ptolemy.data.unit
Class UnitCategory

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.data.unit.UnitCategory
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class UnitCategory
extends Attribute

A property that specifies the category of a base unit. For example, in the International System of Units, the base unit meter has the category length.

Since:
Ptolemy II 2.0
Version:
$Id: UnitCategory.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Xiaojun Liu
See Also:
BaseUnit, Serialized Form
Accepted Rating:
Red (liuxj)
Proposed Rating:
Red (liuxj)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
UnitCategory()
          Construct a unit category in the default workspace with an empty string as its name.
UnitCategory(NamedObj container, java.lang.String name)
          Construct a unit category property with the given name contained by the specified entity.
UnitCategory(Workspace workspace)
          Construct an attribute in the specified workspace with an empty string as a name.
 
Method Summary
 BaseUnit getBaseUnit()
          Return the base unit.
 void setContainer(NamedObj container)
          Set the container and register this object in to the system wide unit system by calling UnitUtilities.registerUnitCategory(String).
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnitCategory

public UnitCategory()
Construct a unit category in the default workspace with an empty string as its name. The object is added to the directory of the workspace. Increment the version number of the workspace.


UnitCategory

public UnitCategory(Workspace workspace)
Construct an attribute in the specified workspace with an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace. The object is added to the directory of the workspace. Increment the version number of the workspace.

Parameters:
workspace - The workspace that will list the attribute.

UnitCategory

public UnitCategory(NamedObj container,
                    java.lang.String name)
             throws IllegalActionException,
                    NameDuplicationException
Construct a unit category property with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.

This constructor adds the created object to the system wide UnitSystem by calling UnitUtilities.registerUnitCategory(String)

Parameters:
container - The container.
name - The name of this attribute.
Throws:
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

getBaseUnit

public BaseUnit getBaseUnit()
Return the base unit.

Returns:
The base unit.

setContainer

public void setContainer(NamedObj container)
                  throws IllegalActionException,
                         NameDuplicationException
Set the container and register this object in to the system wide unit system by calling UnitUtilities.registerUnitCategory(String).

Overrides:
setContainer in class Attribute
Parameters:
container - The container to attach this attribute to. The type of the container must be an instances of BaseUnit.
Throws:
IllegalActionException - If Attribute.setContainer() throws it.
NameDuplicationException - If Attribute.setContainer() throws it.
See Also:
Attribute.getContainer()