step.typedef
Class TypeDef

java.lang.Object
  |
  +--step.typedef.TypeDef
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
RecordDef

public class TypeDef
extends Object
implements Cloneable

A definition for a STEP type.

Types have a default definition, however some fields may choose to use an alternate, context-sensitive version of the definition.

See Also:
FieldDef.getAltTypeDef()

Constructor Summary
TypeDef(String name, Package pkg, List fieldDefs, List modifiers)
           
 
Method Summary
protected  void applyModifiers()
          Apply the list of modifiers to the various fields of this definition.
 Object clone()
          Get a copy (clone) of this definition.
 void dump(int level)
           
static TypeDef getDefault(StepObject o)
          Get the default (prototype) definition for the type of the given object.
static TypeDef getDefault(String typeName)
          Get the default (prototype) definition for the given type name.
static TypeDef getDefault(Type type)
          Get the default (prototype) definition for the given type.
 FieldDef getField(String fieldName)
          Get the field definition for the field with the given name.
 List getFields()
          Get the list of field definitions associated with this definition.
 String getFullName()
          Get the fully-qualified name for the type represented by this definition.
 List getModifiers()
          Get the list of field modifiers associated with this definition.
 String getName()
          Get the short name for the type represented by this definition.
 Package getPackage()
          Get the package that contains the type represented by this definition.
 Type getType()
          Get the type that this definition is associated with.
static boolean isDefined(StepObject o)
          Does the given type have a default definition set?
static boolean isDefined(String typeName)
          Does the given type have a default definition set?
static boolean isDefined(Type type)
          Does the given type have a default definition set?
 boolean isResolved()
          Is this definition complete?
 boolean isTypeResolved()
          Is the type information for this definition complete?
static TypeDef merge(TypeDef lowDef, TypeDef highDef)
          Combine two definitions into one.
 void resolve()
          Execute all operations needed to complete this definition.
protected  void resolveType()
          Complete the type information for this definition.
 void setAsDefault()
          Set this definition as the default (prototype) definition for all objects of this type.
protected  void setFields(List fieldDefs)
          Replace the current list of field definitions.
protected  void setModifiers(List modifiers)
          Replace the current list of field modifiers.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeDef

public TypeDef(String name,
               Package pkg,
               List fieldDefs,
               List modifiers)
Throws:
ClassCastException - if
Method Detail

isDefined

public static boolean isDefined(StepObject o)
Does the given type have a default definition set?

See Also:
setAsDefault()

getDefault

public static TypeDef getDefault(StepObject o)
Get the default (prototype) definition for the type of the given object.

See Also:
getDefault(Type)

isDefined

public static boolean isDefined(String typeName)
Does the given type have a default definition set?

See Also:
setAsDefault()

getDefault

public static TypeDef getDefault(String typeName)
Get the default (prototype) definition for the given type name.

See Also:
getDefault(Type)

isDefined

public static boolean isDefined(Type type)
Does the given type have a default definition set?

See Also:
setAsDefault()

getDefault

public static TypeDef getDefault(Type type)
Get the default (prototype) definition for the given type.

Returns:
the current defualt definition for the type, or null if no default exists for the type.
Throws:
RecordDefNotFoundException - if the type does not have a default definition and one cannot be loaded from the current environment.
See Also:
setAsDefault()

setAsDefault

public void setAsDefault()
Set this definition as the default (prototype) definition for all objects of this type.


getName

public String getName()
Get the short name for the type represented by this definition.

See Also:
getFullName()

getFullName

public String getFullName()
Get the fully-qualified name for the type represented by this definition.

See Also:
getName(), Package.qualify(String)

getPackage

public Package getPackage()
Get the package that contains the type represented by this definition.


getType

public Type getType()
Get the type that this definition is associated with.

See Also:
Type.v(String,Package)

getFields

public List getFields()
Get the list of field definitions associated with this definition.

The list returned is unmodifiable.


setFields

protected void setFields(List fieldDefs)
Replace the current list of field definitions.

Throws:
ClassCastException - if an element of the list is not a FieldDef.

getField

public FieldDef getField(String fieldName)
Get the field definition for the field with the given name.

Returns:
the field definition, or null if no field is defined with the given name.

getModifiers

public List getModifiers()
Get the list of field modifiers associated with this definition.

The list returned is unmodifiable.


setModifiers

protected void setModifiers(List modifiers)
Replace the current list of field modifiers.

Throws:
ClassCastException - if an element of the list is not a FieldModifier.

isTypeResolved

public boolean isTypeResolved()
Is the type information for this definition complete?

See Also:
resolveType(), isResolved()

resolveType

protected void resolveType()
Complete the type information for this definition. The default action is to check that the fields have defined types.

NOTE: Clients of this object can invoke this method indirectly via resolve().

Throws:
ResolveException - if a field has an undefined type.

isResolved

public boolean isResolved()
Is this definition complete?

In general, a type definition is complete (resolved) when all inherited information has been incorporated, the existence of field types have been verified, and the field modifiers have been applied.

See Also:
resolve()

resolve

public void resolve()
Execute all operations needed to complete this definition.

By default, a type definition is completed when the type information is resolved and the field modifiers have been applied.

See Also:
resolveType(), applyModifiers()

applyModifiers

protected void applyModifiers()
Apply the list of modifiers to the various fields of this definition.

NOTE: Clients of this object can invoke this method indirectly via resolve().

Throws:
ResolveException - if

merge

public static TypeDef merge(TypeDef lowDef,
                            TypeDef highDef)
Combine two definitions into one. This method is used by RecordEncoders to handle the encoding of sub-types.

See Also:
FieldDef.merge(FieldDef,FieldDef)

clone

public Object clone()
Get a copy (clone) of this definition. The clone is a deep copy of the field definitions and modifiers.

Overrides:
clone in class Object

dump

public void dump(int level)