com.davisor.data
Class TypeList

java.lang.Object
  extended bycom.davisor.util.IndirectCollection
      extended bycom.davisor.util.IndirectList
          extended bycom.davisor.data.TypeList
All Implemented Interfaces:
java.util.Collection, java.util.List

public class TypeList
extends com.davisor.util.IndirectList

TypeList provides a tool to constuct type lists and hierarcies incrementally, one type and sub-type at a time. This functionality is usefull for example when type definitions are build from XML SAX events.

Since:
JDK1.1
See Also:
IntegerSequence, TupleType

Nested Class Summary
protected static class TypeList.State
          Tuple construction state.
 
Field Summary
protected  java.util.Iterator M_idFactory
           
protected  java.util.Set M_ids
          Current set of type identities.
protected  java.util.Stack M_stack
          Current state stack.
protected  TypeList.State M_state
          Current state.
 
Fields inherited from class com.davisor.util.IndirectCollection
M_collection
 
Constructor Summary
TypeList()
          Default constructor.
TypeList(java.util.Iterator idFactory)
          Creates a new type list that uses given sequence to generate type identities.
TypeList(java.util.List types)
          Creates a new type list that collects types into given list instance.
TypeList(java.util.List types, java.util.Iterator idFactory)
          Creates a new type list that collects types into given list and identity factory instances.
 
Method Summary
 void add(int index, java.lang.Object type)
          Adds a type to a spesific place in currently open tuple type, or among to top-level types.
 boolean add(java.lang.Object type)
          Adds a type to currently open tuple type, or among to top-level types.
 void add(Type type, java.util.Set ids)
          Adds given type identity to given identity set.
 boolean addAll(java.util.Collection collection)
          Adds all element in an another collection into this collection.
 boolean addAll(int index, java.util.Collection c)
          Adds all element in an another collection into this collection.
 TupleType endTupleType()
          Completes current tuple type.
 void startTupleType(java.lang.String dataName, java.lang.String id, java.lang.String metaName, java.lang.String metaGroup)
          Starts building a new tuple type.
 
Methods inherited from class com.davisor.util.IndirectList
get, indexOf, lastIndexOf, listIterator, listIterator, remove, set, subList
 
Methods inherited from class com.davisor.util.IndirectCollection
clear, contains, containsAll, getCollection, isEmpty, iterator, remove, removeAll, retainAll, setCollection, size, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Field Detail

M_state

protected transient TypeList.State M_state
Current state.


M_stack

protected transient java.util.Stack M_stack
Current state stack.


M_ids

protected transient java.util.Set M_ids
Current set of type identities.


M_idFactory

protected java.util.Iterator M_idFactory
Constructor Detail

TypeList

public TypeList()
Default constructor.


TypeList

public TypeList(java.util.Iterator idFactory)
Creates a new type list that uses given sequence to generate type identities.

Parameters:
idFactory - type identity generator

TypeList

public TypeList(java.util.List types)
Creates a new type list that collects types into given list instance.

Parameters:
types - the list into which top-level types are to be collected

TypeList

public TypeList(java.util.List types,
                java.util.Iterator idFactory)
Creates a new type list that collects types into given list and identity factory instances.

Parameters:
types - the list into which top-level types are to be collected
idFactory - type identity generator
Method Detail

add

public boolean add(java.lang.Object type)
Adds a type to currently open tuple type, or among to top-level types. In particular, if this method is called between calls to startTupleType(java.lang.String, java.lang.String, java.lang.String, java.lang.String) and endTupleType() method, the type is added amont the current tuple type being defined. Otherwise the type is added to the list of top-level types.

The identity of the given type must be unique within the context the type is added in. In particular, if the type is a top-level type, no other top-level type must have equal identity. Likewise, if the type is a sub-level type, no other sub-level type in the current open tuple must have equal identity.

If the given type has no identity, a new identity is assigned to it using current identity factory. The newly generated identity must however still meet the identity uniqueness requiremenet. If it does not, the given type keeps it's new identity, but the type itself is rejected from this type list.

If the given type is added inside an open tuple type, type METADATA_PARENT value is set to a string composed from type parent and grantparent type identities.

Parameters:
type - type to be added (must be an instance of Type
Returns:
true if this collection changed as a result of the call
Throws:
java.lang.IllegalArgumentException - if given type is invalid
See Also:
add(Type,Set), endTupleType(), startTupleType(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

addAll

public boolean addAll(java.util.Collection collection)
Adds all element in an another collection into this collection.

Returns:
true if this collection changed as a result of the call

add

public void add(int index,
                java.lang.Object type)
Adds a type to a spesific place in currently open tuple type, or among to top-level types. In particular, if this method is called between calls to startTupleType(java.lang.String, java.lang.String, java.lang.String, java.lang.String) and endTupleType() method, the type is added amont the current tuple type being defined. Otherwise the type is added to the list of top-level types.

If the given type is added inside an open tuple type, type METADATA_PARENT value is set to a string composed from type parent and grantparent type identities.

Parameters:
index - the position to add the new type
type - type to be added (must be an instance of Type
Throws:
java.lang.IllegalArgumentException - if type is not an instance of Type
See Also:
endTupleType(), startTupleType(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Adds all element in an another collection into this collection.

Returns:
true if this collection changed as a result of the call

add

public void add(Type type,
                java.util.Set ids)
Adds given type identity to given identity set. The identity set must not already contain the given identity.

If the given type has no identity, a new identity is assigned to it using current identity factory. The newly generated identity must however still meet the identity uniqueness requirement. If it does not, the given type keeps it's new identity, but the type itself is rejected.

Parameters:
type - type to add
ids - identity set
Throws:
java.lang.IllegalArgumentException - if identity is not unique

endTupleType

public TupleType endTupleType()
Completes current tuple type. A completed top-level tuple type is also added into the current list of top-level types.

Returns:
the tuple type just created
Throws:
java.lang.IllegalStateException - if no tuple is currently open
See Also:
add(Object), startTupleType(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

startTupleType

public void startTupleType(java.lang.String dataName,
                           java.lang.String id,
                           java.lang.String metaName,
                           java.lang.String metaGroup)
Starts building a new tuple type. New types can now be added to this type by calling add(Object) and this method. In particular, each call to this method recursviely opens a new tuple type inside the previous one.

To eventually finish the type now opened and to get a reference to it, call endTupleType(). To add types to the open tuple, call add(Object). To add a TupleType inside another, call this method again.

See Also:
add(Object), endTupleType()


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