jni
Class Argument

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

public class Argument
extends AbstractSettableAttribute

A native method argument associated with a GenericJNIActor.

Since:
Ptolemy II 2.2
Version:
$Id: Argument.java,v 1.60 2007/12/07 06:32:11 cxh Exp $
Author:
V.Arnould, Thales, Contributor: Christopher Brooks
See Also:
GenericJNIActor, Serialized Form
Accepted Rating:
Red (vincent.arnould)
Proposed Rating:
Red (vincent.arnould)

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
Argument()
          Construct an attribute in the default workspace with an empty string as its name.
Argument(GenericJNIActor container, java.lang.String name)
          Creates a new instance of Argument with the given name for the given GenericJNIActor.
 
Method Summary
protected  void _checkContainer(NamedObj container)
          Check that the specified container is of a suitable class for this entity.
protected  void _propagateValue(NamedObj destination)
          Propagate the value of this object to the specified object.
 void addValueListener(ValueListener listener)
          Add a listener to be notified when the value of this settable object changes.
 void checkType()
          Check that the specified type is a suitable type for this entity.
 void exportMoML(java.io.Writer output, int depth, java.lang.String name)
          Export the Argument in a property MoML.
 java.lang.String getC2Type()
          Get the C type of the argument as a pointer if it is an array.
 java.lang.String getC2TypeHack()
          Get the C2 Type Array, but if we are under SunOS, and getC2Type returns long, then return int *.
 NamedObj getContainer()
          Get the container entity.
 java.lang.String getCType()
          Get the C type of the argument.
 java.lang.String getExpression()
          Get the expression of the argument.
 java.lang.String getJNIType()
          Get the JNI type of the argument.
 java.lang.String getJType()
          Get the Java type of the argument.
 java.lang.String getKind()
          Get the kind as a comma separated list.
 java.lang.String getType()
          Get the Java class corresponding to the Java Type.
 Settable.Visibility getVisibility()
          Get the visibility of this Settable.
 boolean isInput()
          Return true if it is an input.
 boolean isOutput()
          Return true if it an output.
 boolean isReturn()
          Return true if it is a return.
 void removeValueListener(ValueListener listener)
          Remove a listener to be notified when the value of this settable object changes.
 void setContainer(NamedObj container)
          Specify the container, adding the entity to the list of entities in the container.
 void setCType(java.lang.String cType)
          Set the C type of the argument with the given string.
 void setExpression()
          Set the expression of the argument from its attributes.
 void setExpression(java.lang.String expression)
          Set the expression of the argument.
 void setInput(boolean input)
          Set to true if the attribute is an input.
 void setKind(java.lang.String selectedValues)
          Set the kind of the argument with the given string.
 void setOutput(boolean output)
          Set to true if the attribute is an output.
 void setReturn(boolean returnFlag)
          Set to true if the attribute is a return.
 void setVisibility(Settable.Visibility visibility)
          Set the visibility of this attribute in the user interface.
 java.util.Collection validate()
          Notify the container that an attribute has changed.
 
Methods inherited from class ptolemy.kernel.util.AbstractSettableAttribute
getDefaultExpression, getValueAsString
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, clone, 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, _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, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, 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
 
Methods inherited from interface ptolemy.kernel.util.Settable
getDisplayName
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName, setName
 

Constructor Detail

Argument

public Argument()
Construct an attribute 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.


Argument

public Argument(GenericJNIActor container,
                java.lang.String name)
         throws IllegalActionException,
                NameDuplicationException
Creates a new instance of Argument with the given name for the given GenericJNIActor. 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.

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

addValueListener

public void addValueListener(ValueListener listener)
Add a listener to be notified when the value of this settable object changes. An implementation of this method should ignore the call if the specified listener is already on the list of listeners. In other words, it should not be possible for the same listener to be notified twice of a value update.

Parameters:
listener - The listener to add, which is ignored, no listener is added.
See Also:
removeValueListener(ValueListener)

checkType

public void checkType()
Check that the specified type is a suitable type for this entity.

Throws:
IllegalActionException - If the Argument has not an acceptable C type. Not thrown in this base class.

exportMoML

public void exportMoML(java.io.Writer output,
                       int depth,
                       java.lang.String name)
                throws java.io.IOException
Export the Argument in a property MoML. If this object is not persistent, then write nothing.

Specified by:
exportMoML in interface MoMLExportable
Overrides:
exportMoML in class NamedObj
Parameters:
output - The output stream to write to.
depth - The depth in the hierarchy, to determine indenting.
name - The name to use in the exported MoML.
Throws:
java.io.IOException - If an IO error occurs
See Also:
MoMLExportable, NamedObj.clone(Workspace), NamedObj.isPersistent(), NamedObj.getDerivedLevel()

getC2Type

public java.lang.String getC2Type()
Get the C type of the argument as a pointer if it is an array.

Returns:
the _cType attribute in pointer

getC2TypeHack

public java.lang.String getC2TypeHack()
Get the C2 Type Array, but if we are under SunOS, and getC2Type returns long, then return int *. On other platforms, just return the value of getC2Type(). FIXME: This platform dependent change is necessary under Solaris 8 for some reason.

Returns:
the _cType attribute in pointer

getCType

public java.lang.String getCType()
Get the C type of the argument.

