/**
* @see org.apache.lenya.workflow.Workflowable#getVersions()
*/
public Version[] getVersions() {
try {
MetaData meta = this.document.getMetaData(METADATA_NAMESPACE);
if (this.versions == null || meta.getLastModified() > this.lastModified) {
String[] versionStrings = meta.getValues(METADATA_VERSION);
this.versions = new Version[versionStrings.length];
SortedMap number2version = new TreeMap();
for (int i = 0; i < versionStrings.length; i++) {
String string = versionStrings[i];
int spaceIndex = string.indexOf(" ");
String numberString = string.substring(0, spaceIndex);
int number = Integer.parseInt(numberString);
String versionString = string.substring(spaceIndex + 1);
Version version = decodeVersion(versionString);
number2version.put(new Integer(number), version);
}
int number = 0;
for (Iterator i = number2version.keySet().iterator(); i.hasNext(); ) {
Version version = (Version) number2version.get(i.next());
this.versions[number] = version;
number++;
}
this.lastModified = meta.getLastModified();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return this.versions;