com.davisor.data
Class TuplePatternType

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.TupleType
                      extended bycom.davisor.data.TuplePatternType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable

public class TuplePatternType
extends TupleType

TuplePatternType defines an advanced tuple member re-arrangement tool that can reorganize tuple data objects with unknown content to tuple data objects with well-known content. Mapping supports members that match the given single target types, and member groups that match the given target type patterns.

Since:
JDK1.1
See Also:
create(int[]), getTypeIndexMap(com.davisor.data.TupleType), TupleData, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
 
Fields inherited from class com.davisor.data.TupleType
M_additionalValues, M_keys, TYPENAME
 
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
  TuplePatternType(java.lang.String dataName, java.lang.String id, int size, int patterns)
          Creates a new tuple data type of the given number of subtypes.
protected TuplePatternType(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, Type[] types, java.util.Map ids, Type[] patterns)
          Creates a new tuple type.
  TuplePatternType(TuplePatternType tpt)
          Deep copy constructor.
 
Method Summary
 TupleType create(int[] map)
          Creates a new tuple type that can re-arrange tuple data objects as described by this tuple pattern and given index map.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 java.lang.String getFormat()
          Gets the pattern tuple customization string.
 Type getPatternType(int index)
          Gets the tuple member pattern type by index.
 int[] getTypeIndexMap(TupleType type)
          Creates a two part index map that maps the elements of the given tuple type to the elements of this type.
 void setPattern(int index, Type type)
          Sets the tuple pattern member type.
 
Methods inherited from class com.davisor.data.TupleType
containsKey, createFormatter, equals, getAdditionalValues, getId, getID, getIndex, getMaxDepth, getSize, getSQLCode, getType, getType, getTypeIndex, getTypeIndex, getTypeIndex, getTypeIndex, getTypeIndexes, getTypeIndexes, getValueClass, hashCode, isNumber, keySet, rearrange, setAdditionalValues, setFormat, setType, toData, toData, toData, toData, toString, zero
 
Methods inherited from class com.davisor.data.FormatType
clearFormatter, getFormatter, getPattern, getSample, 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, getCompatibility, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLName, getSQLName, getTypeName, isNull, parseObject, register, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, 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
 

Constructor Detail

TuplePatternType

public TuplePatternType(TuplePatternType tpt)
Deep copy constructor.


TuplePatternType

public TuplePatternType(java.lang.String dataName,
                        java.lang.String id,
                        int size,
                        int patterns)
Creates a new tuple data type of the given number of subtypes.

Parameters:
dataName - data name
id - type identity
See Also:
Type.setFormat(java.lang.String)

TuplePatternType

protected TuplePatternType(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,
                           Type[] types,
                           java.util.Map ids,
                           Type[] patterns)
Creates a new tuple type.

Parameters:
typeName - type name
dataName - data name
id - type identity
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)
types - member types
ids - member identities
patterns - type patterns
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 TupleType

create

public TupleType create(int[] map)
Creates a new tuple type that can re-arrange tuple data objects as described by this tuple pattern and given index map. The map is assumed to have been created with the getTypeIndexMap method. The map has two parts: the first tells how certain tuple data object members are to be re-arranged so that their order will match the members of this type. The second part of the map tells how the tuple data object members are to be re-arranged so that they match the type patterns described by this object.

The method will return a new ordinary tuple type that represents the combined result of element and pattern mapping. Furthermore, the mapping table is modified so that it can be directly used with the new type and it's rearrange method.

See Also:
getTypeIndexMap(com.davisor.data.TupleType), TupleType.rearrange(TupleData,int [])

getPatternType

public Type getPatternType(int index)
Gets the tuple member pattern type by index.

Throws:
java.lang.ArrayIndexOutOfBoundsException - if the given index does not match any member.
See Also:
TupleType.getType(java.lang.String), TupleType.setType(int, com.davisor.data.Type)

getTypeIndexMap

public int[] getTypeIndexMap(TupleType type)
Creates a two part index map that maps the elements of the given tuple type to the elements of this type. For the first N elements, where N is the size of this tuple, a map value map[n] tells which element in another tuple would match element n in this tuple. A negative value indicates that there was no match.

After the first N map elements, another map follows that tells with which pattern types that the elements in the given type would match. Unlike normal elements, several elements may match the to given pattern type. The resulting map can be used to construct a replacing type that actually has all the members that the given tuple members would match.

Mapping is based on type names only, not type equality or general compatibility. Operations that assign elements in this tuple to the elements of the target tuple are expected to arrange suitable type conversions.

The primary use for the returned map is to create a new tuple type object that can re-arrange tuple data objects of the given type to tuple data objects described by this type. Please see the create method for more information.

Overrides:
getTypeIndexMap in class TupleType
See Also:
create(int[]), TupleType.getTypeIndex(java.lang.String), TupleType.rearrange(com.davisor.data.TupleData, int[])

setPattern

public void setPattern(int index,
                       Type type)
Sets the tuple pattern member type.

Parameters:
index - the index of the new pattern member type
type - the new pattern type (may be null)
See Also:
TupleType.setType(int, com.davisor.data.Type)

getFormat

public java.lang.String getFormat()
Gets the pattern tuple customization string. The customization string equals the ordinary tuple customization string followed by pattern type encodes within parenthesis and separated by white space.

Overrides:
getFormat in class TupleType
Returns:
Tuple type specification string.
See Also:
TupleType.getFormat()


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