if (modelString.getWidth() < 1) {
throw new IllegalActionException(getName() + "need to have"
+ "the modelString port be connected");
} else if (modelString.hasToken(0)) {
StringToken str = null;
try {
str = (StringToken) modelString.get(0);
_parser.reset();
CompositeActor model = (CompositeActor) _parser.parse(str
.stringValue());
StringWriter writer = new StringWriter();
try {
model.exportMoML(writer, 1);
} catch (Exception ex) {
// FIXME: don't ignore?
}
String modelMoML = writer.toString();
if (((BooleanToken) connectPorts.getToken()).booleanValue()) {
_moml = "<group>\n" + modelMoML
+ "<relation name=\"newR1\" "
+ "class=\"ptolemy.actor.TypedIORelation\">\n"
+ "</relation>\n" + "<relation name=\"newR2\" "
+ "class=\"ptolemy.actor.TypedIORelation\">\n"
+ "</relation>\n"
+ "<link port=\"input\" relation=\"newR1\"/>\n"
+ "<link port=\"" + model.getName()
+ ".input\" relation=\"newR1\"/>\n"
+ "<link port=\"" + model.getName()
+ ".output\" relation=\"newR2\"/>\n"
+ "<link port=\"output\" relation=\"newR2\"/>\n"
+ "</group>";
} else {
_moml = "<group>\n" + modelMoML + "</group>";
}
} catch (Exception ex) {
if (_debugging) {
_debug("Problem parsing " + str.stringValue());
}
throw new IllegalActionException(this, ex, "Problem parsing "
+ str.stringValue());
}
}
super.fire();
}