MD5 校验值:195005882709ac21163d7a1b97aeec73
Namespace.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package gnu.mapping; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.ObjectStreamException; import java.util.Hashtable; public class Namespace implements Externalizable, HasNamedParts { int log2Size; private int mask; String name; int num_bindings; protected String prefix; protected SymbolRef[] table; protected static final Hashtable nsTable = new Hashtable(50); public static final Namespace EmptyNamespace = valueOf(""); public Namespace() { this(64); } protected Namespace(int i) { this.prefix = ""; this.log2Size = 4; while (i > (1 << this.log2Size)) { this.log2Size++; } int i2 = 1 << this.log2Size; this.table = new SymbolRef[i2]; this.mask = i2 - 1; } public static Namespace create() { return new Namespace(64); } public static Namespace create(int i) { return new Namespace(i); } public static Namespace getDefault() { return EmptyNamespace; } public static Symbol getDefaultSymbol(String str) { return EmptyNamespace.getSymbol(str); } public static Namespace makeUnknownNamespace(String str) { return valueOf((str == null || str == "") ? "" : "http://kawa.gnu.org/unknown-namespace/" + str, str); } public static Namespace valueOf() { return EmptyNamespace; } public static Namespace valueOf(String str) { String str2 = str; if (str2 == null) { str2 = ""; } synchronized (nsTable) { Namespace namespace = (Namespace) nsTable.get(str2); if (namespace != null) { return namespace; } Namespace namespace2 = new Namespace(); namespace2.setName(str2.intern()); nsTable.put(str2, namespace2); return namespace2; } } public static Namespace valueOf(String str, SimpleSymbol simpleSymbol) { return valueOf(str, simpleSymbol == null ? null : simpleSymbol.getName()); } public static Namespace valueOf(String str, String str2) { Namespace namespace; if (str2 == null || str2.length() == 0) { return valueOf(str); } String str3 = str2 + " -> " + str; synchronized (nsTable) { Object obj = nsTable.get(str3); if (obj instanceof Namespace) { namespace = (Namespace) obj; } else { Namespace namespace2 = new Namespace(); namespace2.setName(str.intern()); namespace2.prefix = str2.intern(); nsTable.put(str3, namespace2); namespace = namespace2; } } return namespace; } public Symbol add(Symbol symbol, int i) { int i2 = i & this.mask; SymbolRef symbolRef = new SymbolRef(symbol, this); symbol.namespace = this; symbolRef.next = this.table[i2]; this.table[i2] = symbolRef; this.num_bindings++; if (this.num_bindings >= this.table.length) { rehash(); } return symbol; } public Object get(String str) { return Environment.getCurrent().get(getSymbol(str)); } public final String getName() { return this.name; } public final String getPrefix() { return this.prefix; } public Symbol getSymbol(String str) { return lookup(str, str.hashCode(), true); } public boolean isConstant(String str) { return false; } public Symbol lookup(String str) { return lookup(str, str.hashCode(), false); } public Symbol lookup(String str, int i, boolean z) { synchronized (this) { Symbol lookupInternal = lookupInternal(str, i); if (lookupInternal != null) { return lookupInternal; } if (z) { return add(this == EmptyNamespace ? new SimpleSymbol(str) : new Symbol(this, str), i); } return null; } } public final Symbol lookupInternal(String str, int i) { int i2 = i & this.mask; SymbolRef symbolRef = null; SymbolRef symbolRef2 = this.table[i2]; while (true) { SymbolRef symbolRef3 = symbolRef2; if (symbolRef3 == null) { return null; } SymbolRef symbolRef4 = symbolRef3.next; Symbol symbol = symbolRef3.getSymbol(); if (symbol == null) { if (symbolRef == null) { this.table[i2] = symbolRef4; } else { symbolRef.next = symbolRef4; } this.num_bindings--; } else { if (symbol.getLocalPart().equals(str)) { return symbol; } symbolRef = symbolRef3; } symbolRef2 = symbolRef4; } } @Override public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException { this.name = ((String) objectInput.readObject()).intern(); this.prefix = (String) objectInput.readObject(); } public Object readResolve() throws ObjectStreamException { String name = getName(); if (name != null) { String str = (this.prefix == null || this.prefix.length() == 0) ? name : this.prefix + " -> " + name; Namespace namespace = (Namespace) nsTable.get(str); if (namespace != null) { return namespace; } nsTable.put(str, this); } return this; } protected void rehash() { int length = this.table.length; int i = 2 * length; int i2 = i - 1; int i3 = 0; SymbolRef[] symbolRefArr = this.table; SymbolRef[] symbolRefArr2 = new SymbolRef[i]; int i4 = length; while (true) { i4--; if (i4 < 0) { this.table = symbolRefArr2; this.log2Size++; this.mask = i2; this.num_bindings = i3; return; } SymbolRef symbolRef = symbolRefArr[i4]; while (true) { SymbolRef symbolRef2 = symbolRef; if (symbolRef2 != null) { SymbolRef symbolRef3 = symbolRef2.next; Symbol symbol = symbolRef2.getSymbol(); if (symbol != null) { int hashCode = symbol.getName().hashCode() & i2; i3++; symbolRef2.next = symbolRefArr2[hashCode]; symbolRefArr2[hashCode] = symbolRef2; } symbolRef = symbolRef3; } } } } public boolean remove(Symbol symbol) { synchronized (this) { int hashCode = symbol.getLocalPart().hashCode() & this.mask; SymbolRef symbolRef = null; SymbolRef symbolRef2 = this.table[hashCode]; while (true) { SymbolRef symbolRef3 = symbolRef2; if (symbolRef3 == null) { return false; } SymbolRef symbolRef4 = symbolRef3.next; Symbol symbol2 = symbolRef3.getSymbol(); if (symbol2 == null || symbol2 == symbol) { if (symbolRef == null) { this.table[hashCode] = symbolRef4; } else { symbolRef.next = symbolRef4; } this.num_bindings--; if (symbol2 != null) { return true; } } else { symbolRef = symbolRef3; } symbolRef2 = symbolRef4; } } } public final void setName(String str) { this.name = str; } public String toString() { StringBuilder sb = new StringBuilder("#,(namespace \""); sb.append(this.name); sb.append('\"'); if (this.prefix != null && this.prefix != "") { sb.append(' '); sb.append(this.prefix); } sb.append(')'); return sb.toString(); } @Override public void writeExternal(ObjectOutput objectOutput) throws IOException { objectOutput.writeObject(getName()); objectOutput.writeObject(this.prefix); } }