xtc.type
Class TupleT

java.lang.Object
  extended by xtc.tree.Node
      extended by xtc.type.Type
          extended by xtc.type.DerivedT
              extended by xtc.type.TupleT
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, Locatable

public class TupleT
extends DerivedT

A tuple type. Tuples may be either anonymous, without a name, or named. For named tuples, this class provides accessors to the full name and the simple name, which is the full name without any qualifier.

Version:
$Revision: 1.7 $
Author:
Robert Grimm

Nested Class Summary
 
Nested classes/interfaces inherited from class xtc.type.Type
Type.Tag
 
Constructor Summary
TupleT()
          Create a new incomplete and anonymous tuple type.
TupleT(java.util.List<Type> types)
          Create a new anonymous tuple type.
TupleT(java.lang.String name)
          Create a new incomplete tuple type.
TupleT(java.lang.String name, java.util.List<Type> types)
          Create a new tuple type.
TupleT(java.lang.String name, Type type)
          Create a new tuple type.
TupleT(Type template, java.lang.String name, java.util.List<Type> types)
          Create a new tuple type.
 
Method Summary
 TupleT copy()
          Create a deep copy of this type.
 boolean equals(java.lang.Object o)
           
 java.lang.String getName()
          Get this tuple's name.
 java.lang.String getSimpleName()
          Get this tuple's simple name.
 java.util.List<Type> getTypes()
          Get the element types.
 int hashCode()
           
 boolean hasName()
          Determine whether this tuple has a name.
 boolean hasName(java.lang.String name)
          Determine whether this tuple has the specified name.
 boolean hasSimpleName(java.lang.String name)
          Determine whether this tuple has the specified simple name.
 boolean isTuple()
          Determine whether this type is an tuple.
 Type seal()
          Seal this type.
 void setTypes(java.util.List<Type> types)
          Set the element types.
 Type.Tag tag()
          Get this type's tag.
 TupleT toTuple()
          Get this type as an tuple.
 void write(java.lang.Appendable out)
          Write a human readable representation to the specified appendable.
 
Methods inherited from class xtc.type.DerivedT
isDerived
 
Methods inherited from class xtc.type.Type
addAttribute, annotate, attribute, attribute, attribute, attributes, cast, checkNotSealed, constant, constant, copy, deannotate, getAttribute, getAttribute, getConstant, getConstant, getLanguage, getLanguage, getLocation, getLocation, getScope, getScope, getShape, getShape, hasAlias, hasAnnotated, hasAttribute, hasAttribute, hasAttribute, hasAttribute, hasAttributes, hasConstant, hasConstant, hasEnum, hasEnumerator, hasError, hasInstantiated, hasLanguage, hasLanguage, hasLocation, hasLocation, hasParameterized, hasScope, hasScope, hasShape, hasShape, hasStructOrUnion, hasTag, hasTagged, hasVariable, hasWTag, isAlias, isAnnotated, isArray, isBoolean, isClass, isConcrete, isEnum, isEnumerator, isError, isFloat, isFunction, isInstantiated, isInteger, isInterface, isInternal, isInternalParameter, isLabel, isMethod, isNamedParameter, isNumber, isPackage, isParameter, isParameterized, isPointer, isSealed, isStruct, isUnion, isUnit, isVariable, isVariant, isVoid, isWildcard, isWrapped, language, locate, locate, mark, properties, removeAttribute, removeProperty, resolve, resolve, scope, seal, setLocation, setLocation, setProperty, shape, shape, toAlias, toAnnotated, toArray, toBoolean, toClass, toEnum, toEnumerator, toFloat, toFunction, toInstantiated, toInteger, toInterface, toInternal, toInternalParameter, toLabel, toMethod, toNamedParameter, toNumber, toPackage, toParameter, toParameterized, toPointer, toStruct, toStructOrUnion, toTagged, toUnion, toUnit, toVariable, toVariant, toVoid, toWildcard, toWrapped, trace, wtag
 
