port.send(0, new BooleanToken(((Boolean) ret)
.booleanValue()));
} else if (typ.equals("double")) {
port.send(0, new DoubleToken(((Double) ret).doubleValue()));
} else if (typ.equals("int")) {
port.send(0, new IntToken(((Integer) ret).intValue()));
} else if (typ.equals("char")) {
port.send(0,
new UnsignedByteToken(((Byte) ret).byteValue()));
} else {
System.out.println("The return type is not convertible "
+ "with Ptolemy II types.");
}
}
//if the argument is output
else if ((port != null)
&& port.isOutput()
&& (port.getName() != null)
&& (getArgumentReturn() != null)
&& !(port.getName().equals(this.getArgumentReturn()
.getName()))) {
String typ = "";
Field field = null;
try {
field = _class.getDeclaredField("_" + port.getName());
typ = field.getType().toString();
} catch (NoSuchFieldException ex) {
try {
field = _class.getDeclaredField("_"
+ port.getName().substring(0,
port.getName().length() - 3));
typ = field.getType().toString();
} catch (Throwable throwable) {
try {
throw new IllegalActionException(this, throwable,
"No '+" + port.getName() + "' field !");
} catch (Throwable throwable2) {
getDirector().stop();
}
}
}
if (field == null) {
throw new InternalErrorException("Field '" + port.getName()
+ "' in '" + _class + "' is null?");
} else {
if (typ.equals("boolean")) {
try {
port.send(0,
new BooleanToken(field.getBoolean(obj)));
} catch (IllegalAccessException ex) {
throw new IllegalActionException(this, ex, "Type '"
+ typ + "' is not castable");
}
} else if (typ.equals("double")) {
try {
port.send(0, new DoubleToken(field.getDouble(obj)));
} catch (IllegalAccessException ex) {
throw new IllegalActionException(this, ex, "Type '"
+ typ + "' is not castable");
}
} else if (typ.equals("int")) {
try {
port.send(0, new IntToken(field.getInt(obj)));
} catch (IllegalAccessException ex) {
throw new IllegalActionException(this, ex, "Type '"
+ typ + "' is not castable");
}
} else if (typ.equals("char")) {
try {
port.send(0, new UnsignedByteToken(field
.getChar(obj)));
} catch (IllegalAccessException ex) {
throw new IllegalActionException(this, ex, "Type '"
+ typ + "' is not castable");
}
} else if (typ.equals("class [I")) {
try {
if (field == null) {
throw new InternalErrorException(
"field == null?");
}
if (obj == null) {
throw new InternalErrorException("obj == null?");
}
if (field.get(obj) == null) {
throw new InternalErrorException(
"field.get(obj) == null? (field = "
+ field + " obj = " + obj);
}
Token[] toks = new Token[((int[]) field.get(obj)).length];
for (int j = 0; j < ((int[]) field.get(obj)).length; j++) {
toks[j] = new IntToken(
((int[]) field.get(obj))[j]);
}
port.send(0, new ArrayToken(BaseType.INT, toks));
} catch (IllegalAccessException ex) {