biz.c24.io.api.data
Class UnionDataType

java.lang.Object
  extended by biz.c24.io.api.data.DataType
      extended by biz.c24.io.api.data.SimpleDataType
          extended by biz.c24.io.api.data.UnionDataType
All Implemented Interfaces:
ModelComponent, Serializable

public class UnionDataType
extends SimpleDataType

A simple data type representing a union of other simple data types.

For example, this type may be used to represent an integer or a string.

Note, the order in which the member types are added is important. In the above example, if the string was the first member type to be added then all data would be interpreted as strings. This is because the string type is wider than the integer type. In other words narrower member types must be added first.

Warning: Serialized objects of this class or of a deployed class which is derived from it may not be compatible with future releases of C24 Integreation Objects. The current serialization support is appropriate for short term storage or RMI between applications running the same version of C24 Integreation Objects.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class biz.c24.io.api.data.DataType
duringParsing, hasEnumerations, hasPatternMatching, qualifierValidation
 
Constructor Summary
UnionDataType()
          Constructs a new instance.
 
Method Summary
 void addMemberType(SimpleDataType memberType)
          Adds a member type.
 String formatObject(Object obj, boolean external)
          Formats the supplied obj into a string.
 int getMaxSize()
          Returns the maximum allowable size out of all the member types.
 SimpleDataType getMemberType(int index)
          Return the member type at index.
 int getMemberTypeCount()
          Returns the number of member types that have been added.
 int getMinSize()
          Returns the minimum allowable size out of all the member types.
 Class getValidObjectClass()
          Returns the class of valid objects of this type.
 boolean isValidObjectClass(Class c)
          Returns whether c is the class of a valid object of this type.
 Object parseObject(String str, boolean external)
          Parses str into an object derived from on of the member types.
 void removeMemberType(int index)
          Removes a member type.
 
Methods inherited from class biz.c24.io.api.data.SimpleDataType
formatObject, formatObjectExternal, getInstance, getMaxExclusive, getMaxInclusive, getMinExclusive, getMinInclusive, isComplex, isSimple, isSizeFixed, parseObject, parseObjectExternal, setMaxExclusive, setMaxInclusive, setMinExclusive, setMinInclusive, validateProperties
 
Methods inherited from class biz.c24.io.api.data.DataType
addDerivedType, addValidator, addValidator, derivedTypeKeySet, getAnnotation, getDatabaseColumnName, getDerivedType, getDerivedType, getDerivedTypes, getDescription, getEnumeration, getInitiator, getModel, getName, getNullDefiningElementDecl, getOriginalName, getOriginalPatternMatch, getPatternMatch, getPatternType, getTerminator, getValidator, getValidatorCount, getValidatorIndex, hasDerivedTypes, isLocal, removeDerivedType, removeValidator, setAnnotation, setDatabaseColumnName, setInitiator, setLocal, setModel, setName, setOriginalName, setOriginalPatternMatch, setPatternMatch, setPatternType, setTerminator, toString, validate, validateProperties, validateProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnionDataType

public UnionDataType()
Constructs a new instance.

Method Detail

getMemberTypeCount

public int getMemberTypeCount()
Returns the number of member types that have been added.

Returns:
The number of member types.

getMemberType

public SimpleDataType getMemberType(int index)
Return the member type at index.

Parameters:
index - The index of the member type to be retrieved.
Returns:
The member type at index.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= getNamespaceCount()).

addMemberType

public void addMemberType(SimpleDataType memberType)
Adds a member type.

Parameters:
memberType - The new value.
Throws:
NullPointerException - if memberType is null.

removeMemberType

public void removeMemberType(int index)
Removes a member type.

Parameters:
index - The index of the member type to be removed.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= getMemberTypeCount()).

getValidObjectClass

public Class getValidObjectClass()
Description copied from class: DataType
Returns the class of valid objects of this type.

Overrides:
getValidObjectClass in class SimpleDataType
Returns:
The class.

isValidObjectClass

public boolean isValidObjectClass(Class c)
Description copied from class: DataType
Returns whether c is the class of a valid object of this type.

Overrides:
isValidObjectClass in class DataType
Parameters:
c - The class.
Returns:
Whether it is valid or not.

getMinSize

public int getMinSize()
Returns the minimum allowable size out of all the member types.

Overrides:
getMinSize in class SimpleDataType
Returns:
The minimum size.

getMaxSize

public int getMaxSize()
Returns the maximum allowable size out of all the member types.

Overrides:
getMaxSize in class SimpleDataType
Returns:
The maximum size or -1 if the size is unbounded.

parseObject

public Object parseObject(String str,
                          boolean external)
                   throws ParserException
Parses str into an object derived from on of the member types.

The member types are examined in order (starting at index 0) until one is found which is capable of parsing str.

Overrides:
parseObject in class SimpleDataType
Parameters:
str - The string to be parsed.
external - Whether the overrideable parse method may be used.
Returns:
The object.
Throws:
ParserException - If the parsing failed.

formatObject

public String formatObject(Object obj,
                           boolean external)
Formats the supplied obj into a string.

Overrides:
formatObject in class SimpleDataType
Parameters:
obj - The object to be formatted.
external - Whether the overrideable format method may be used.
Returns:
The string.
Throws:
IllegalArgumentException - if the class of obj is not recognised by any of the member types.


C24 Technologies © 2002-2012: All Rights Reserved.