|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.kernel.util.AbstractSettableAttribute
ptolemy.kernel.util.StringAttribute
ptolemy.kernel.attributes.VersionAttribute
public class VersionAttribute
A nonpersistent attribute that identifies the version of an object. This attribute does not export MoML The value of the attribute contains a String version-id that represents the version. A version-id is a string with substrings separated by one of '.', '-' or '_'. The substrings may consist of any characters except space. Version-ids can be compared against each other other with the compareTo() method.
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
,
Serialized Form
Red (cxh) |
Red (cxh) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Nested classes/interfaces inherited from interface ptolemy.kernel.util.Settable |
---|
Settable.Visibility |
Field Summary | |
---|---|
private java.util.List |
_tupleList
|
static VersionAttribute |
CURRENT_VERSION
The VersionAttribute that contains the version of the Ptolemy II release that is currently running. |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Fields inherited from interface ptolemy.kernel.util.Settable |
---|
EXPERT, FULL, NONE, NOT_EDITABLE |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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(). |
Methods inherited from class ptolemy.kernel.util.StringAttribute |
---|
_propagateValue, addValueListener, exportMoML, getExpression, getVisibility, removeValueListener, setVisibility, validate |
Methods inherited from class ptolemy.kernel.util.AbstractSettableAttribute |
---|
getDefaultExpression, getValueAsString |
Methods inherited from class ptolemy.kernel.util.Attribute |
---|
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.kernel.util.Settable |
---|
getDisplayName |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getFullName, getName, getName, setName |
Field Detail |
---|
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. }
private java.util.List _tupleList
Constructor Detail |
---|
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.Method Detail |
---|
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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |