/**
* @throws NullPointerException if text is null.
*/
public static Node createNode(String text) {
Node node = null;
String typeName = null;
String name = null;
text = text.trim();
int spaceIndex = text.indexOf(' ');
if (spaceIndex!=-1) {
typeName = text.substring(0, spaceIndex);
name = text.substring(spaceIndex + 1);
} else {
typeName = text;
name = null;
}
Class nodeType = NodeTypes.getNodeType(typeName);
if ( nodeType==null ) throw new IllegalArgumentException("unknown node type name '" + typeName + "'");
try {
node = (Node) nodeType.newInstance();
node.setName(name);
} catch (Exception e) {
throw new JbpmException("couldn't instantiate nodehandler for type '" + typeName + "'");
}
return node;
}