195 lines
5.7 KiB
Java
195 lines
5.7 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package javax.baja.util;
|
|
|
|
import com.tridium.util.ArrayUtil;
|
|
import java.io.DataInput;
|
|
import java.io.DataOutput;
|
|
import java.io.IOException;
|
|
import java.util.StringTokenizer;
|
|
import javax.baja.sys.BEnumRange;
|
|
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 BEnumSet
|
|
extends BSimple {
|
|
public static final BEnumSet NULL;
|
|
public static final BEnumSet DEFAULT;
|
|
public static final Type TYPE;
|
|
private int[] ordinals;
|
|
private BEnumRange range;
|
|
private int hashCode;
|
|
static /* synthetic */ Class class$javax$baja$util$BEnumSet;
|
|
|
|
public static final BEnumSet make(int[] nArray, BEnumRange bEnumRange) {
|
|
if (bEnumRange == null) {
|
|
bEnumRange = BEnumRange.NULL;
|
|
}
|
|
return (BEnumSet)new BEnumSet(nArray, bEnumRange).intern();
|
|
}
|
|
|
|
public static final BEnumSet make(int[] nArray) {
|
|
return BEnumSet.make(nArray, BEnumRange.NULL);
|
|
}
|
|
|
|
public final int[] getOrdinals() {
|
|
return (int[])this.ordinals.clone();
|
|
}
|
|
|
|
public final boolean contains(int n) {
|
|
boolean bl = false;
|
|
if (ArrayUtil.binarySearch(this.ordinals, n) != -1) {
|
|
bl = true;
|
|
}
|
|
return bl;
|
|
}
|
|
|
|
public final BEnumRange getRange() {
|
|
return this.range;
|
|
}
|
|
|
|
public final boolean isNull() {
|
|
boolean bl = false;
|
|
if (this.ordinals.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 BEnumSet) {
|
|
BEnumSet bEnumSet = (BEnumSet)object;
|
|
if (this.ordinals.length != bEnumSet.ordinals.length) {
|
|
return false;
|
|
}
|
|
int n = 0;
|
|
while (n < this.ordinals.length) {
|
|
if (this.ordinals[n] != bEnumSet.ordinals[n]) {
|
|
return false;
|
|
}
|
|
++n;
|
|
}
|
|
return this.range.equals(bEnumSet.range);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public final String toString(Context context) {
|
|
Object object;
|
|
Object object2 = this.range;
|
|
if (context != null && (object = (BEnumRange)context.getFacet("range")) != null) {
|
|
object2 = object;
|
|
}
|
|
object = new StringBuffer();
|
|
int n = 0;
|
|
while (n < this.ordinals.length) {
|
|
if (n > 0) {
|
|
((StringBuffer)object).append(',');
|
|
}
|
|
((StringBuffer)object).append(((BEnumRange)object2).getDisplayTag(this.ordinals[n], context));
|
|
++n;
|
|
}
|
|
return ((StringBuffer)object).toString();
|
|
}
|
|
|
|
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() throws IOException {
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
int n = 0;
|
|
while (n < this.ordinals.length) {
|
|
if (n > 0) {
|
|
stringBuffer.append(',');
|
|
}
|
|
stringBuffer.append(this.ordinals[n]);
|
|
++n;
|
|
}
|
|
if (!this.range.isNull()) {
|
|
stringBuffer.append('@').append(this.range.encodeToString());
|
|
}
|
|
return stringBuffer.toString();
|
|
}
|
|
|
|
public final BObject decodeFromString(String string) throws IOException {
|
|
BEnumRange bEnumRange = null;
|
|
int n = string.indexOf(64);
|
|
if (n > 0) {
|
|
bEnumRange = (BEnumRange)BEnumRange.DEFAULT.decodeFromString(string.substring(n + 1));
|
|
string = string.substring(0, n);
|
|
}
|
|
int[] nArray = new int[string.length() / 2 + 1];
|
|
int n2 = 0;
|
|
StringTokenizer stringTokenizer = new StringTokenizer(string, ",");
|
|
while (stringTokenizer.hasMoreTokens()) {
|
|
nArray[n2++] = Integer.parseInt(stringTokenizer.nextToken());
|
|
}
|
|
int[] nArray2 = new int[n2];
|
|
System.arraycopy(nArray, 0, nArray2, 0, n2);
|
|
return BEnumSet.make(nArray2, bEnumRange);
|
|
}
|
|
|
|
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 BEnumSet(int[] nArray, BEnumRange bEnumRange) {
|
|
this.this();
|
|
nArray = (int[])nArray.clone();
|
|
ArrayUtil.sort(nArray);
|
|
this.ordinals = nArray;
|
|
this.range = bEnumRange;
|
|
}
|
|
|
|
static {
|
|
DEFAULT = NULL = BEnumSet.make(new int[0], BEnumRange.NULL);
|
|
Class clazz = class$javax$baja$util$BEnumSet;
|
|
if (clazz == null) {
|
|
clazz = class$javax$baja$util$BEnumSet = BEnumSet.class("[Ljavax.baja.util.BEnumSet;", false);
|
|
}
|
|
TYPE = Sys.loadType(clazz);
|
|
}
|
|
}
|
|
|