ecologylab.xml.types.scalar
Class CharType

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.xml.types.scalar.ScalarType<java.lang.Character>
          extended by ecologylab.xml.types.scalar.CharType

public class CharType
extends ScalarType<java.lang.Character>

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

Author:
andruid

Field Summary
static char DEFAULT_VALUE
           
static java.lang.String DEFAULT_VALUE_STRING
           
 
Fields inherited from class ecologylab.xml.types.scalar.ScalarType
DEFAULT_DELIMS
 
Constructor Summary
CharType()
          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.Character getInstance(java.lang.String value)
          Parse the String into the (primitive) type, and return a boxed instance.
 char getValue(java.lang.String valueString)
          Convert the parameter to char.
 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 object)
          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 char 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

CharType

public CharType()
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("char").

Method Detail

getValue

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


getInstance

public java.lang.Character getInstance(java.lang.String value)
Parse the String into the (primitive) type, and return a boxed instance.

Specified by:
getInstance in class ScalarType<java.lang.Character>
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.Character>
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(java.lang.Object, java.lang.reflect.Field, java.lang.String)

toString

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

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

defaultValueString

protected 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, "false".

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

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.Character>
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.Character>
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.Character>
Parameters:
buffy -
field -
context -
needsEscaping - TODO
Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.io.IOException