207 lines
6.3 KiB
Java
207 lines
6.3 KiB
Java
package org.simpleframework.xml.stream;
|
|
|
|
import org.xmlpull.v1.XmlPullParser;
|
|
|
|
/* loaded from: classes.dex */
|
|
class PullReader implements EventReader {
|
|
private XmlPullParser parser;
|
|
private EventNode peek;
|
|
|
|
public PullReader(XmlPullParser xmlPullParser) {
|
|
this.parser = xmlPullParser;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventReader
|
|
public EventNode peek() throws Exception {
|
|
if (this.peek == null) {
|
|
this.peek = next();
|
|
}
|
|
return this.peek;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventReader
|
|
public EventNode next() throws Exception {
|
|
EventNode eventNode = this.peek;
|
|
if (eventNode == null) {
|
|
return read();
|
|
}
|
|
this.peek = null;
|
|
return eventNode;
|
|
}
|
|
|
|
private EventNode read() throws Exception {
|
|
int next;
|
|
do {
|
|
next = this.parser.next();
|
|
if (next == 1) {
|
|
return null;
|
|
}
|
|
if (next == 2) {
|
|
return start();
|
|
}
|
|
if (next == 4) {
|
|
return text();
|
|
}
|
|
} while (next != 3);
|
|
return end();
|
|
}
|
|
|
|
private Text text() throws Exception {
|
|
return new Text(this.parser);
|
|
}
|
|
|
|
private Start start() throws Exception {
|
|
Start start = new Start(this.parser);
|
|
return start.isEmpty() ? build(start) : start;
|
|
}
|
|
|
|
private Start build(Start start) throws Exception {
|
|
int attributeCount = this.parser.getAttributeCount();
|
|
for (int i = 0; i < attributeCount; i++) {
|
|
Entry attribute = attribute(i);
|
|
if (!attribute.isReserved()) {
|
|
start.add(attribute);
|
|
}
|
|
}
|
|
return start;
|
|
}
|
|
|
|
private Entry attribute(int i) throws Exception {
|
|
return new Entry(this.parser, i);
|
|
}
|
|
|
|
private End end() throws Exception {
|
|
return new End();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class Entry extends EventAttribute {
|
|
private final String name;
|
|
private final String prefix;
|
|
private final String reference;
|
|
private final XmlPullParser source;
|
|
private final String value;
|
|
|
|
@Override // org.simpleframework.xml.stream.EventAttribute, org.simpleframework.xml.stream.Attribute
|
|
public boolean isReserved() {
|
|
return false;
|
|
}
|
|
|
|
public Entry(XmlPullParser xmlPullParser, int i) {
|
|
this.reference = xmlPullParser.getAttributeNamespace(i);
|
|
this.prefix = xmlPullParser.getAttributePrefix(i);
|
|
this.value = xmlPullParser.getAttributeValue(i);
|
|
this.name = xmlPullParser.getAttributeName(i);
|
|
this.source = xmlPullParser;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.Attribute
|
|
public String getValue() {
|
|
return this.value;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventAttribute, org.simpleframework.xml.stream.Attribute
|
|
public Object getSource() {
|
|
return this.source;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventAttribute, org.simpleframework.xml.stream.Attribute
|
|
public String getReference() {
|
|
return this.reference;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventAttribute, org.simpleframework.xml.stream.Attribute
|
|
public String getPrefix() {
|
|
return this.prefix;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.Attribute
|
|
public String getName() {
|
|
return this.name;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class Start extends EventElement {
|
|
private final int line;
|
|
private final String name;
|
|
private final String prefix;
|
|
private final String reference;
|
|
private final XmlPullParser source;
|
|
|
|
public Start(XmlPullParser xmlPullParser) {
|
|
this.reference = xmlPullParser.getNamespace();
|
|
this.line = xmlPullParser.getLineNumber();
|
|
this.prefix = xmlPullParser.getPrefix();
|
|
this.name = xmlPullParser.getName();
|
|
this.source = xmlPullParser;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventNode
|
|
public Object getSource() {
|
|
return this.source;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventNode
|
|
public String getReference() {
|
|
return this.reference;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventNode
|
|
public String getPrefix() {
|
|
return this.prefix;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventNode
|
|
public String getName() {
|
|
return this.name;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventElement, org.simpleframework.xml.stream.EventNode
|
|
public int getLine() {
|
|
return this.line;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class Text extends EventToken {
|
|
private final XmlPullParser source;
|
|
private final String text;
|
|
|
|
@Override // org.simpleframework.xml.stream.EventToken, org.simpleframework.xml.stream.EventNode
|
|
public boolean isText() {
|
|
return true;
|
|
}
|
|
|
|
public Text(XmlPullParser xmlPullParser) {
|
|
this.text = xmlPullParser.getText();
|
|
this.source = xmlPullParser;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventToken, org.simpleframework.xml.stream.EventNode
|
|
public String getValue() {
|
|
return this.text;
|
|
}
|
|
|
|
@Override // org.simpleframework.xml.stream.EventToken, org.simpleframework.xml.stream.EventNode
|
|
public Object getSource() {
|
|
return this.source;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class End extends EventToken {
|
|
@Override // org.simpleframework.xml.stream.EventToken, org.simpleframework.xml.stream.EventNode
|
|
public boolean isEnd() {
|
|
return true;
|
|
}
|
|
|
|
private End() {
|
|
}
|
|
}
|
|
}
|