266 lines
9.3 KiB
Java
266 lines
9.3 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.tridium.sys.schema.Utils
|
|
* javax.baja.nre.util.TextUtil
|
|
* javax.baja.sys.BAction
|
|
* javax.baja.sys.BBoolean
|
|
* javax.baja.sys.BComplex
|
|
* javax.baja.sys.BComponent
|
|
* javax.baja.sys.BDouble
|
|
* javax.baja.sys.BFloat
|
|
* javax.baja.sys.BInteger
|
|
* javax.baja.sys.BLong
|
|
* javax.baja.sys.BString
|
|
* javax.baja.sys.BValue
|
|
* javax.baja.sys.BajaRuntimeException
|
|
* javax.baja.sys.Property
|
|
* javax.baja.sys.Sys
|
|
* javax.baja.sys.Type
|
|
* javax.baja.util.BTypeSpec
|
|
*/
|
|
package com.tridium.program;
|
|
|
|
import com.tridium.program.BProgram;
|
|
import com.tridium.program.ProgramBase;
|
|
import com.tridium.sys.schema.Utils;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import javax.baja.nre.util.TextUtil;
|
|
import javax.baja.sys.BAction;
|
|
import javax.baja.sys.BBoolean;
|
|
import javax.baja.sys.BComplex;
|
|
import javax.baja.sys.BComponent;
|
|
import javax.baja.sys.BDouble;
|
|
import javax.baja.sys.BFloat;
|
|
import javax.baja.sys.BInteger;
|
|
import javax.baja.sys.BLong;
|
|
import javax.baja.sys.BString;
|
|
import javax.baja.sys.BValue;
|
|
import javax.baja.sys.BajaRuntimeException;
|
|
import javax.baja.sys.Property;
|
|
import javax.baja.sys.Sys;
|
|
import javax.baja.sys.Type;
|
|
import javax.baja.util.BTypeSpec;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class BProgramAction
|
|
extends BAction {
|
|
public static final Property parameterTypeSpec = BProgramAction.newProperty((int)0, (BValue)BTypeSpec.NULL, null);
|
|
public static final Property returnTypeSpec = BProgramAction.newProperty((int)0, (BValue)BTypeSpec.NULL, null);
|
|
public static final Type TYPE;
|
|
static Object[] noArgs;
|
|
ProgramBase cachedImpl;
|
|
Method cachedMethod;
|
|
static /* synthetic */ Class class$com$tridium$program$BProgramAction;
|
|
|
|
public BTypeSpec getParameterTypeSpec() {
|
|
return (BTypeSpec)this.get(parameterTypeSpec);
|
|
}
|
|
|
|
public void setParameterTypeSpec(BTypeSpec bTypeSpec) {
|
|
this.set(parameterTypeSpec, (BValue)bTypeSpec, null);
|
|
}
|
|
|
|
public BTypeSpec getReturnTypeSpec() {
|
|
return (BTypeSpec)this.get(returnTypeSpec);
|
|
}
|
|
|
|
public void setReturnTypeSpec(BTypeSpec bTypeSpec) {
|
|
this.set(returnTypeSpec, (BValue)bTypeSpec, null);
|
|
}
|
|
|
|
public Type getType() {
|
|
return TYPE;
|
|
}
|
|
|
|
public final BProgram getProgram() {
|
|
return (BProgram)this.getParent();
|
|
}
|
|
|
|
public Type getParameterType() {
|
|
try {
|
|
BTypeSpec bTypeSpec = this.getParameterTypeSpec();
|
|
if (bTypeSpec.isNull()) {
|
|
return null;
|
|
}
|
|
return this.getParameterTypeSpec().getResolvedType();
|
|
}
|
|
catch (Exception exception) {
|
|
exception.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public BValue getParameterDefault() {
|
|
try {
|
|
BTypeSpec bTypeSpec = this.getParameterTypeSpec();
|
|
if (bTypeSpec.isNull()) {
|
|
return null;
|
|
}
|
|
return (BValue)this.getParameterTypeSpec().getResolvedType().getInstance();
|
|
}
|
|
catch (Throwable throwable) {
|
|
throwable.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public BValue invoke(BComponent bComponent, BValue bValue) {
|
|
block15: {
|
|
try {
|
|
BComplex bComplex = this.getParent();
|
|
if (!(bComplex instanceof BProgram)) break block15;
|
|
BProgram bProgram = (BProgram)bComplex;
|
|
ProgramBase programBase = bProgram.impl;
|
|
if (programBase == null) break block15;
|
|
if (programBase != this.cachedImpl) {
|
|
this.resolveCache(programBase);
|
|
}
|
|
if (this.cachedMethod == null) break block15;
|
|
if (this.cachedMethod.getParameterTypes().length == 1) {
|
|
Object[] objectArray;
|
|
try {
|
|
switch (Utils.getTypeAccess(this.cachedMethod.getParameterTypes()[0])) {
|
|
case 0: {
|
|
objectArray = new Object[]{new Boolean(((BBoolean)bValue).getBoolean())};
|
|
break;
|
|
}
|
|
case 2: {
|
|
objectArray = new Object[]{new Integer(((BInteger)bValue).getInt())};
|
|
break;
|
|
}
|
|
case 3: {
|
|
objectArray = new Object[]{new Long(((BLong)bValue).getLong())};
|
|
break;
|
|
}
|
|
case 4: {
|
|
objectArray = new Object[]{new Float(((BFloat)bValue).getFloat())};
|
|
break;
|
|
}
|
|
case 5: {
|
|
objectArray = new Object[]{new Double(((BDouble)bValue).getDouble())};
|
|
break;
|
|
}
|
|
case 6: {
|
|
objectArray = new Object[]{((BString)bValue).getString()};
|
|
break;
|
|
}
|
|
default: {
|
|
objectArray = new Object[]{bValue};
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (ClassCastException classCastException) {
|
|
throw new BajaRuntimeException("Value of type " + bValue.getType() + " not compatible with action parameter " + this.cachedMethod.getParameterTypes()[0]);
|
|
}
|
|
return (BValue)this.cachedMethod.invoke((Object)programBase, objectArray);
|
|
}
|
|
return (BValue)this.cachedMethod.invoke((Object)programBase, noArgs);
|
|
}
|
|
catch (InvocationTargetException invocationTargetException) {
|
|
invocationTargetException.getTargetException().printStackTrace();
|
|
}
|
|
catch (Throwable throwable) {
|
|
throwable.printStackTrace();
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public Type getReturnType() {
|
|
try {
|
|
BTypeSpec bTypeSpec = this.getReturnTypeSpec();
|
|
if (bTypeSpec.isNull()) {
|
|
return null;
|
|
}
|
|
return bTypeSpec.getResolvedType();
|
|
}
|
|
catch (Exception exception) {
|
|
exception.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
void updateParameter(ProgramBase programBase) {
|
|
Class<?> clazz = null;
|
|
Class<?> clazz2 = null;
|
|
this.resolveCache(programBase);
|
|
if (this.cachedMethod == null) {
|
|
this.setParameterTypeSpec(BTypeSpec.NULL);
|
|
this.setReturnTypeSpec(BTypeSpec.NULL);
|
|
} else {
|
|
Type type;
|
|
try {
|
|
type = this.cachedMethod.getParameterTypes();
|
|
if (((Class<?>[])type).length == 0) {
|
|
this.setParameterTypeSpec(BTypeSpec.NULL);
|
|
} else {
|
|
clazz = type[0];
|
|
Type type2 = Sys.getType(clazz);
|
|
this.setParameterTypeSpec(type2.getTypeSpec());
|
|
}
|
|
}
|
|
catch (Exception exception) {
|
|
System.out.println("ERROR: Invalid parameter class " + this.getName() + ' ' + clazz);
|
|
exception.printStackTrace();
|
|
}
|
|
try {
|
|
clazz2 = this.cachedMethod.getReturnType();
|
|
if (clazz2 == Void.TYPE || clazz2 == null) {
|
|
this.setReturnTypeSpec(BTypeSpec.NULL);
|
|
} else {
|
|
type = Sys.getType(clazz2);
|
|
this.setReturnTypeSpec(type.getTypeSpec());
|
|
}
|
|
}
|
|
catch (Exception exception) {
|
|
System.out.println("ERROR: Invalid return class " + this.getName() + ' ' + clazz2);
|
|
exception.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
private final void resolveCache(ProgramBase programBase) {
|
|
this.cachedImpl = programBase;
|
|
this.cachedMethod = null;
|
|
String string = "on" + TextUtil.capitalize((String)this.getName());
|
|
Method[] methodArray = programBase.getClass().getMethods();
|
|
int n = 0;
|
|
while (n < methodArray.length) {
|
|
if (methodArray[n].getName().equals(string)) {
|
|
this.cachedMethod = methodArray[n];
|
|
break;
|
|
}
|
|
++n;
|
|
}
|
|
}
|
|
|
|
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());
|
|
}
|
|
}
|
|
|
|
static {
|
|
Class clazz = class$com$tridium$program$BProgramAction;
|
|
if (clazz == null) {
|
|
clazz = class$com$tridium$program$BProgramAction = BProgramAction.class("[Lcom.tridium.program.BProgramAction;", false);
|
|
}
|
|
TYPE = Sys.loadType((Class)clazz);
|
|
noArgs = new Object[0];
|
|
}
|
|
}
|
|
|