uk.ac.man.cs.rainbow.datamodel
Class Type.Union

java.lang.Object
  |
  +--uk.ac.man.cs.rainbow.datamodel.Type
        |
        +--uk.ac.man.cs.rainbow.datamodel.Type.Union
All Implemented Interfaces:
Argument, Data.Union.T, Serializable, Type
Enclosing class:
Type

public static class Type.Union
extends Type
implements Data.Union.T

The class of types of unions.

See Also:
Data.Union, Serialized Form

Inner classes inherited from class uk.ac.man.cs.rainbow.datamodel.Type
Type.Boolean, Type.Enum, Type.Integer, Type.Tuple, Type.Union, Type.Vector
 
Field Summary
protected  String[] tags
           
protected  Type[] types
           
 
Constructor Summary
Type.Union(Type[] types, String[] fieldNames)
           
 
Method Summary
 int countTags()
          How many tags are there?
 boolean equals(Type t)
          Test for equality between types.
 int getIndex(String fieldName)
          Convert an option name into an integer index into the type.
 String getTag(int idx)
          Get the name of the idxth tag.
 Type getTagEnumeration()
          Get an enumeration of the tags.
 Type getType(int idx)
          Get the type of the idxth tag.
 String render(Expression contents, int index)
          Render a union, given the value and tag that the union is defined by.
 String toString()
          Render the type as a string.
 
Methods inherited from class uk.ac.man.cs.rainbow.datamodel.Type
compatableWith, equals, parse, parse, subst
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

types

protected Type[] types

tags

protected String[] tags
Constructor Detail

Type.Union

public Type.Union(Type[] types,
                  String[] fieldNames)
Method Detail

toString

public String toString()
Description copied from class: Type
Render the type as a string. Must be specified by real types.
Overrides:
toString in class Type

render

public String render(Expression contents,
                     int index)
Description copied from interface: Data.Union.T
Render a union, given the value and tag that the union is defined by.
Specified by:
render in interface Data.Union.T

countTags

public int countTags()
Description copied from interface: Data.Union.T
How many tags are there?
Specified by:
countTags in interface Data.Union.T

getTag

public String getTag(int idx)
Description copied from interface: Data.Union.T
Get the name of the idxth tag.
Specified by:
getTag in interface Data.Union.T
Following copied from interface: uk.ac.man.cs.rainbow.datamodel.Data.Union.T
Throws:
TypeException - If the index is out of range.

getType

public Type getType(int idx)
Description copied from interface: Data.Union.T
Get the type of the idxth tag.
Specified by:
getType in interface Data.Union.T

getTagEnumeration

public Type getTagEnumeration()
                       throws TypeException
Description copied from interface: Data.Union.T
Get an enumeration of the tags.
Specified by:
getTagEnumeration in interface Data.Union.T

equals

public boolean equals(Type t)
Description copied from class: Type
Test for equality between types.
Overrides:
equals in class Type

getIndex

public int getIndex(String fieldName)
             throws TypeException
Convert an option name into an integer index into the type.
Specified by:
getIndex in interface Data.Union.T
Throws:
TypeException - If the option name is not known in the type.