/* * Decompiled with CFR 0.152. */ package javax.baja.util; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.StringTokenizer; import javax.baja.naming.SlotPath; import javax.baja.sys.BObject; import javax.baja.sys.BSimple; import javax.baja.sys.Context; import javax.baja.sys.IllegalNameException; import javax.baja.sys.Sys; import javax.baja.sys.Type; /* * Illegal identifiers - consider using --renameillegalidents true */ public final class BNameList extends BSimple { public static final BNameList NULL; public static final BNameList DEFAULT; public static final Type TYPE; private String string; private String[] names; private int hashCode; static /* synthetic */ Class class$javax$baja$util$BNameList; public static final BNameList make(String string) { return BNameList.make(new String[]{string}); } public static final BNameList make(String[] stringArray) { if (stringArray.length == 0) { return NULL; } String[] stringArray2 = new String[stringArray.length]; int n = 0; while (n < stringArray.length) { String string = stringArray2[n] = stringArray[n]; SlotPath.verifyValidName(string); ++n; } return (BNameList)new BNameList(stringArray2).intern(); } public static final BNameList union(BNameList bNameList, BNameList bNameList2) { if (bNameList.isNull()) { return bNameList2; } if (bNameList2.isNull()) { return bNameList; } HashMap hashMap = new HashMap(); String[] stringArray = bNameList.names; String[] stringArray2 = bNameList2.names; int n = 0; while (n < stringArray.length) { hashMap.put(stringArray[n], stringArray[n]); ++n; } n = 0; while (n < stringArray2.length) { hashMap.put(stringArray2[n], stringArray2[n]); ++n; } String[] stringArray3 = hashMap.values().toArray(new String[hashMap.size()]); return (BNameList)new BNameList(stringArray3).intern(); } public static final BNameList intersection(BNameList bNameList, BNameList bNameList2) { if (bNameList.isNull()) { return NULL; } if (bNameList2.isNull()) { return NULL; } ArrayList arrayList = new ArrayList(); String[] stringArray = bNameList.names; int n = 0; while (n < stringArray.length) { if (bNameList2.contains(stringArray[n])) { arrayList.add(stringArray[n]); } ++n; } String[] stringArray2 = arrayList.toArray(new String[arrayList.size()]); return (BNameList)new BNameList(stringArray2).intern(); } public static final BNameList difference(BNameList bNameList, BNameList bNameList2) { if (bNameList.isNull()) { return NULL; } if (bNameList2.isNull()) { return bNameList; } HashSet hashSet = new HashSet(bNameList2.names.length); int n = 0; while (n < bNameList2.names.length) { hashSet.add(bNameList2.names[n]); ++n; } ArrayList arrayList = new ArrayList(); int n2 = 0; while (n2 < bNameList.names.length) { if (!hashSet.contains(bNameList.names[n2])) { arrayList.add(bNameList.names[n2]); } ++n2; } return (BNameList)new BNameList(arrayList.toArray(new String[arrayList.size()])).intern(); } public final String[] getNames() { String[] stringArray = new String[this.names.length]; System.arraycopy(this.names, 0, stringArray, 0, stringArray.length); return stringArray; } public final boolean contains(String string) { String[] stringArray = this.names; int n = 0; while (n < stringArray.length) { if (stringArray[n].equals(string)) { return true; } ++n; } return false; } public final boolean isNull() { boolean bl = false; if (this.names.length == 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 BNameList) { BNameList bNameList = (BNameList)object; if (this.names.length != bNameList.names.length) { return false; } int n = 0; while (n < this.names.length) { if (!bNameList.contains(this.names[n])) { return false; } ++n; } 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(); int n = 0; while (n < this.names.length) { if (n > 0) { stringBuffer.append(';'); } stringBuffer.append(this.names[n]); ++n; } this.string = stringBuffer.toString(); } return this.string; } public final BObject decodeFromString(String string) throws IOException { try { Object object; ArrayList arrayList = new ArrayList(); StringTokenizer stringTokenizer = new StringTokenizer(string, ";"); while (stringTokenizer.hasMoreTokens()) { object = stringTokenizer.nextToken().trim(); SlotPath.verifyValidName((String)object); arrayList.add((String)object); } object = (BNameList)new BNameList(arrayList.toArray(new String[arrayList.size()])).intern(); ((BNameList)object).string = string; return object; } catch (IllegalNameException illegalNameException) { throw illegalNameException; } catch (Exception exception) { throw new IOException("Invalid BNameList: " + string); } } 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 BNameList(String[] stringArray) { this.this(); this.names = stringArray; } static { DEFAULT = NULL = new BNameList(new String[0]); Class clazz = class$javax$baja$util$BNameList; if (clazz == null) { clazz = class$javax$baja$util$BNameList = BNameList.class("[Ljavax.baja.util.BNameList;", false); } TYPE = Sys.loadType(clazz); } }