sk.uniba.euromath.document.schema.impl.iterator
Class SchemaLevelNodeIteratorBuilder

java.lang.Object
  extended by sk.uniba.euromath.document.schema.impl.iterator.SchemaLevelNodeIteratorBuilder
Direct Known Subclasses:
IteratorBuilder

public class SchemaLevelNodeIteratorBuilder
extends Object

Simple builder for the SchemaLevelNodeIterator object. Introduces several useful methods for overriding builders.

Author:
Martin Vysny

Field Summary
static ContentFilter FILTER_ACCEPT_ALL
          Filter that accepts all pointer infos.
 
Constructor Summary
SchemaLevelNodeIteratorBuilder()
           
 
Method Summary
protected static List<ContentInfo> computeItems(Node parent, ContentFilter filter, SortedSet<sk.baka.ikslibs.ptr.DOMPoint> forceIPs, boolean lastEmptyItem)
          Computes the list of items, that will be iterated.
static SchemaLevelNodeIterator createIterator(Collection<ContentInfo> items)
          Creates simple iterator iterating over given items.
static SchemaLevelNodeIterator createIterator(Node parent, boolean lastItemEmpty)
          Creates simple iterator, with no force insertpoints and no filter.
static SchemaLevelNodeIterator createIterator(Node parent, sk.baka.ikslibs.ptr.DOMPoint ip, ContentFilter filter)
          Creates simple iterator, with last empty item.
static SchemaLevelNodeIterator createIterator(Node parent, SortedSet<sk.baka.ikslibs.ptr.DOMPoint> forceIPs, ContentFilter filter, boolean lastEmptyItem)
          Creates instance of iterator, that walks over insertpoints of children of given element.
static SchemaLevelNodeIterator createWithDeleted(sk.baka.ikslibs.interval.DOMInterval interval)
          Pretends that there are nodes cut from the node sequence.
static SchemaLevelNodeIterator createWithInserted(Element parent, sk.baka.ikslibs.ptr.DOMPoint ip, ContentInfo ci)
          Pretends that there is given node inserted at given insertpoint.
static SchemaLevelNodeIterator createWithInserted(Element parent, sk.baka.ikslibs.ptr.DOMPoint ip, List<ContentInfo> items)
          Pretends that there is given node inserted at given insertpoint.
static SchemaLevelNodeIterator createWithInserted(Element parent, sk.baka.ikslibs.ptr.DOMPoint ip, Node node)
          Pretends that there is given node inserted at given insertpoint.
static SchemaLevelNodeIterator createWithInserted(Element parent, sk.baka.ikslibs.ptr.DOMPoint ip, String text)
          Pretends that there is some text inserted at given insertpoint.
protected static void normalize(List<ContentInfo> items)
          Normalizes the items by merging all adjacent text ContentInfo together.
protected static int search(List<ContentInfo> list, sk.baka.ikslibs.ptr.DomPointer ptr)
          Search with given pointer in list of insertpoints.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILTER_ACCEPT_ALL

public static final ContentFilter FILTER_ACCEPT_ALL
Filter that accepts all pointer infos.

Constructor Detail

SchemaLevelNodeIteratorBuilder

public SchemaLevelNodeIteratorBuilder()
Method Detail

createIterator

public static SchemaLevelNodeIterator createIterator(Node parent,
                                                     boolean lastItemEmpty)
Creates simple iterator, with no force insertpoints and no filter.

Parameters:
parent - the node whose children have to be iterated.
lastItemEmpty - if true then last item is a pointer that points after the last node.
Returns:
iterator instance.

createIterator

public static SchemaLevelNodeIterator createIterator(Node parent,
                                                     sk.baka.ikslibs.ptr.DOMPoint ip,
                                                     ContentFilter filter)
Creates simple iterator, with last empty item.

Parameters:
parent - the node whose children have to be iterated.
ip - the one forced insert point
filter - the filter
Returns:
iterator instance.

createIterator

public static SchemaLevelNodeIterator createIterator(Node parent,
                                                     SortedSet<sk.baka.ikslibs.ptr.DOMPoint> forceIPs,
                                                     ContentFilter filter,
                                                     boolean lastEmptyItem)
Creates instance of iterator, that walks over insertpoints of children of given element.

