ecologylab.xml.types.scalar
Class IntType

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.xml.types.scalar.ScalarType<java.lang.Integer>
          extended by ecologylab.xml.types.scalar.IntType

public class IntType
extends ScalarType<java.lang.Integer>

Type system entry for int, a built-in primitive.

Author:
andruid

Field Summary
static int DEFAULT_VALUE
           
static java.lang.String DEFAULT_VALUE_STRING
           
 
Fields inherited from class ecologylab.xml.types.scalar.ScalarType
DEFAULT_DELIMS
 
Constructor Summary
IntType()
          This constructor should only be called once per session, through a static initializer, typically in TypeRegistry.
 
Method Summary
 void appendValue(java.lang.Appendable buffy, java.lang.reflect.Field field, java.lang.Object context, boolean needsEscaping)
          Get the value from the Field, in the context.
 void appendValue(java.lang.StringBuilder buffy, java.lang.reflect.Field field, java.lang.Object context, boolean needsEscaping)
          Get the value from the Field, in the context.
protected  java.lang.String defaultValueString()
          The default value for this type, as a String.
 java.lang.Integer getInstance(java.lang.String value)
          If this is a reference type, build an appropriate Object, given a String representation.
 int getValue(java.lang.String valueString)
          Convert the parameter to int.
 boolean isDefaultValue(java.lang.reflect.Field field, java.lang.Object context)
          True if the value in the Field object matches the default value for this type.
 boolean setField(java.lang.Object object, java.lang.reflect.Field field, java.lang.String value)
          This is a primitive type, so we set it specially.
 java.lang.String toString(java.lang.reflect.Field field, java.lang.Object context)
          The string representation for a Field of this type
 
Methods inherited from class ecologylab.xml.types.scalar.ScalarType
affordsInterestExpression, allowDelimitersInTokens, allowNewLines, appendValue, appendValue, composedOfTerms, defaultValue, defaultValueLength, delimeters, getClassName, getTypeClass, illegalChars, isDefaultValue, isFloatingPoint, isPrimitive, isReference, marshall, needsEscaping, setFieldError
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_VALUE

public static final int DEFAULT_VALUE
See Also:
Constant Field Values

DEFAULT_VALUE_STRING

public static final java.lang.String DEFAULT_VALUE_STRING
See Also:
Constant Field Values
Constructor Detail

IntType

public IntType()
This constructor should only be called once per session, through a static initializer, typically in TypeRegistry.

To get the instance of this type object for use in translations, call TypeRegistry.get("int").

Method Detail

getValue

public int getValue(java.lang.String valueString)
Convert the parameter to int.


getInstance

public java.lang.Integer getInstance(java.lang.String value)
If this is a reference type, build an appropriate Object, given a String representation. If it is a primitive type, return a boxed value.

Specified by:
getInstance in class ScalarType<java.lang.Integer>
Parameters:
value - String representation of the instance.

setField

public boolean setField(java.lang.Object object,
                        java.lang.reflect.Field field,
                        java.lang.String value)
This is a primitive type, so we set it specially.

Overrides:
setField in class ScalarType<java.lang.Integer>
Parameters:
object - The object whose field should be modified.
field - The field to be set.
value - String representation of the value to set the field to. This Type will convert the value to the appropriate type, using getInstance(String) for reference types, and type specific getValue(String) methods for primitive types.
Returns:
true if the field is set properly, or if the parameter value that is passed in is null. false if the field cannot be accessed, or if value cannot be converted to the appropriate type.
See Also:
ScalarType.setField(Object, Field, String)

toString

public java.lang.String toString(java.lang.reflect.Field field,
                                 java.lang.Object context)
The string representation for a Field of this type

Overrides:
toString in class ScalarType<java.lang.Integer>

defaultValueString

protected final java.lang.String defaultValueString()
The default value for this type, as a String. This value is the one that translateToXML(...) wont bother emitting. In this case, "0".

Overrides:
defaultValueString in class ScalarType<java.lang.Integer>

isDefaultValue

public boolean isDefaultValue(java.lang.reflect.Field field,
                              java.lang.Object context)
                       throws java.lang.IllegalArgumentException,
                              java.lang.IllegalAccessException
True if the value in the Field object matches the default value for this type.

Overrides:
isDefaultValue in class ScalarType<java.lang.Integer>
Parameters:
field -
Returns:
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException

appendValue

public void appendValue(java.lang.StringBuilder buffy,
                        java.lang.reflect.Field field,
                        java.lang.Object context,
                        boolean needsEscaping)
                 throws java.lang.IllegalArgumentException,
                        java.lang.IllegalAccessException
Get the value from the Field, in the context. Append its value to the buffy.

Overrides:
appendValue in class ScalarType<java.lang.Integer>
Parameters:
buffy -
field -
context -
needsEscaping - TODO
Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException

appendValue

public void appendValue(java.lang.Appendable buffy,
                        java.lang.reflect.Field field,
                        java.lang.Object context,
                        boolean needsEscaping)
                 throws java.lang.IllegalArgumentException,
                        java.lang.IllegalAccessException,
                        java.io.IOException
Get the value from the Field, in the context. Append its value to the buffy.

Overrides:
appendValue in class ScalarType<java.lang.Integer>
Parameters:
buffy -
field -
context -
needsEscaping - TODO
Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.io.IOException