org.quattor.pan.type
Class FullType

java.lang.Object
  extended by org.quattor.pan.type.Type
      extended by org.quattor.pan.type.FullType

public class FullType
extends Type

Represents a complete type specification in the pan language, which can have a default value and/or a validation block defined.

Author:
loomis

Field Summary
 
Fields inherited from class org.quattor.pan.type.Type
source, sourceRange
 
Constructor Summary
FullType(BaseType baseType)
          This contructor is intended for built-in types that have neither source locations or default values.
FullType(java.lang.String source, SourceRange sourceRange, BaseType baseType, Element defaultValue, Operation dml)
           
 
Method Summary
 Element findDefault(Context context)
          This method returns the default value for the type or null if no default value exists.
 BaseType getBaseType()
           
 java.lang.String getTypeName()
           
 Element setDefaults(Context context, Element self)
          This will call the setDefaults method of the base type with the given argument.
 java.lang.String toString()
           
 void validate(Context context, Element self)
          This method will run this type's validation against the given element.
 void validateAsIncludedType(Context context, Element self)
          A FullType defers the validation to the referenced BaseType, but also runs the DML validation block if defined.
 void verifySubtypesDefined(TypeMap types)
          This method verifies that all of the types referenced from this type are already defined within the given context.
 
Methods inherited from class org.quattor.pan.type.Type
getSource, getSourceRange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FullType

public FullType(BaseType baseType)
This contructor is intended for built-in types that have neither source locations or default values.

Parameters:
baseType -

FullType

public FullType(java.lang.String source,
                SourceRange sourceRange,
                BaseType baseType,
                Element defaultValue,
                Operation dml)
Method Detail

findDefault

public Element findDefault(Context context)
Description copied from class: Type
This method returns the default value for the type or null if no default value exists. While only FullType objects can directly have a default value, these can be referenced by other types like AliasType and RecordType.

Specified by:
findDefault in class Type
Parameters:
context - the context may be needed by a complex type to look up other type definitions
Returns:
default value or null if one doesn't exist

validate

public void validate(Context context,
                     Element self)
              throws ValidationException
Description copied from class: Type
This method will run this type's validation against the given element. The method may not modify either argument.

Specified by:
validate in class Type
Parameters:
context - ObjectContext for running the validation
self - Element to validate
Throws:
ValidationException

validateAsIncludedType

public void validateAsIncludedType(Context context,
                                   Element self)
                            throws ValidationException
A FullType defers the validation to the referenced BaseType, but also runs the DML validation block if defined.

Overrides:
validateAsIncludedType in class Type
Parameters:
context - ObjectContext for running the validation
self - Element to validate
Throws:
ValidationException

setDefaults

public Element setDefaults(Context context,
                           Element self)
                    throws EvaluationException
This will call the setDefaults method of the base type with the given argument. NOTE: this method cannot be called with self equal to null. If the element doesn't exist, then the caller must extract the default value from this type as set the value. Afterwards, this method can be called. This is necessary because we cannot lookup the path on a null value.

Specified by:
setDefaults in class Type
Returns:
replacement element or null if no replacement is necessary
Throws:
EvaluationException

verifySubtypesDefined

public void verifySubtypesDefined(TypeMap types)
Description copied from class: Type
This method verifies that all of the types referenced from this type are already defined within the given context. If not, an EvaluationException will be thrown.

Specified by:
verifySubtypesDefined in class Type
Parameters:
types - TypeMap to use for looking up referenced types

getBaseType

public BaseType getBaseType()

getTypeName

public java.lang.String getTypeName()

toString

public java.lang.String toString()
Overrides:
toString in class Type


Copyright © 2011 Quattor. All Rights Reserved.