344 lines
10 KiB
Java
344 lines
10 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package javax.baja.units;
|
|
|
|
import java.io.DataInput;
|
|
import java.io.DataOutput;
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
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 BDimension
|
|
extends BSimple {
|
|
private static final HashMap cache = new HashMap();
|
|
public static final BDimension DEFAULT;
|
|
public static final BDimension NULL;
|
|
public static final Type TYPE;
|
|
private int exp0;
|
|
private int exp1;
|
|
private String string;
|
|
static /* synthetic */ Class class$javax$baja$units$BDimension;
|
|
|
|
public static final BDimension make(int n, int n2, int n3, int n4, int n5, int n6, int n7) {
|
|
return BDimension.make(n, n2, n3, n4, n5, n6, n7, 0);
|
|
}
|
|
|
|
/*
|
|
* WARNING - Removed try catching itself - possible behaviour change.
|
|
* Enabled aggressive block sorting
|
|
* Enabled unnecessary exception pruning
|
|
* Enabled aggressive exception aggregation
|
|
*/
|
|
public static final BDimension make(int n, int n2, int n3, int n4, int n5, int n6, int n7, int n8) {
|
|
BDimension bDimension = new BDimension();
|
|
bDimension.exp0 = (n & 0xFF) << 24 | (n2 & 0xFF) << 16 | (n3 & 0xFF) << 8 | n4 & 0xFF;
|
|
bDimension.exp1 = (n5 & 0xFF) << 24 | (n6 & 0xFF) << 16 | (n7 & 0xFF) << 8 | n8 & 0xFF;
|
|
HashMap hashMap = cache;
|
|
synchronized (hashMap) {
|
|
BDimension bDimension2 = (BDimension)cache.get(bDimension);
|
|
if (bDimension2 != null) {
|
|
return bDimension2;
|
|
}
|
|
cache.put(bDimension, bDimension);
|
|
return bDimension;
|
|
}
|
|
}
|
|
|
|
public final int getMeter() {
|
|
return (byte)(this.exp0 >> 24 & 0xFF);
|
|
}
|
|
|
|
public final int getKilogram() {
|
|
return (byte)(this.exp0 >> 16 & 0xFF);
|
|
}
|
|
|
|
public final int getSecond() {
|
|
return (byte)(this.exp0 >> 8 & 0xFF);
|
|
}
|
|
|
|
public final int getAmpere() {
|
|
return (byte)(this.exp0 & 0xFF);
|
|
}
|
|
|
|
public final int getKelvin() {
|
|
return (byte)(this.exp1 >> 24 & 0xFF);
|
|
}
|
|
|
|
public final int getMole() {
|
|
return (byte)(this.exp1 >> 16 & 0xFF);
|
|
}
|
|
|
|
public final int getCandela() {
|
|
return (byte)(this.exp1 >> 8 & 0xFF);
|
|
}
|
|
|
|
public final int getDollar() {
|
|
return (byte)(this.exp1 & 0xFF);
|
|
}
|
|
|
|
public final String toString(Context context) {
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
BDimension.append(stringBuffer, "m", this.getMeter());
|
|
BDimension.append(stringBuffer, "kg", this.getKilogram());
|
|
BDimension.append(stringBuffer, "s", this.getSecond());
|
|
BDimension.append(stringBuffer, "A", this.getAmpere());
|
|
BDimension.append(stringBuffer, "K", this.getKelvin());
|
|
BDimension.append(stringBuffer, "mol", this.getMole());
|
|
BDimension.append(stringBuffer, "cd", this.getCandela());
|
|
BDimension.append(stringBuffer, "$", this.getDollar());
|
|
return stringBuffer.toString();
|
|
}
|
|
|
|
private static final void append(StringBuffer stringBuffer, String string, int n) {
|
|
if (n == 0) {
|
|
return;
|
|
}
|
|
if (stringBuffer.length() > 0) {
|
|
stringBuffer.append('\u00b7');
|
|
}
|
|
stringBuffer.append(string);
|
|
if (n > 1) {
|
|
if (n == 2) {
|
|
stringBuffer.append('\u00b2');
|
|
} else if (n == 3) {
|
|
stringBuffer.append('\u00b3');
|
|
} else {
|
|
stringBuffer.append(n);
|
|
}
|
|
} else if (n < 0) {
|
|
stringBuffer.append(n);
|
|
}
|
|
}
|
|
|
|
public final int hashCode() {
|
|
return this.exp0 ^ this.exp1 << 1;
|
|
}
|
|
|
|
public final boolean equals(Object object) {
|
|
if (object instanceof BDimension) {
|
|
BDimension bDimension = (BDimension)object;
|
|
boolean bl = false;
|
|
if (this.exp0 == bDimension.exp0 && this.exp1 == bDimension.exp1) {
|
|
bl = true;
|
|
}
|
|
return bl;
|
|
}
|
|
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) {
|
|
int n;
|
|
int n2;
|
|
int n3;
|
|
int n4;
|
|
int n5;
|
|
int n6;
|
|
int n7;
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
int n8 = this.getMeter();
|
|
if (n8 != 0) {
|
|
stringBuffer.append('(').append('m');
|
|
if (n8 != 1) {
|
|
stringBuffer.append(n8);
|
|
}
|
|
stringBuffer.append(')');
|
|
}
|
|
if ((n7 = this.getKilogram()) != 0) {
|
|
stringBuffer.append('(').append('k').append('g');
|
|
if (n7 != 1) {
|
|
stringBuffer.append(n7);
|
|
}
|
|
stringBuffer.append(')');
|
|
}
|
|
if ((n6 = this.getSecond()) != 0) {
|
|
stringBuffer.append('(').append('s');
|
|
if (n6 != 1) {
|
|
stringBuffer.append(n6);
|
|
}
|
|
stringBuffer.append(')');
|
|
}
|
|
if ((n5 = this.getAmpere()) != 0) {
|
|
stringBuffer.append('(').append('A');
|
|
if (n5 != 1) {
|
|
stringBuffer.append(n5);
|
|
}
|
|
stringBuffer.append(')');
|
|
}
|
|
if ((n4 = this.getKelvin()) != 0) {
|
|
stringBuffer.append('(').append('K');
|
|
if (n4 != 1) {
|
|
stringBuffer.append(n4);
|
|
}
|
|
stringBuffer.append(')');
|
|
}
|
|
if ((n3 = this.getMole()) != 0) {
|
|
stringBuffer.append('(').append("Mol");
|
|
if (n3 != 1) {
|
|
stringBuffer.append(n3);
|
|
}
|
|
stringBuffer.append(')');
|
|
}
|
|
if ((n2 = this.getCandela()) != 0) {
|
|
stringBuffer.append('(').append("cd");
|
|
if (n2 != 1) {
|
|
stringBuffer.append(n2);
|
|
}
|
|
stringBuffer.append(')');
|
|
}
|
|
if ((n = this.getDollar()) != 0) {
|
|
stringBuffer.append('(').append('$');
|
|
if (n != 1) {
|
|
stringBuffer.append(n);
|
|
}
|
|
stringBuffer.append(')');
|
|
}
|
|
this.string = stringBuffer.toString();
|
|
}
|
|
return this.string;
|
|
}
|
|
|
|
public final BObject decodeFromString(String string) throws IOException {
|
|
try {
|
|
int n = 0;
|
|
int n2 = 0;
|
|
int n3 = 0;
|
|
int n4 = 0;
|
|
int n5 = 0;
|
|
int n6 = 0;
|
|
int n7 = 0;
|
|
int n8 = 0;
|
|
int[] nArray = new int[1];
|
|
int n9 = 0;
|
|
int n10 = string.length();
|
|
while (n9 < n10) {
|
|
if (string.charAt(n9++) != '(') {
|
|
throw new Exception();
|
|
}
|
|
char c = string.charAt(n9++);
|
|
switch (c) {
|
|
case '$': {
|
|
n8 = this.parseExp(string, n9, nArray);
|
|
break;
|
|
}
|
|
case 'c': {
|
|
n7 = this.parseExp(string, ++n9, nArray);
|
|
break;
|
|
}
|
|
case 'm': {
|
|
n = this.parseExp(string, n9, nArray);
|
|
break;
|
|
}
|
|
case 'k': {
|
|
n2 = this.parseExp(string, ++n9, nArray);
|
|
break;
|
|
}
|
|
case 's': {
|
|
n3 = this.parseExp(string, n9, nArray);
|
|
break;
|
|
}
|
|
case 'A': {
|
|
n4 = this.parseExp(string, n9, nArray);
|
|
break;
|
|
}
|
|
case 'K': {
|
|
n5 = this.parseExp(string, n9, nArray);
|
|
break;
|
|
}
|
|
case 'M': {
|
|
n6 = this.parseExp(string, n9 += 2, nArray);
|
|
break;
|
|
}
|
|
default: {
|
|
throw new Exception();
|
|
}
|
|
}
|
|
n9 = nArray[0];
|
|
if (string.charAt(n9++) == ')') continue;
|
|
throw new Exception();
|
|
}
|
|
return BDimension.make(n, n2, n3, n4, n5, n6, n7, n8);
|
|
}
|
|
catch (Throwable throwable) {
|
|
throwable.printStackTrace();
|
|
throw new IOException(string);
|
|
}
|
|
}
|
|
|
|
private final int parseExp(String string, int n, int[] nArray) {
|
|
boolean bl = false;
|
|
char c = string.charAt(n);
|
|
if (c == ')') {
|
|
nArray[0] = n;
|
|
return 1;
|
|
}
|
|
if (c == '-') {
|
|
bl = true;
|
|
++n;
|
|
}
|
|
int n2 = 0;
|
|
while ((c = string.charAt(n)) != ')') {
|
|
if (c < '0' || c > '9') {
|
|
throw new IllegalArgumentException("not number: " + c);
|
|
}
|
|
n2 = n2 * 10 + (c - 48);
|
|
++n;
|
|
}
|
|
nArray[0] = n;
|
|
if (bl) {
|
|
return -n2;
|
|
}
|
|
return n2;
|
|
}
|
|
|
|
public final boolean isNull() {
|
|
return this.equals(NULL);
|
|
}
|
|
|
|
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 BDimension() {
|
|
}
|
|
|
|
static {
|
|
NULL = DEFAULT = BDimension.make(0, 0, 0, 0, 0, 0, 0);
|
|
Class clazz = class$javax$baja$units$BDimension;
|
|
if (clazz == null) {
|
|
clazz = class$javax$baja$units$BDimension = BDimension.class("[Ljavax.baja.units.BDimension;", false);
|
|
}
|
|
TYPE = Sys.loadType(clazz);
|
|
}
|
|
}
|
|
|