Parameters:
parent - iterates through insertpoints in children nodes of this node.
forceIPs - forces these insertpoints to be part of insertpoints returned by this iterator. If denotes CharacterData node, then iterator acts if this text node was splitted into two adjacent chardata nodes with this insertpoint inbetween them. Otherwise, it is ignored. It may be null or an empty set - then it is ignored. All invalid forceIPs are automatically deleted from the set.
filter - the node filter that is used by the computeItems() function to specify which nodes will occur in the items list. All Text, CDATASection and Element are reported to this filter. If null then the default filter, accepting all nodes, is returned.
lastEmptyItem - if true then last item is a pointer that points after the last node (if this ptrinfo is not rejected by the filter).
Returns:
iterator instance.

createIterator

public static SchemaLevelNodeIterator createIterator(Collection<ContentInfo> items)
Creates simple iterator iterating over given items.

Parameters:
items - collection of ContentInfo.
Returns:
the iterator.

computeItems

protected static List<ContentInfo> computeItems(Node parent,
                                                ContentFilter filter,
                                                SortedSet<sk.baka.ikslibs.ptr.DOMPoint> forceIPs,
                                                boolean lastEmptyItem)
Computes the list of items, that will be iterated.

Parameters:
parent - the parent node, may be element, document, entity and document fragment.
filter - filter that filters out the nodes. All Text, CDATASection and Element are reported to this filter. If null then the default filter accepting all nodes is used.
forceIPs - Forced insert points. It can be poin into the chardata node - then the walker must act as if this cdata node was split into two adjacent chardata nodes with this insertpoint inbetween them. It always points into children of given parent - it can never point into contents of entity reference node. May be null- in such case no force points are used.
lastEmptyItem - if true then last item is a pointer that points
Returns:
list of ContentInfo objects.

search

protected static final int search(List<ContentInfo> list,
                                  sk.baka.ikslibs.ptr.DomPointer ptr)
Search with given pointer in list of insertpoints.

Parameters:
list - sorted list of contentinfos
ptr - pointer to find.
Returns:
binarySearch result.
See Also:
Arrays.binarySearch(java.lang.Object[], java.lang.Object)

normalize

protected static void normalize(List<ContentInfo> items)
Normalizes the items by merging all adjacent text ContentInfo together.

Parameters:
items - list of ContentInfos.

createWithInserted

public static SchemaLevelNodeIterator createWithInserted(Element parent,
                                                         sk.baka.ikslibs.ptr.DOMPoint ip,
                                                         Node node)
Pretends that there is given node inserted at given insertpoint. Entities, Entity reference and document fragment nodes are properly resolved.

Parameters:
parent - the parent node where the node should be inserted
ip - the point where the node must be inserted
node - the node that shall be inserted at given point
Returns:
the iterator

createWithInserted

public static SchemaLevelNodeIterator createWithInserted(Element parent,
                                                         sk.baka.ikslibs.ptr.DOMPoint ip,
                                                         List<ContentInfo> items)
Pretends that there is given node inserted at given insertpoint. Entity reference and document fragment nodes are properly resolved.

Parameters:
parent - the parent node where the node should be inserted
ip - the point where the node must be inserted
items - list of ContentInfo that shall be inserted at given point. All pointers in this list must be equal to the (parent, ip) pointer.
Returns:
the iterator

createWithInserted

public static SchemaLevelNodeIterator createWithInserted(Element parent,
                                                         sk.baka.ikslibs.ptr.DOMPoint ip,
                                                         ContentInfo ci)
Pretends that there is given node inserted at given insertpoint. Entity reference and document fragment nodes are properly resolved.

Parameters:
parent - the parent node where the node should be inserted
ip - the point where the node must be inserted
ci - the ContentInfo instance that shall be inserted at given point
Returns:
the iterator

createWithInserted

public static SchemaLevelNodeIterator createWithInserted(Element parent,
                                                         sk.baka.ikslibs.ptr.DOMPoint ip,
                                                         String text)
Pretends that there is some text inserted at given insertpoint.

Parameters:
parent - the parent node where the node should be inserted
ip - the point where the node must be inserted
text - the text that shall be inserted at given position
Returns:
the iterator

createWithDeleted

public static SchemaLevelNodeIterator createWithDeleted(sk.baka.ikslibs.interval.DOMInterval interval)
Pretends that there are nodes cut from the node sequence. This 'cut' interval is specified with two pointers. These two pointers must point into same element.

Parameters:
interval - the interval
Returns:
the iterator


Copyright © 2003-2006 null. All Rights Reserved.