public class VersionAttribute extends StringAttribute implements java.lang.Comparable
The JNLP specification at
http://jcp.org/jsr/detail/056.jsp
gives the following syntax for version-ids:
version-id ::= string ( separator string ) * string ::= char ( char ) * char ::= Any ASCII character except a space, a separator or a modifier separator ::= "." | "-" | "_"
Valid version-id include "1.3", "1.3.1", "1.3-beta_01".
The JNLP specification includes version-strings, which are used for matching one or more version-ids in a fashion similar to wildcard matches within a regular expression. At this time, this class does not implement version-strings.
SingletonConfigurableAttribute
Red (cxh) |
Red (cxh) |
NamedObj.ContainedObjectsIterator
Settable.Visibility
Modifier and Type | Field and Description |
---|---|
static VersionAttribute |
CURRENT_VERSION
The VersionAttribute that contains the version of the Ptolemy II
release that is currently running.
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
EXPERT, FULL, NONE, NOT_EDITABLE
Constructor and Description |
---|
VersionAttribute(NamedObj container,
java.lang.String name)
Construct an attribute with the given name contained by the
specified container.
|
VersionAttribute(java.lang.String expression)
Construct an object in the default workspace with the empty string
as its name.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone(Workspace workspace)
Clone the attribute into the specified workspace.
|
int |
compareTo(java.lang.Object object)
Compare the value of this VersionAttribute against the argument
according to the VersionAttribute syntax and padding rules.
|
boolean |
equals(java.lang.Object object)
Return true if the specified object is an instance of
VersionAttribute and represents the same version as this one.
|
int |
hashCode()
Return a hash code value for attribute.
|
boolean |
isLessThan(VersionAttribute version)
Return true if this version is less than the specified version.
|
java.util.Iterator |
iterator()
Return an iterator over the elements of the version,
each of which is a String.
|
static java.lang.String |
majorCurrentVersion()
Return the major version, which consists of the first two
tuples.
|
void |
setExpression(java.lang.String expression)
Set the value of the string attribute and notify the container
of the value of this attribute by calling attributeChanged().
|
_propagateValue, addValueListener, exportMoML, getExpression, getVisibility, removeValueListener, setVisibility, validate
getDefaultExpression, getValueAsString
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
finalize, getClass, notify, notifyAll, wait, wait, wait
getDisplayName
description, getContainer, getFullName, getName, getName, setName
public static final VersionAttribute CURRENT_VERSION
VersionAttribute assumedVersion = ...; if (VersionAttribute.CURRENT_VERSION.isLessThan(assumedVersion)) { throw new IllegalActionException("You need to upgrade!"); }
Similarly, this variable may be used to change the Ptolemy II functionality depending on the version number:
if (VersionAttribute.CURRENT_VERSION.compareTo( new VersionAttribute("2.0")) ≥ 0 ) { // Perform some operation if the current version is // Ptolemy II 2.0 or later. }
public VersionAttribute(java.lang.String expression) throws IllegalActionException
expression
- The initial value of this parameter, set
using setExpression().IllegalActionException
- If the value is of the
incorrect format.setExpression(String)
public VersionAttribute(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this attribute.IllegalActionException
- If the attribute is not of an
acceptable class for the container, or if the name contains a period.NameDuplicationException
- If the name coincides with
an attribute already in the container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class StringAttribute
workspace
- The workspace for the new attributejava.lang.CloneNotSupportedException
- If a derived class contains
an attribute that cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public int compareTo(java.lang.Object object)
"1.2.2-005" is greater than "1.2.2.4",
"1.3.1" is an greater than "1.3"
"1.3-beta" is an greater than "1.3-alpha"
Version-id contain one or more elements. When two version-id's
are compared, they are normalized by padding the shortest
version-id with additional elements containing "0".
During comparison, if both elements can be parsed as Java
int
s, then they are compared as integers. If the
elements cannot be parsed as integers, they are compared as Strings.
compareTo
in interface java.lang.Comparable
object
- The VersionAttribute to compare against.public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- The specified object that is compared against.public int hashCode()
hashCode
in class java.lang.Object
public boolean isLessThan(VersionAttribute version)
version
- The VersionAttribute that is compared against.compareTo(Object)
public java.util.Iterator iterator()
public static java.lang.String majorCurrentVersion()
public void setExpression(java.lang.String expression) throws IllegalActionException
setExpression
in interface Settable
setExpression
in class StringAttribute
expression
- The version string, consisting of
version ID tuples separated by '.', '-' or '_'. For example:
"1.2", "1.2_beta-4".IllegalActionException
- If the argument contains a
space, which violates the JNLP Version format specification.StringAttribute.getExpression()