Java Reference
In-Depth Information
* Depending on the string passed in creates the appropriate type, among:
* <code>VersionId</code><br>
* <code>StarVersion</code><br>
* <code>PlusVersion</code><br>
* <code>VersionString</code><br>
public static Versionable createVersionable(String vers) {
if (vers==null)
return new UnspecifiedVersion();
if (vers.indexOf(' ')!=-1)
return new VersionString(vers);
if (vers.indexOf('+')!=-1)
return new PlusVersion(vers);
if (vers.indexOf('*')!=-1)
return new StarVersion(vers);
if ((VersionId.isNumber(vers)) || (vers.indexOf(VersionId.DOT_CHAR)!=-1))
return new VersionId(vers);
return new UnspecifiedVersion();//in all other cases
* Factory method for VersionId types
public static VersionId createVersionId(String vers) {
if (vers==null)
return new UnspecifiedVersion();
Versionable v = createVersionable(vers);
if (v instanceof VersionId)
return (VersionId)v;
return new UnspecifiedVersion();
* exact match
public abstract boolean match(Versionable v);
Listing 12.4 shows the VersionId class that represents exact version labels for resources. Note
that such versions can be sorted using the Comparable interface. In this way, the cache of a
Search WWH ::

Custom Search