177 lines
5.9 KiB
Java
177 lines
5.9 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package javax.baja.sys;
|
|
|
|
import javax.baja.naming.BOrd;
|
|
import javax.baja.sys.Action;
|
|
import javax.baja.sys.BBoolean;
|
|
import javax.baja.sys.BComponent;
|
|
import javax.baja.sys.BDouble;
|
|
import javax.baja.sys.BFacets;
|
|
import javax.baja.sys.BFloat;
|
|
import javax.baja.sys.BInteger;
|
|
import javax.baja.sys.BLink;
|
|
import javax.baja.sys.BLong;
|
|
import javax.baja.sys.BString;
|
|
import javax.baja.sys.BValue;
|
|
import javax.baja.sys.Property;
|
|
import javax.baja.sys.Slot;
|
|
import javax.baja.sys.Sys;
|
|
import javax.baja.sys.Type;
|
|
import javax.baja.util.BConverter;
|
|
import javax.baja.util.BNullConverter;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class BConversionLink
|
|
extends BLink {
|
|
public static final Property converter = BConversionLink.newProperty(0, new BNullConverter(), BFacets.NULL);
|
|
public static final Type TYPE;
|
|
static /* synthetic */ Class class$javax$baja$sys$BConversionLink;
|
|
|
|
public final BConverter getConverter() {
|
|
return (BConverter)this.get(converter);
|
|
}
|
|
|
|
public final void setConverter(BConverter bConverter) {
|
|
this.set(converter, (BValue)bConverter, null);
|
|
}
|
|
|
|
public Type getType() {
|
|
return TYPE;
|
|
}
|
|
|
|
public void propagate(BValue bValue) {
|
|
if (this.getTargetComponent() == this.getSourceComponent() && this.getTargetSlot() == this.getSourceSlot()) {
|
|
System.out.println("WARNING: Infinite link: " + this);
|
|
return;
|
|
}
|
|
Slot slot = this.getSourceSlot();
|
|
Slot slot2 = this.getTargetSlot();
|
|
if (slot.isAction()) {
|
|
if (slot2.asAction().getParameterType() != null) {
|
|
bValue = (BValue)this.getConverter().convert(bValue, slot2.asAction().getParameterDefault());
|
|
}
|
|
if (slot2.isAction()) {
|
|
this.propagateActionToAction(bValue);
|
|
return;
|
|
}
|
|
if (slot2.isTopic()) {
|
|
this.propagateActionToTopic(bValue);
|
|
return;
|
|
}
|
|
} else if (slot.isTopic()) {
|
|
if (slot2.isAction()) {
|
|
this.propagateTopicToAction(bValue);
|
|
return;
|
|
}
|
|
if (slot2.isTopic()) {
|
|
this.propagateTopicToTopic(bValue);
|
|
return;
|
|
}
|
|
} else if (slot.isProperty()) {
|
|
if (slot2.isAction()) {
|
|
this.propagatePropertyToAction();
|
|
return;
|
|
}
|
|
if (slot2.isProperty()) {
|
|
this.propagatePropertyToProperty();
|
|
return;
|
|
}
|
|
}
|
|
throw new IllegalStateException("Invalid link config");
|
|
}
|
|
|
|
public void propagatePropertyToAction() {
|
|
Slot slot = this.getTargetSlot();
|
|
Action action = slot.asAction();
|
|
BValue bValue = null;
|
|
if (action.getParameterType() != null) {
|
|
bValue = (BValue)this.getConverter().convert(this.getSourceComponent().get(this.getSourceSlot().asProperty()), slot.asAction().getParameterDefault());
|
|
}
|
|
this.getTargetComponent().invoke(action, bValue);
|
|
}
|
|
|
|
public void propagatePropertyToProperty() {
|
|
BComponent bComponent = this.getTargetComponent();
|
|
BComponent bComponent2 = this.getSourceComponent();
|
|
Property property = this.getSourceSlot().asProperty();
|
|
Property property2 = this.getTargetSlot().asProperty();
|
|
BValue bValue = (BValue)this.getConverter().convert(bComponent2.get(property), bComponent.get(property2));
|
|
switch (property2.getTypeAccess()) {
|
|
case 0: {
|
|
bComponent.setBoolean(property2, ((BBoolean)bValue).getBoolean(), null);
|
|
break;
|
|
}
|
|
case 2: {
|
|
bComponent.setInt(property2, ((BInteger)bValue).getInt(), null);
|
|
break;
|
|
}
|
|
case 3: {
|
|
bComponent.setLong(property2, ((BLong)bValue).getLong(), null);
|
|
break;
|
|
}
|
|
case 4: {
|
|
bComponent.setFloat(property2, ((BFloat)bValue).getFloat(), null);
|
|
break;
|
|
}
|
|
case 5: {
|
|
bComponent.setDouble(property2, ((BDouble)bValue).getDouble(), null);
|
|
break;
|
|
}
|
|
case 6: {
|
|
bComponent.setString(property2, ((BString)bValue).getString(), null);
|
|
break;
|
|
}
|
|
case 7: {
|
|
if (bValue.isSimple()) {
|
|
bComponent.set(property2, bValue, null);
|
|
break;
|
|
}
|
|
bComponent.get(property2).asComplex().copyFrom(bValue.asComplex());
|
|
break;
|
|
}
|
|
default: {
|
|
throw new IllegalStateException("Unexpected link source type: " + property.getType() + " (" + property.getTypeAccess() + ')');
|
|
}
|
|
}
|
|
}
|
|
|
|
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());
|
|
}
|
|
}
|
|
|
|
public BConversionLink() {
|
|
}
|
|
|
|
public BConversionLink(BOrd bOrd, String string, String string2, boolean bl, BConverter bConverter) {
|
|
super(bOrd, string, string2, bl);
|
|
this.setConverter(bConverter);
|
|
}
|
|
|
|
public BConversionLink(BComponent bComponent, Slot slot, Slot slot2, BConverter bConverter) {
|
|
super(bComponent, slot, slot2);
|
|
this.setConverter(bConverter);
|
|
}
|
|
|
|
static {
|
|
Class clazz = class$javax$baja$sys$BConversionLink;
|
|
if (clazz == null) {
|
|
clazz = class$javax$baja$sys$BConversionLink = BConversionLink.class("[Ljavax.baja.sys.BConversionLink;", false);
|
|
}
|
|
TYPE = Sys.loadType(clazz);
|
|
}
|
|
}
|
|
|