142 lines
3.4 KiB
Java
142 lines
3.4 KiB
Java
package com.thoughtworks.xstream.io.binary;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
class ReaderDepthState {
|
|
private static final String EMPTY_STRING = "";
|
|
private State current;
|
|
|
|
private static class Attribute {
|
|
String name;
|
|
String value;
|
|
|
|
private Attribute() {
|
|
}
|
|
}
|
|
|
|
private static class State {
|
|
List attributes;
|
|
boolean hasMoreChildren;
|
|
String name;
|
|
State parent;
|
|
String value;
|
|
|
|
private State() {
|
|
}
|
|
}
|
|
|
|
ReaderDepthState() {
|
|
}
|
|
|
|
public void addAttribute(String str, String str2) {
|
|
Attribute attribute = new Attribute();
|
|
attribute.name = str;
|
|
attribute.value = str2;
|
|
State state = this.current;
|
|
if (state.attributes == null) {
|
|
state.attributes = new ArrayList();
|
|
}
|
|
this.current.attributes.add(attribute);
|
|
}
|
|
|
|
public String getAttribute(String str) {
|
|
List<Attribute> list = this.current.attributes;
|
|
if (list == null) {
|
|
return null;
|
|
}
|
|
for (Attribute attribute : list) {
|
|
if (attribute.name.equals(str)) {
|
|
return attribute.value;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public int getAttributeCount() {
|
|
List list = this.current.attributes;
|
|
if (list == null) {
|
|
return 0;
|
|
}
|
|
return list.size();
|
|
}
|
|
|
|
public String getAttributeName(int i) {
|
|
List list = this.current.attributes;
|
|
if (list == null) {
|
|
return null;
|
|
}
|
|
return ((Attribute) list.get(i)).name;
|
|
}
|
|
|
|
public Iterator getAttributeNames() {
|
|
List list = this.current.attributes;
|
|
if (list == null) {
|
|
return Collections.EMPTY_SET.iterator();
|
|
}
|
|
final Iterator it = list.iterator();
|
|
return new Iterator() { // from class: com.thoughtworks.xstream.io.binary.ReaderDepthState.1
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return it.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public Object next() {
|
|
return ((Attribute) it.next()).name;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
};
|
|
}
|
|
|
|
public String getName() {
|
|
return this.current.name;
|
|
}
|
|
|
|
public String getValue() {
|
|
String str = this.current.value;
|
|
return str == null ? "" : str;
|
|
}
|
|
|
|
public boolean hasMoreChildren() {
|
|
return this.current.hasMoreChildren;
|
|
}
|
|
|
|
public void pop() {
|
|
this.current = this.current.parent;
|
|
}
|
|
|
|
public void push() {
|
|
State state = new State();
|
|
state.parent = this.current;
|
|
this.current = state;
|
|
}
|
|
|
|
public void setHasMoreChildren(boolean z) {
|
|
this.current.hasMoreChildren = z;
|
|
}
|
|
|
|
public void setName(String str) {
|
|
this.current.name = str;
|
|
}
|
|
|
|
public void setValue(String str) {
|
|
this.current.value = str;
|
|
}
|
|
|
|
public String getAttribute(int i) {
|
|
List list = this.current.attributes;
|
|
if (list == null) {
|
|
return null;
|
|
}
|
|
return ((Attribute) list.get(i)).value;
|
|
}
|
|
}
|