home *** CD-ROM | disk | FTP | other *** search
- import java.io.FileNotFoundException;
- import java.io.PrintStream;
- import stardiv.classfile.ClassFormatException;
- import stardiv.security.JScript2JavaInterface;
-
- public class JSbxValue extends JSbxBase implements Cloneable {
- public static final short JSBX_TYPE_EMPTY = 1;
- public static final short JSBX_TYPE_OBJECT = 2;
- public static final short JSBX_TYPE_STRING = 4;
- public static final short JSBX_TYPE_BOOL = 8;
- public static final short JSBX_TYPE_DOUBLE = 16;
- public static final short JSBX_TYPE_FUNCTION = 32;
- private short nJSbxType;
- private JSbxBase aJSbxObject;
- private String aJSbxString;
- private boolean bJSbxBool;
- private double dJSbxDouble;
-
- public JSbxValue() {
- this.SetType((short)1);
- }
-
- public JSbxValue(JSbxBase var1) {
- this.SetType((short)2);
- this.ImpSetObject(var1);
- }
-
- public JSbxValue(String var1) {
- this.SetType((short)4);
- this.ImpSetString(var1);
- }
-
- public JSbxValue(boolean var1) {
- this.SetType((short)8);
- this.ImpSetBool(var1);
- }
-
- public JSbxValue(double var1) {
- this.SetType((short)16);
- this.ImpSetDouble(var1);
- }
-
- public JSbxValue(JSbxValue var1) {
- this.CopyData(var1);
- }
-
- public JSbxValue(short var1) {
- this.SetType(var1);
- }
-
- private final JSbxBase ImpGetObject() {
- return this.aJSbxObject;
- }
-
- private final String ImpGetString() {
- return this.aJSbxString;
- }
-
- private final boolean ImpGetBool() {
- return this.bJSbxBool;
- }
-
- private final double ImpGetDouble() {
- return this.dJSbxDouble;
- }
-
- private final void ImpSetObject(JSbxBase var1) {
- this.aJSbxObject = var1;
- }
-
- private final void ImpSetString(String var1) {
- this.aJSbxString = var1;
- }
-
- private final void ImpSetBool(boolean var1) {
- this.bJSbxBool = var1;
- }
-
- private final void ImpSetDouble(double var1) {
- this.dJSbxDouble = var1;
- }
-
- public final void CopyData(JSbxValue var1) {
- this.SetType(var1.GetType());
- this.ImpSetObject(var1.ImpGetObject());
- this.ImpSetString(var1.ImpGetString());
- this.ImpSetBool(var1.ImpGetBool());
- this.ImpSetDouble(var1.ImpGetDouble());
- }
-
- public Object clone() {
- return new JSbxValue(this);
- }
-
- public final void Clear() {
- this.ImpSetObject((JSbxBase)null);
- this.ImpSetString("");
- this.ImpSetBool(false);
- this.ImpSetDouble((double)0.0F);
- }
-
- private final void SetType(short var1) {
- this.nJSbxType = var1;
- }
-
- public final short GetType() {
- return this.nJSbxType;
- }
-
- public final JSbxBase GetObject() throws JSbxException {
- JSbxValue var1 = this;
- if (this.GetType() != 2) {
- this.Get(var1 = new JSbxValue((short)2));
- }
-
- return var1.ImpGetObject();
- }
-
- public final String GetString() throws JSbxException {
- JSbxValue var1 = this;
- if (this.GetType() != 4) {
- this.Get(var1 = new JSbxValue((short)4));
- }
-
- return var1.ImpGetString();
- }
-
- public final boolean GetBool() throws JSbxException {
- JSbxValue var1 = this;
- if (this.GetType() != 8) {
- this.Get(var1 = new JSbxValue((short)8));
- }
-
- return var1.ImpGetBool();
- }
-
- public final double GetDouble() throws JSbxException {
- JSbxValue var1 = this;
- if (this.GetType() != 16) {
- this.Get(var1 = new JSbxValue((short)16));
- }
-
- return var1.ImpGetDouble();
- }
-
- public final void Get(JSbxValue var1) throws JSbxException {
- ImpConvert(this, var1);
- }
-
- public final void Put(JSbxValue var1) throws JSbxException {
- this.CopyData(var1);
- }
-
- static final void ImpConvert(JSbxValue var0, JSbxValue var1) throws JSbxException {
- short var2 = var0.GetType();
- short var3 = var1.GetType();
- if (var2 != var3 && var3 != 1) {
- switch (var3) {
- case 2:
- switch (var2) {
- case 1:
- var1.ImpSetObject((JSbxBase)null);
- case 4:
- var1.ImpSetObject(JScriptManager.CreateClassObject("String"));
- return;
- case 8:
- var1.ImpSetObject(JScriptManager.CreateClassObject("Boolean"));
- return;
- case 16:
- var1.ImpSetObject(JScriptManager.CreateClassObject("Number"));
- return;
- default:
- return;
- }
- case 4:
- switch (var2) {
- case 1:
- var1.ImpSetString("undefined");
- return;
- case 2:
- JSbxBase var11 = var0.GetObject();
- JSbxObject var14 = null;
- if (var11 instanceof JSbxObject) {
- var14 = (JSbxObject)var11;
- }
-
- if (var14 == null) {
- var1.ImpSetString("null");
- return;
- }
-
- var1.ImpSetString(var14.JS_toString());
- return;
- case 8:
- if (var0.ImpGetBool()) {
- var1.ImpSetString("true");
- return;
- }
-
- var1.ImpSetString("false");
- return;
- case 16:
- double var15 = var0.ImpGetDouble();
- if (Double.isInfinite(var15)) {
- var1.ImpSetString((var15 == Double.NEGATIVE_INFINITY ? "-" : "+") + "Infinity");
- return;
- }
-
- if (Double.isNaN(var15)) {
- var1.ImpSetString("NaN");
- return;
- }
-
- var1.ImpSetString(ConvertNumber(var15));
- return;
- default:
- return;
- }
- case 8:
- switch (var2) {
- case 1:
- var1.ImpSetBool(false);
- return;
- case 2:
- JSbxBase var13 = var0.GetObject();
- JSbxObject var6 = null;
- if (var13 instanceof JSbxObject) {
- var6 = (JSbxObject)var13;
- }
-
- if (var6 == null) {
- var1.ImpSetBool(false);
- return;
- }
-
- JSbxValue var7 = var6.JS_valueOf();
- if (var7 != null) {
- var1.ImpSetBool(var7.GetBool());
- return;
- }
-
- var1.ImpSetBool(true);
- return;
- case 4:
- boolean var10 = var0.ImpGetString().length() > 0;
- var1.ImpSetBool(var10);
- return;
- case 16:
- double var12 = var0.ImpGetDouble();
- if (var12 == Double.NaN) {
- var1.ImpSetBool(false);
- }
-
- var1.ImpSetBool(var0.ImpGetDouble() != (double)0.0F);
- return;
- default:
- return;
- }
- case 16:
- switch (var2) {
- case 1:
- throw new JSbxException(4712, "Conversion: can't convert empty to number");
- case 2:
- JSbxBase var9 = var0.GetObject();
- if (var9 == null) {
- var1.ImpSetDouble((double)0.0F);
- return;
- }
-
- if (var9 instanceof JSbxObject) {
- JSbxValue var5 = ((JSbxObject)var9).JS_valueOf();
- if (var5.GetType() == 16) {
- var1.ImpSetDouble(var5.GetDouble());
- return;
- }
-
- throw new JSbxException(4715, var0.ImpGetObject() + " is not a number");
- }
-
- throw new JSbxException(4715, var0.ImpGetObject() + " is not a number");
- case 4:
- try {
- Double var4 = new Double(var0.ImpGetString());
- var1.ImpSetDouble(var4);
- return;
- } catch (NumberFormatException var8) {
- throw new JSbxException(4714, var0.ImpGetString() + " is not a number");
- }
- case 8:
- var1.ImpSetDouble(var0.ImpGetBool() ? (double)1.0F : (double)0.0F);
- return;
- }
- }
-
- } else {
- var1.CopyData(var0);
- }
- }
-
- public final JSbxValue CallFunction(JScriptCallParam var1) throws JSbxExceptionBase {
- if (this.GetType() == 2) {
- JSbxBase var2 = this.ImpGetObject();
- if (var2 instanceof JSbxMethod) {
- return ((JSbxMethod)var2).CallFunction(var1);
- }
- }
-
- throw new JSbxException(888, this.GetErrorValueInfo() + " cannot be converted to a function.");
- }
-
- public String GetJScript_typeofString() {
- return this.GetTypeString();
- }
-
- public static Object convertJScript2Java(JSbxValue var0) {
- Object var1 = null;
- if (var0 != null) {
- switch (var0.GetType()) {
- case 2:
- var1 = var0.ImpGetObject();
- ((JSbxObject)var1).setLifeConnectManager(JScriptManager.GetMyJScriptManager());
- break;
- case 4:
- var1 = var0.ImpGetString();
- break;
- case 8:
- var1 = new Boolean(var0.ImpGetBool());
- break;
- case 16:
- var1 = new Double(var0.ImpGetDouble());
- }
- }
-
- return var1;
- }
-
- public static JSbxValue convertJava2JScript(Object var0, boolean var1, JScript2JavaInterface var2) throws FileNotFoundException, ClassFormatException, ClassNotFoundException {
- JSbxValue var3 = null;
- if (var0 == null) {
- if (!var1) {
- var3 = new JSbxValue((JSbxBase)null);
- }
- } else if (var1 && var0 instanceof Number) {
- var3 = new JSbxValue(((Number)var0).doubleValue());
- } else if (var1 && var0 instanceof Boolean) {
- var3 = new JSbxValue((Boolean)var0);
- } else if (var0 instanceof JSbxObject) {
- var3 = new JSbxValue((JSbxObject)var0);
- } else {
- JScriptJavaObject var4 = new JScriptJavaObject(var0, var2);
- var3 = new JSbxValue(var4);
- }
-
- if (var3 == null) {
- var3 = new JSbxValue();
- }
-
- return var3;
- }
-
- public static Object convertJScript2JSObject(JSbxValue var0) {
- Object var1 = convertJScript2Java(var0);
- if (var1 instanceof JScriptJavaObject) {
- var1 = ((JScriptJavaObject)var1).getJavaObject();
- }
-
- return var1;
- }
-
- public static JSbxValue convertJSObject2JScript(Object var0) throws FileNotFoundException, ClassFormatException, ClassNotFoundException {
- return convertJSObject2JScript(var0, (JScriptManager)null);
- }
-
- public static JSbxValue convertJSObject2JScript(Object var0, JScriptManager var1) throws FileNotFoundException, ClassFormatException, ClassNotFoundException {
- JSbxValue var2 = null;
- if (var0 == null) {
- var2 = new JSbxValue((JSbxBase)null);
- } else if (var0 instanceof JSbxObject) {
- var2 = new JSbxValue((JSbxObject)var0);
- } else if (var0 instanceof Object[]) {
- JScript2JavaInterface var3 = getSecureJScriptCalling(var1);
- if (var3 != null) {
- JScriptJavaObject var4 = new JScriptJavaObject(var0, var3, true);
- var2 = new JSbxValue(var4);
- }
- } else if (var0 instanceof Boolean) {
- var2 = new JSbxValue((Boolean)var0);
- }
-
- if (var0 instanceof Number) {
- var2 = new JSbxValue(((Number)var0).doubleValue());
- } else {
- JScript2JavaInterface var5 = getSecureJScriptCalling(var1);
- if (var5 != null) {
- JScriptJavaObject var6 = new JScriptJavaObject(var0, var5);
- var2 = new JSbxValue(var6);
- }
- }
-
- if (var2 == null) {
- var2 = new JSbxValue();
- }
-
- return var2;
- }
-
- private static JScript2JavaInterface getSecureJScriptCalling(JScriptManager var0) {
- if (var0 == null) {
- var0 = JScriptManager.GetMyJScriptManager();
- }
-
- JScript2JavaInterface var1 = null;
- if (var0 != null) {
- var1 = var0.getSecureJScriptCalling();
- }
-
- return var1;
- }
-
- private final String GetObjectValueString() {
- String var1 = "unknown";
- JSbxBase var2 = this.ImpGetObject();
- if (var2 == null) {
- var1 = "null";
- } else if (var2 instanceof JScriptMethod) {
- JScriptMethod var3 = (JScriptMethod)var2;
- var1 = "Function \"" + var3.GetName() + "\"";
- } else if (var2 instanceof JSbxMethod) {
- var1 = "JSbxMethod";
- } else if (var2 instanceof JSbxObject) {
- var1 = ((JSbxObject)var2).JS_toString();
- } else {
- var1 = "Valid";
- }
-
- return var1;
- }
-
- private final String GetTypeString() {
- String var1 = "unknown";
- switch (this.GetType()) {
- case 1:
- var1 = "undefined";
- break;
- case 2:
- var1 = "object";
-
- try {
- JSbxBase var2 = this.GetObject();
- if (var2 instanceof JSbxObject) {
- JSbxObject var3 = (JSbxObject)var2;
- if (var3 != null) {
- var1 = var3.GetJScript_typeofString();
- } else {
- var1 = "object";
- }
- } else {
- System.out.println("WARNING: bad object-type " + var2);
- }
- } catch (JSbxException var4) {
- }
- break;
- case 4:
- var1 = "string";
- break;
- case 8:
- var1 = "boolean";
- break;
- case 16:
- var1 = "number";
- }
-
- return var1;
- }
-
- private final String GetValueString() {
- String var1 = "unknown";
-
- try {
- switch (this.GetType()) {
- case 1:
- var1 = "empty";
- break;
- case 2:
- var1 = this.GetObjectValueString();
- break;
- case 4:
- var1 = "\"" + this.GetString() + "\"";
- break;
- case 8:
- var1 = String.valueOf(this.GetBool());
- break;
- case 16:
- var1 = String.valueOf(this.GetDouble());
- }
- } catch (JSbxException var2) {
- }
-
- return var1;
- }
-
- public void Dump(PrintStream var1, int var2, int var3) throws JSbxException {
- JSbxValue var4 = new JSbxValue("");
- String var5 = this.GetTypeString();
- var1.print(var5);
- if (this.GetType() == 2) {
- JSbxBase var6 = this.ImpGetObject();
- var1.println(": " + this.GetObjectValueString());
- if (var6 != null) {
- if (var2 < var3 || var3 == -1) {
- this.ImpGetObject().Dump(var1, var2, var3);
- }
-
- return;
- }
- } else {
- if (this.GetType() != 1) {
- this.Get(var4);
- var1.print(": ");
- if (this.GetType() == 4) {
- var1.println("\"" + var4.ImpGetString() + "\"");
- return;
- }
-
- var1.println(var4.ImpGetString());
- return;
- }
-
- var1.println();
- }
-
- }
-
- public final String GetBrowserTypeInfo() {
- return this.GetTypeString();
- }
-
- public final String GetBrowserValueInfo() {
- return this.GetValueString();
- }
-
- public final String GetBrowserInfo() {
- return new String(this.GetBrowserTypeInfo() + " " + this.GetBrowserValueInfo());
- }
-
- public final String GetErrorValueInfo() {
- return this.GetValueString();
- }
-
- public static final String ConvertNumber(double var0) {
- long var2 = Double.doubleToLongBits(var0);
- int var4 = (int)(var2 >> 52 & 2047L);
- long var5 = var4 == 0 ? (var2 & 4503599627370495L) << 1 : var2 & 4503599627370495L | 4503599627370496L;
- int var7 = var4 - 1075;
- long var8 = 0L;
- if (var7 > 0) {
- var8 = var5 << var7;
- } else {
- var8 = var5 >> -var7;
- }
-
- boolean var10 = Math.abs(var0) != (double)var8;
- return var10 ? String.valueOf(var0) : String.valueOf((long)var0);
- }
- }
-