com.davisor.data
Class ChoiceType

java.lang.Object
  extended byjava.text.Format
      extended bycom.davisor.data.Type
          extended bycom.davisor.data.LocaleType
              extended bycom.davisor.data.FormatType
                  extended bycom.davisor.data.SimpleNumberType
                      extended bycom.davisor.data.DoubleType
                          extended bycom.davisor.data.ChoiceType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, NumberType, java.io.Serializable

public class ChoiceType
extends DoubleType

ChoiceType extends the DoubleType class by a choice formatting option, as defined by the standard Java ChoiceFormat class. ChoiceType specification strings will be passed to an underlying ChoiceFormat instance that will be used to format data values of the choice type.

Since:
JDK1.1
See Also:
EnumType, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static java.lang.String TYPENAME
          Type name ("CHOICE").
 
Fields inherited from class com.davisor.data.DoubleType
DEFAULT
 
Fields inherited from class com.davisor.data.FormatType
M_pattern, M_sample
 
Fields inherited from class com.davisor.data.LocaleType
DEFAULT_LOCALE, M_locale
 
Fields inherited from class com.davisor.data.Type
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS
 
Constructor Summary
  ChoiceType()
          Default constructor.
  ChoiceType(ChoiceType ct)
          Copy constructor.
  ChoiceType(java.lang.String dataName)
          Creates a new default type with no identity.
  ChoiceType(java.lang.String dataName, java.lang.String id, java.util.Map metaData, java.util.Locale locale, java.lang.String pattern, java.lang.Object sample)
          Creates a new choice type.
  ChoiceType(java.lang.String dataName, java.lang.String id, java.lang.String format)
          Creates a new choice data type from a choice pattern.
protected ChoiceType(java.lang.String typeName, java.lang.String dataName, java.lang.String id, java.util.Map metaData, java.util.Locale locale, java.lang.String pattern, java.lang.Object sample)
          Creates a new choice type.
 
Method Summary
protected  java.text.Format createFormatter()
          Creates a new format instance suitable for the purposes of this class.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 float getCompatibility(java.lang.Class type)
          Gets an estimate of how well this type could represent objects of the given class.
 
Methods inherited from class com.davisor.data.DoubleType
decode, encode, equals, getSQLCode, getValueClass, toData, toData, toData, toData
 
Methods inherited from class com.davisor.data.SimpleNumberType
byteValue, byteValue, doubleValue, doubleValue, floatValue, floatValue, intValue, intValue, longValue, longValue, numberValue, shortValue, shortValue, stringValue, stringValue, stringValue, stringValue, stringValue, stringValue, stringValue, zero
 
Methods inherited from class com.davisor.data.FormatType
clearFormatter, getFormat, getFormatter, getPattern, getSample, hashCode, setFormat, setFormat, setLocale, setPattern, setSample
 
Methods inherited from class com.davisor.data.LocaleType
getLocale, setLocale
 
Methods inherited from class com.davisor.data.Type
ceil, check, check, compare, create, create, create, create, create, dup, floor, format, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLName, getSQLName, getTypeName, isNull, parseObject, register, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, toString, toXML, xmlEnd, xmlStart
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPENAME

public static final java.lang.String TYPENAME
Type name ("CHOICE").

See Also:
Constant Field Values
Constructor Detail

ChoiceType

public ChoiceType()
Default constructor.


ChoiceType

public ChoiceType(ChoiceType ct)
Copy constructor.


ChoiceType

public ChoiceType(java.lang.String dataName)
Creates a new default type with no identity.

Parameters:
dataName - data name (may be null)

ChoiceType

public ChoiceType(java.lang.String dataName,
                  java.lang.String id,
                  java.lang.String format)
Creates a new choice data type from a choice pattern. The given pattern will be passed to a new Java ChoiceFormat object that will be used later to format data objects of this type.

This is the constructor the SQL type mapper Type.create(Integer,String,String,String) method will call to create a type that matches given SQL type.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)
format - Java ChoiceFormat choice pattern (may be null)
See Also:
FormatType.setFormat(java.util.Locale, java.lang.String)

ChoiceType

public ChoiceType(java.lang.String dataName,
                  java.lang.String id,
                  java.util.Map metaData,
                  java.util.Locale locale,
                  java.lang.String pattern,
                  java.lang.Object sample)
Creates a new choice type.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)
metaData - type meta data map (may be null)
locale - type locale (may be null)
pattern - format pattern (may be null)
sample - format sample (may be null)

ChoiceType

protected ChoiceType(java.lang.String typeName,
                     java.lang.String dataName,
                     java.lang.String id,
                     java.util.Map metaData,
                     java.util.Locale locale,
                     java.lang.String pattern,
                     java.lang.Object sample)
Creates a new choice type.

Parameters:
typeName - type name
dataName - data name (may be null)
id - type identity (may be null)
metaData - type meta data map (may be null)
locale - type locale (may be null)
pattern - format pattern (may be null)
sample - format sample (may be null)
Method Detail

dup

public com.davisor.core.Dupable dup()
Makes a deep copy of this object.

Specified by:
dup in interface com.davisor.core.Dupable
Overrides:
dup in class DoubleType

createFormatter

protected java.text.Format createFormatter()
Creates a new format instance suitable for the purposes of this class.

Overrides:
createFormatter in class SimpleNumberType
See Also:
FormatType.clearFormatter(), FormatType.getFormatter(), FormatType.setFormat(Locale,String), FormatType.setLocale(Locale), FormatType.setPattern(String)

getCompatibility

public float getCompatibility(java.lang.Class type)
Gets an estimate of how well this type could represent objects of the given class.

Overrides:
getCompatibility in class Type
Parameters:
type - type to estimate
Returns:
0.75 if the given type is assignable from Double, otherwise 0.0.
See Also:
DoubleType.getValueClass()


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.