Methods inherited from class xtc.tree.Node
add, add, addAll, addAll, addAll, addAll, addAllTo, addNode, contains, get, getBoolean, getBooleanProperty, getGeneric, getList, getNode, getProperty, getString, getStringProperty, getTokenText, hasProperty, hasTraversal, indexOf, isAnnotation, isEmpty, isGeneric, isList, isToken, iterator, lastIndexOf, remove, set, size, strip, toAnnotation, toList, toString, toToken
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TupleT

public TupleT()
Create a new incomplete and anonymous tuple type.


TupleT

public TupleT(java.util.List<Type> types)
Create a new anonymous tuple type.

Parameters:
types - The types.

TupleT

public TupleT(java.lang.String name)
Create a new incomplete tuple type.

Parameters:
name - The name.

TupleT

public TupleT(java.lang.String name,
              Type type)
Create a new tuple type.

Parameters:
name - The name.
type - The only element type.

TupleT

public TupleT(java.lang.String name,
              java.util.List<Type> types)
Create a new tuple type.

Parameters:
name - The name.
types - The element types.

TupleT

public TupleT(Type template,
              java.lang.String name,
              java.util.List<Type> types)
Create a new tuple type.

Parameters:
template - The type whose annotations to copy.
name - The name.
types - The element types.
Method Detail

seal

public Type seal()
Description copied from class: Type
Seal this type. Subclasses that reference other types must override this method and, if the instance is not sealed, first invoke the superclass' version and then seal all referenced types. For example, if a subclass references a single type type, the corresponding overridden method reads:
 public Type seal() {
   if (! isSealed()) {
     super.seal();
     type.seal();
   }
   return this;
 }
 
First testing whether a type is sealed and then invoking the superclass' seal() method avoids infinite recursions for mutually recursive types.

Overrides:
seal in class Type
Returns:
This type.
See Also:
Type.seal(List)

copy

public TupleT copy()
Description copied from class: Type
Create a deep copy of this type. The resulting type is not sealed.

Specified by:
copy in class Type
Returns:
A deep copy of this type.

tag

public Type.Tag tag()
Description copied from class: Type
Get this type's tag. Invocations to this method are forwarded across wrapped types.

Specified by:
tag in class Type
Returns:
This type's tag.
See Also:
Type.wtag()

isTuple

public boolean isTuple()
Description copied from class: Type
Determine whether this type is an tuple.

Overrides:
isTuple in class Type
Returns:
true if this type is an tuple.

toTuple

public TupleT toTuple()
Description copied from class: Type
Get this type as an tuple.

Overrides:
toTuple in class Type
Returns:
This type as an tuple.

hasName

public boolean hasName()
Determine whether this tuple has a name.

Returns:
true if this tuple has a name.

hasName

public boolean hasName(java.lang.String name)
Determine whether this tuple has the specified name.

Overrides:
hasName in class Node
Parameters:
name - The name.
Returns:
true if this tuple has the name.

hasSimpleName

public boolean hasSimpleName(java.lang.String name)
Determine whether this tuple has the specified simple name.

Parameters:
name - The simple name.
Returns:
true if this tuple has the simple name.

getName

public java.lang.String getName()
Get this tuple's name.

Overrides:
getName in class Node
Returns:
The name or null if this tuple is anonymous.

getSimpleName

public java.lang.String getSimpleName()
Get this tuple's simple name.

Returns:
The simple name or null if this tuple is anonymous.

getTypes

public java.util.List<Type> getTypes()
Get the element types.

Returns:
The element types.

setTypes

public void setTypes(java.util.List<Type> types)
Set the element types.

Parameters:
types - The new element types.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

write

public void write(java.lang.Appendable out)
           throws java.io.IOException
Description copied from class: Node
Write a human readable representation to the specified appendable. If this node supports generic traversal, the default implementation writes this node in algebraic term-format; otherwise, it writes the string returned by Object.toString().

Overrides:
write in class Node
Parameters:
out - The appendable.
Throws:
java.io.IOException - Signals an I/O error.


Copyright © 2012. All Rights Reserved.