ptolemy.moml
Class Documentation

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.kernel.util.AbstractSettableAttribute
              extended by ptolemy.kernel.util.StringAttribute
                  extended by ptolemy.moml.Documentation
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable

public class Documentation
extends StringAttribute

An attribute that contains documentation for the container.

The name of a documentation object can often be meaningful. Many times the name can be used to specify important information about the type of documentation. Unfortunately, all documentation objects are currently treated the same.

Since:
Ptolemy II 0.4
Version:
$Id: Documentation.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Yellow (neuendor)
Proposed Rating:
Yellow (eal)

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
 
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
Documentation(NamedObj container, java.lang.String name)
          Construct an attribute with the specified container and name.
 
Method Summary
static java.lang.String consolidate(NamedObj object)
          Return as a single string all the documentation associated with the specified object.
 void exportMoML(java.io.Writer output, int depth, java.lang.String name)
          Write a MoML description of this object with the specified indentation depth.
 void setExpression(java.lang.String expression)
          Override the base class to remove this instance from its container if the argument is an empty string.
 void setValue(java.lang.String value)
          Set the documentation string.
 java.lang.String toString()
          Get the documentation as a string, with the class name prepended.
 
Methods inherited from class ptolemy.kernel.util.StringAttribute
_propagateValue, addValueListener, 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 ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, 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
 

Constructor Detail

Documentation

public Documentation(NamedObj container,
                     java.lang.String name)
              throws IllegalActionException,
                     NameDuplicationException
Construct an attribute with the specified container and name. The documentation contained by the attribute is initially empty, but can be set using the setValue() method.

Parameters:
container - The container.
name - The name of the attribute.
Throws:
IllegalActionException - If the attribute is not of an acceptable class for the container.
NameDuplicationException - If the name coincides with an attribute already in the container.
Method Detail

consolidate

public static java.lang.String consolidate(NamedObj object)
Return as a single string all the documentation associated with the specified object. Each attribute of type of class Documentation that the object contains contributes to the documentation. The text contributed by each such attribute starts on a new line. If there are no such attributes, then null is returned.

Parameters:
object - The object to document.
Returns:
The documentation for the object.

exportMoML

public void exportMoML(java.io.Writer output,
                       int depth,
                       java.lang.String name)
                throws java.io.IOException
Write a MoML description of this object with the specified indentation depth. This class is directly supported by the MoML "doc" element, so we generate MoML of the form "<doc>documentation</doc>", where documentation is replaced by the string value of this attribute. If this object is not persistent, then write nothing.

Specified by:
exportMoML in interface MoMLExportable
Overrides:
exportMoML in class StringAttribute
Parameters:
output - The output stream to write to.
depth - The depth in the hierarchy, to determine indenting.
name - The name to use instead of the current name.
Throws:
java.io.IOException - If an I/O error occurs.
See Also:
NamedObj._exportMoMLContents(java.io.Writer, int), NamedObj.isPersistent()

setExpression

public void setExpression(java.lang.String expression)
                   throws IllegalActionException
Override the base class to remove this instance from its container if the argument is an empty string. The removal is done in a change request, so it may not take effect immediately.

Specified by:
setExpression in interface Settable
Overrides:
setExpression in class StringAttribute
Parameters:
expression - The value of the string attribute.
Throws:
IllegalActionException - If the change is not acceptable to the container.
See Also:
StringAttribute.getExpression()

setValue

public void setValue(java.lang.String value)
Set the documentation string.

Parameters:
value - The documentation.
See Also:
AbstractSettableAttribute.getValueAsString()

toString

public java.lang.String toString()
Get the documentation as a string, with the class name prepended.

Overrides:
toString in class NamedObj
Returns:
A string describing the object.