gov.llnl.babel.symbols
Class Type

java.lang.Object
  |
  +--gov.llnl.babel.symbols.Type

public class Type
extends java.lang.Object

The Type class defines a SIDL type, such as a primitive type (boolean, char, dcomplex, double, fcomplex, float, int, long, opaque, and string), arrays, and user-defined types (enum, interface, or class). A Type object may also be created for a void return type from a method.


Field Summary
static int ARRAY
           
static int BOOLEAN
           
static int CHAR
           
static int CLASS
           
static int COLUMN_MAJOR
           
static int DCOMPLEX
           
static int DOUBLE
           
static int ENUM
           
static int FCOMPLEX
           
static int FLOAT
           
static int INT
           
static int INTERFACE
           
static int LONG
           
static int OPAQUE
           
static int ROW_MAJOR
           
static int STRING
           
static int SYMBOL
           
static int UNSPECIFIED
           
static int VOID
           
 
Constructor Summary
Type(int type)
          Create a new primitive type (boolean, char, dcomplex, double, fcomplex, float, int, long, opaque, and string).
Type(SymbolID id)
          Create a new type given a user-defined symbol identifier.
Type(Type type, int dim, int order)
          Create a new array provided the array type, dimension, and order.
 
Method Summary
 boolean equals(java.lang.Object object)
          Compare two type objects and return true if they are the same.
 int getArrayDimension()
          If this type is an array, then return the dimension; otherwise, return zero.
 int getArrayOrder()
          If this type is an array, then return the order; otherwise, return zero.
 Type getArrayType()
          If this is an array, return the array type; otherwise return null.
 int getDetailedType()
          Returns the integer that identifies the type of this type.
 SymbolID getSymbolID()
          Return the symbol identifier associated with this symbol type.
 int getType()
          Return the integer that identifies the type of this type.
 java.lang.String getTypeString()
          Return a string representation of the type for printing out the types in a method signature.
 boolean hasArrayOrderSpec()
          Return true if and only if the type is an array with an ordering specification.
 boolean isArray()
          Check whether the type is an array.
 boolean isPrimitive()
          Check whether the type is one of the standard primitive types, including strings.
 boolean isString()
          Check whether the type is a string.
 boolean isSymbol()
          Check whether the type is a symbol.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VOID

public static final int VOID
See Also:
Constant Field Values

BOOLEAN

public static final int BOOLEAN
See Also:
Constant Field Values

CHAR

public static final int CHAR
See Also:
Constant Field Values

DCOMPLEX

public static final int DCOMPLEX
See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
See Also:
Constant Field Values

FCOMPLEX

public static final int FCOMPLEX
See Also:
Constant Field Values

FLOAT

public static final int FLOAT
See Also:
Constant Field Values

INT

public static final int INT
See Also:
Constant Field Values

LONG

public static final int LONG
See Also:
Constant Field Values

OPAQUE

public static final int OPAQUE
See Also:
Constant Field Values

STRING

public static final int STRING
See Also:
Constant Field Values

ENUM

public static final int ENUM
See Also:
Constant Field Values

INTERFACE

public static final int INTERFACE
See Also:
Constant Field Values

CLASS

public static final int CLASS
See Also:
Constant Field Values

SYMBOL

public static final int SYMBOL
See Also:
Constant Field Values

ARRAY

public static final int ARRAY
See Also:
Constant Field Values

UNSPECIFIED

public static final int UNSPECIFIED
See Also:
Constant Field Values

COLUMN_MAJOR

public static final int COLUMN_MAJOR
See Also:
Constant Field Values

ROW_MAJOR

public static final int ROW_MAJOR
See Also:
Constant Field Values
Constructor Detail

Type

public Type(int type)
Create a new primitive type (boolean, char, dcomplex, double, fcomplex, float, int, long, opaque, and string). Use the other constructors to create a symbol or array type.


Type

public Type(SymbolID id)
Create a new type given a user-defined symbol identifier. This symbol identifier will represent an enum, interface, or class.


Type

public Type(Type type,
            int dim,
            int order)
Create a new array provided the array type, dimension, and order.

Method Detail

getType

public int getType()
Return the integer that identifies the type of this type. If the type is ENUM, INTERFACE, or CLASS, it is returned as the generic SYMBOL. (for historical purposes)


getDetailedType

public int getDetailedType()
Returns the integer that identifies the type of this type. If type == SYMBOL, this method will try to further refine the type to one of (CLASS, INTERFACE, ENUM). This may, in fact, fail if the type is undefined (via a forward reference) and then SYMBOL is returned.


isPrimitive

public boolean isPrimitive()
Check whether the type is one of the standard primitive types, including strings.


isString

public boolean isString()
Check whether the type is a string.


isSymbol

public boolean isSymbol()
Check whether the type is a symbol.


isArray

public boolean isArray()
Check whether the type is an array.


getArrayDimension

public int getArrayDimension()
If this type is an array, then return the dimension; otherwise, return zero.


getArrayOrder

public int getArrayOrder()
If this type is an array, then return the order; otherwise, return zero.


getArrayType

public Type getArrayType()
If this is an array, return the array type; otherwise return null.


hasArrayOrderSpec

public boolean hasArrayOrderSpec()
Return true if and only if the type is an array with an ordering specification. For example, array<int,2,column-major> would return true; array<int, 2> would return false. For non-array types, this always returns false.


getSymbolID

public SymbolID getSymbolID()
Return the symbol identifier associated with this symbol type. If this is not a symbol type, then return null.


getTypeString

public java.lang.String getTypeString()
Return a string representation of the type for printing out the types in a method signature.


equals

public boolean equals(java.lang.Object object)
Compare two type objects and return true if they are the same.

Overrides:
equals in class java.lang.Object