Returns:
the _cType attribute
See Also:
setCType(String)

getContainer

public NamedObj getContainer()
Get the container entity.

Specified by:
getContainer in interface Nameable
Overrides:
getContainer in class Attribute
Returns:
The container, which is an instance of CompositeEntity.
See Also:
setContainer(NamedObj)

getExpression

public java.lang.String getExpression()
Get the expression of the argument. The format is "_isInput, _isOutput, _isReturn, _cType".

Returns:
the string containing the argument specifications
See Also:
setExpression(String)

getJNIType

public java.lang.String getJNIType()
Get the JNI type of the argument.

Returns:
the corresponding JNI type.

getJType

public java.lang.String getJType()
Get the Java type of the argument.

Returns:
the corresponding Java type

getKind

public java.lang.String getKind()
Get the kind as a comma separated list.

Returns:
"input", "output" "input, output" or "return"
See Also:
setKind(String)

getType

public java.lang.String getType()
Get the Java class corresponding to the Java Type.

Returns:
the corresponding Java class

getVisibility

public Settable.Visibility getVisibility()
Get the visibility of this Settable.

Returns:
Always return Settable.NONE, indicating that the user interface should not make an instance visible.
See Also:
Settable.setVisibility(Visibility)

isInput

public boolean isInput()
Return true if it is an input.

Returns:
true is it is an input, or false if not.

isOutput

public boolean isOutput()
Return true if it an output.

Returns:
true is it is an output, or false if not.

isReturn

public boolean isReturn()
Return true if it is a return.

Returns:
true is it is an return, or false if not.

removeValueListener

public void removeValueListener(ValueListener listener)
Remove a listener to be notified when the value of this settable object changes.

Parameters:
listener - The listener to remove.
See Also:
addValueListener(ValueListener)

setCType

public void setCType(java.lang.String cType)
Set the C type of the argument with the given string.

Parameters:
cType - The C type of argument.
See Also:
getCType()

setContainer

public void setContainer(NamedObj container)
                  throws IllegalActionException,
                         NameDuplicationException
Specify the container, adding the entity to the list of entities in the container.

If the container already contains an entity with the same name, then throw an exception and do not make any changes. Similarly, if the container is not in the same workspace as this entity, throw an exception.
If the entity is already contained by the container, do nothing.
If this entity already has a container, remove it from that container first. Otherwise, remove it from the directory of the workspace, if it is present.
If the argument is null, then unlink the ports of the entity from any relations and remove it from its container.
It is not added to the workspace directory, so this could result in this entity being garbage collected.
Derived classes may further constrain the container to subclasses of CompositeEntity by overriding the protected method _checkContainer(). This method is write-synchronized to the workspace and increments its version number.

Overrides:
setContainer in class Attribute
Parameters:
container - The proposed container, which must be a GenericJNIActor.
Throws:
IllegalActionException - If the action would result in a recursive containment structure, or if this entity and container are not in the same workspace, or if the container is not an instance of GenericJNIActor.
NameDuplicationException - If the name of this entity collides with a name already in the container.
See Also:
getContainer()

setExpression

public void setExpression(java.lang.String expression)
Set the expression of the argument. The format is "_isInput,_isOutput,_isReturn,_cType".

Specified by:
setExpression in interface Settable
Overrides:
setExpression in class AbstractSettableAttribute
Parameters:
expression - The value of this attribute.
See Also:
getExpression()

setExpression

public void setExpression()
Set the expression of the argument from its attributes.

See Also:
getExpression()

setInput

public void setInput(boolean input)
Set to true if the attribute is an input.

Parameters:
input - True if this is an input, false if it is not.

setKind

public void setKind(java.lang.String selectedValues)
Set the kind of the argument with the given string.

Parameters:
selectedValues - A string describing the type of Argument. valid values are "input", "output", "return", "input, output".
See Also:
getKind()

setOutput

public void setOutput(boolean output)
Set to true if the attribute is an output.

Parameters:
output - True if this is an output, false if it is not.

setReturn

public void setReturn(boolean returnFlag)
Set to true if the attribute is a return.

Parameters:
returnFlag - True if this is an input, false if it is not.

setVisibility

public void setVisibility(Settable.Visibility visibility)
Set the visibility of this attribute in the user interface.

Parameters:
visibility - Ignored, the visibility of this attribute is always Settable.NONE.
See Also:
getVisibility()

validate

public java.util.Collection validate()
                              throws IllegalActionException
Notify the container that an attribute has changed.

Returns:
A collection of settables that are also validated as a side effect, or null if there are none.
Throws:
IllegalActionException - If a error occurs

_checkContainer

protected void _checkContainer(NamedObj container)
                        throws IllegalActionException
Check that the specified container is of a suitable class for this entity. In this base class, this method returns immediately without doing anything. Derived classes may override it to constrain the container.

Parameters:
container - The proposed container.
Throws:
IllegalActionException - If the container is not of an acceptable class. Not thrown in this base class.

_propagateValue

protected void _propagateValue(NamedObj destination)
                        throws IllegalActionException
Propagate the value of this object to the specified object. The specified object is required to be an instance of the same class as this one, or a ClassCastException will be thrown.

Overrides:
_propagateValue in class NamedObj
Parameters:
destination - Object to which to propagate the value.
Throws:
IllegalActionException - If the value cannot be propagated.