[jbpm-commits] JBoss JBPM SVN: r3098 - projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Nov 26 05:46:03 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-11-26 05:46:02 -0500 (Wed, 26 Nov 2008)
New Revision: 3098
Modified:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Attachments.java
Log:
Add Key.valueOf(String)
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Attachments.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Attachments.java 2008-11-26 09:31:53 UTC (rev 3097)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Attachments.java 2008-11-26 10:46:02 UTC (rev 3098)
@@ -80,6 +80,25 @@
this.name = name;
}
+ public static Key valueOf(String key)
+ {
+ int index = key.indexOf(",");
+ if (key.startsWith("[") && key.endsWith("]") && index > 0)
+ {
+ String classPart = key.substring(1, index);
+ String namePart = key.substring(index + 1, key.length() - 1);
+ try
+ {
+ return new Key(Class.forName(classPart), namePart);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new IllegalArgumentException("Cannot find class: " + classPart);
+ }
+ }
+ return null;
+ }
+
/**
* Get the class part for this key
*
@@ -121,22 +140,16 @@
}
/**
- * Returns the String repesentation of this Key. <p/>
- * <pre>
- * "[" + clazz + "," + name + "]"
+ * Returns the String repesentation of this Key.
+ * <p/>
+ *
+ * <pre>
+ * "[" + clazz + "," + name + "]"
* </pre>
*/
public String toString()
{
- StringBuilder str = new StringBuilder("[");
- if (clazz != null)
- str.append(clazz.getName());
- if (clazz != null && name != null)
- str.append(",");
- if (name != null)
- str.append(name);
- str.append("]");
- return str.toString();
+ return "[" + clazz + "," + name + "]";
}
}
}
\ No newline at end of file
More information about the jbpm-commits
mailing list