An attribute for defining a data type for a port. Use setExpression() to define a data type, as in for example,
attribute.setExpression("double");
The class TypedIOPort recognizes when this attribute is inserted and calls setTypeEquals() to define its type. In the above example, the type of the port is set to double.
The type can be given by any expression that can be evaluated. In fact, it would be equally valid to specify the type to be double using
attribute.setExpression("0.0");
The Constants class defines the constant "double" to have the value 0.0, so that instead you may give the type by name. The Constants class defines for convenience the following constants: boolean, complex, double, fixedpoint, general, int, long, matrix, object, scalar, string, and unknown. The constant "unknown" has a rather special behavior, in that it sets the type of the port to be unknown, allowing type resolution to infer it. The constant "matrix" designates a matrix without specifying an element type, in contrast to, for example, "[double]", which specifies a double matrix. Similarly, the constant "scalar" designates a scalar of any type (double, int, long, etc.). The constant "general" designates any type.
Since the type is given by a "prototype" (an expression with the appropriate type), any data type that can be given in an expression can be specified as a type. For structured types, follow the same syntax as in expressions. For example:
{double} - double array [int] - int matrix {field1 = string, field2 = int} - record with two fields
@author Edward A. Lee, Xiaojun Liu
@version $Id: TypeAttribute.java,v 1.36 2006/10/26 21:44:02 cxh Exp $
@since Ptolemy II 1.0
@Pt.ProposedRating Yellow (eal)
@Pt.AcceptedRating Red (cxh)
@see TypedIOPort
@see ptolemy.data.expr.Constants