/* * Decompiled with CFR 0.152. */ package javax.baja.naming; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; import java.util.StringTokenizer; import javax.baja.naming.BOrd; 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; /* * Illegal identifiers - consider using --renameillegalidents true */ public final class BOrdList extends BSimple { public static final BOrdList NULL; public static final BOrdList DEFAULT; public static final Type TYPE; private int hashCode; private BOrd[] ords; private String string; static /* synthetic */ Class class$javax$baja$naming$BOrdList; public static final BOrdList make(BOrd bOrd) { return new BOrdList(new BOrd[]{bOrd}, bOrd.encodeToString()); } public static final BOrdList make(BOrd[] bOrdArray) { if (bOrdArray.length == 0) { return NULL; } return new BOrdList((BOrd[])bOrdArray.clone(), null); } public static final BOrdList add(BOrdList bOrdList, BOrd bOrd) { BOrd[] bOrdArray = new BOrd[bOrdList.ords.length + 1]; System.arraycopy(bOrdList.ords, 0, bOrdArray, 0, bOrdList.ords.length); bOrdArray[bOrdArray.length - 1] = bOrd; return new BOrdList(bOrdArray, null); } public static final BOrdList remove(BOrdList bOrdList, int n) { BOrd[] bOrdArray = new BOrd[bOrdList.ords.length - 1]; System.arraycopy(bOrdList.ords, 0, bOrdArray, 0, n); if (n < bOrdList.ords.length) { System.arraycopy(bOrdList.ords, n + 1, bOrdArray, n, bOrdList.ords.length - n - 1); } return new BOrdList(bOrdArray, null); } public static final BOrdList make(String string) { return (BOrdList)DEFAULT.decodeFromString(string); } public final BOrd get(int n) { return this.ords[n]; } public final int size() { return this.ords.length; } public final boolean isNull() { boolean bl = false; if (this.ords.length == 0) { bl = true; } return bl; } public final BOrd[] toArray() { return (BOrd[])this.ords.clone(); } public final int hashCode() { if (this.hashCode == -1) { int n = 11; int n2 = 0; while (n2 < this.ords.length) { n ^= this.ords[n2].hashCode(); ++n2; } this.hashCode = n; } return this.hashCode; } public final boolean equals(Object object) { if (object instanceof BOrdList) { BOrd[] bOrdArray = this.ords; BOrd[] bOrdArray2 = ((BOrdList)object).ords; if (bOrdArray.length != bOrdArray2.length) { return false; } int n = 0; while (n < bOrdArray.length) { if (!bOrdArray[n].equals(bOrdArray2[n])) { return false; } ++n; } return true; } return false; } 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) { if (this.ords.length == 1) { this.string = this.ords[0].encodeToString(); } else { StringBuffer stringBuffer = new StringBuffer(); int n = 0; while (n < this.ords.length) { if (n > 0) { stringBuffer.append('\n'); } stringBuffer.append(this.ords[n].encodeToString()); ++n; } this.string = stringBuffer.toString(); } } return this.string; } public final BObject decodeFromString(String string) { if (string.length() == 0) { return DEFAULT; } int n = string.indexOf(10); if (n < 0) { return new BOrdList(new BOrd[]{BOrd.make(string)}, string); } ArrayList arrayList = new ArrayList(); StringTokenizer stringTokenizer = new StringTokenizer(string, "\n"); while (stringTokenizer.hasMoreTokens()) { arrayList.add(BOrd.make(stringTokenizer.nextToken())); } BOrd[] bOrdArray = arrayList.toArray(new BOrd[arrayList.size()]); return new BOrdList(bOrdArray, string); } public final String toString(Context context) { if (this.ords.length == 1) { return this.ords[0].toString(context); } StringBuffer stringBuffer = new StringBuffer(); int n = 0; while (n < this.ords.length) { if (n > 0) { stringBuffer.append("; "); } stringBuffer.append(this.ords[n].toString(context)); ++n; } return stringBuffer.toString(); } 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 BOrdList(BOrd[] bOrdArray, String string) { this.this(); this.ords = bOrdArray; this.string = string; } static { DEFAULT = NULL = new BOrdList(new BOrd[0], ""); Class clazz = class$javax$baja$naming$BOrdList; if (clazz == null) { clazz = class$javax$baja$naming$BOrdList = BOrdList.class("[Ljavax.baja.naming.BOrdList;", false); } TYPE = Sys.loadType(clazz); } }