jni
Class Argument

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

public class Argument
extends AbstractSettableAttribute

An Argument is a native function argument associated to a GenericJNIActor

Since:
Ptolemy II 2.2
Version:
$Id: Argument.java,v 1.28.2.2 2004/06/22 01:37:01 cxh Exp $
Author:
V.Arnould, Thales
See Also:
GenericJNIActor, Serialized Form
Accepted Rating:
Red (vincent.arnould)
Proposed Rating:
Red (vincent.arnould)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Nested classes inherited from class ptolemy.kernel.util.Settable
Settable.Visibility
 
Field Summary
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.kernel.util.Settable
EXPERT, FULL, NONE, NOT_EDITABLE
 
Constructor Summary
Argument()
          Default constructor
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(GenericJNIActor container)
          Check that the specified container is of a suitable class for this entity.
protected  void _checkType()
          Check that the specified type is a suitable type 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 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()
          This is for derivates of Attribute
 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 v)
          This is for derivates of Attribute set the Visibility
 void validate()
          Notify the container that an attribute has changed
 
Methods inherited from class ptolemy.kernel.util.AbstractSettableAttribute
getDefaultExpression
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, clone, setName
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, 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.Nameable
description, getFullName, getName, getName, setName
 

Constructor Detail

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


Argument

public Argument()
Default constructor

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.

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

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.

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

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"

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()
This is for derivates of Attribute

Returns:
the 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.

setCType

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


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.

setExpression

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

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

setExpression

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


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".

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 v)
This is for derivates of Attribute set the Visibility

Parameters:
v - The visibility of this Settable.

validate

public void validate()
              throws IllegalActionException
Notify the container that an attribute has changed

Throws:
IllegalActionException - If a error occurs

_checkContainer

protected void _checkContainer(GenericJNIActor 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.

_checkType

protected 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.

_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.