/* * Decompiled with CFR 0.152. * * Could not load the following classes: * javax.baja.nre.util.Array */ package javax.baja.util; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import javax.baja.nre.util.Array; import javax.baja.sys.BObject; import javax.baja.sys.BSimple; import javax.baja.sys.Context; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BFormat; /* * Illegal identifiers - consider using --renameillegalidents true */ public final class BNameMap extends BSimple { public static final BNameMap NULL; public static final BNameMap DEFAULT; public static final Type TYPE; private String string; private HashMap map; private int hashCode; static /* synthetic */ Class class$javax$baja$util$BNameMap; static /* synthetic */ Class class$java$lang$String; public static final BNameMap make(HashMap hashMap) { if (hashMap.size() == 0) { return NULL; } String string = (String)hashMap.keySet().iterator().next(); BFormat bFormat = (BFormat)hashMap.get(string); return (BNameMap)new BNameMap((HashMap)hashMap.clone()).intern(); } public static final BNameMap make(BNameMap bNameMap, String string, String string2) { return BNameMap.make(bNameMap, string, BFormat.make(string2)); } public static final BNameMap make(BNameMap bNameMap, String string, BFormat bFormat) { HashMap hashMap = (HashMap)bNameMap.map.clone(); hashMap.put(string, bFormat); return (BNameMap)new BNameMap(hashMap).intern(); } public static final BNameMap make(BNameMap bNameMap, BNameMap bNameMap2) { HashMap hashMap = (HashMap)bNameMap.map.clone(); String[] stringArray = bNameMap2.list(); int n = 0; while (n < stringArray.length) { hashMap.put(stringArray[n], bNameMap2.get(stringArray[n])); ++n; } return (BNameMap)new BNameMap(hashMap).intern(); } public static final BNameMap remove(BNameMap bNameMap, String string) { HashMap hashMap = (HashMap)bNameMap.map.clone(); hashMap.remove(string); return (BNameMap)new BNameMap(hashMap).intern(); } public final String[] list() { return this.map.keySet().toArray(new String[this.map.size()]); } public final BFormat get(String string) { return (BFormat)this.map.get(string); } public final boolean isNull() { boolean bl = false; if (this.map.size() == 0) { bl = true; } return bl; } public final int hashCode() { try { if (this.hashCode == -1) { this.hashCode = this.encodeToString().hashCode(); } return this.hashCode; } catch (Exception exception) { return System.identityHashCode(this); } } public final boolean equals(Object object) { if (object instanceof BNameMap) { BNameMap bNameMap = (BNameMap)object; if (this.map.size() != bNameMap.map.size()) { return false; } Iterator iterator = this.map.keySet().iterator(); while (iterator.hasNext()) { String string = (String)iterator.next(); BFormat bFormat = (BFormat)this.map.get(string); if (bFormat.equals(bNameMap.map.get(string))) continue; return false; } return true; } return false; } public final String toString(Context context) { return this.encodeToString(); } public final void encode(DataOutput dataOutput) throws IOException { dataOutput.writeUTF(this.encodeToString()); } public final BObject decode(DataInput dataInput) throws IOException { return this.decodeFromString(dataInput.readUTF()); } public final String encodeToString() { if (this.string == null) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append('{'); Iterator iterator = this.map.keySet().iterator(); while (iterator.hasNext()) { String string = (String)iterator.next(); BFormat bFormat = (BFormat)this.map.get(string); this.escape(stringBuffer, string); stringBuffer.append('='); this.escape(stringBuffer, bFormat.getFormat()); stringBuffer.append(';'); } stringBuffer.append('}'); this.string = stringBuffer.toString(); } return this.string; } public final BObject decodeFromString(String string) throws IOException { try { int n; int n2 = string.indexOf(123); int n3 = string.lastIndexOf(125); if (n2 + 1 == n3) { return NULL; } String string2 = string.substring(n2 + 1, n3); Class clazz = class$java$lang$String; if (clazz == null) { clazz = class$java$lang$String = BNameMap.class("[Ljava.lang.String;", false); } Array array = new Array(clazz); int n4 = string2.length(); StringBuffer stringBuffer = new StringBuffer(); int n5 = 59; int n6 = 0; while (n6 < n4) { n = string2.charAt(n6); if (n == 92) { stringBuffer.append(string2.charAt(++n6)); } else if (n != 61 && n != 59) { stringBuffer.append((char)n); } else { if (n == n5) { throw new Exception(); } n5 = n; array.add((Object)stringBuffer.toString()); stringBuffer.setLength(0); } ++n6; } HashMap hashMap = new HashMap(); n = 0; while (n < array.size()) { String string3 = (String)array.get(n); BFormat bFormat = BFormat.make((String)array.get(n + '\u0001')); hashMap.put(string3, bFormat); n += 2; } BNameMap bNameMap = (BNameMap)new BNameMap(hashMap).intern(); bNameMap.string = string; return bNameMap; } catch (Exception exception) { throw new IOException("Invalid BNameMap: " + string); } } private final void escape(StringBuffer stringBuffer, String string) { int n = string.length(); int n2 = 0; while (n2 < n) { char c = string.charAt(n2); switch (c) { case '\\': { stringBuffer.append("\\\\"); break; } case '{': { stringBuffer.append("\\{"); break; } case '}': { stringBuffer.append("\\}"); break; } case '=': { stringBuffer.append("\\="); break; } case ';': { stringBuffer.append("\\;"); break; } default: { stringBuffer.append(c); } } ++n2; } } public final Type getType() { return TYPE; } static /* synthetic */ Class class(String string, boolean bl) { try { Class clazz = Class.forName(string); if (!bl) { clazz = clazz.getComponentType(); } return clazz; } catch (ClassNotFoundException classNotFoundException) { throw new NoClassDefFoundError(classNotFoundException.getMessage()); } } private final /* synthetic */ void this() { this.hashCode = -1; } private BNameMap(HashMap hashMap) { this.this(); this.map = hashMap; } static { DEFAULT = NULL = new BNameMap(new HashMap()); Class clazz = class$javax$baja$util$BNameMap; if (clazz == null) { clazz = class$javax$baja$util$BNameMap = BNameMap.class("[Ljavax.baja.util.BNameMap;", false); } TYPE = Sys.loadType(clazz); } }