|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.uniba.euromath.document.DomPointer
public final class DomPointer
Represents immutable pointer to contents of document. It always points between nodes (if there are any). The following is true:
beforePoints and pointsTo is null if and
only if parent doesn't have any child elements.
DomPointerFlag flags define behaviour of getNext,
getPrevious,getNearest,
getFirst and getLast functions. By default,
when no flags are specified then any insertpoint will do. These flags specify
restrictions on returned pointer.
Warning! Tests for equality and comparing pointers may seem inconsistent: If one pointer is pointing after the last character of the text node and second pointer points right after this text node having pos parameter equal to zero, then it seems that these two pointers are pointing at same position in the document however they are not equal. In such case try normalization and/or entity skipping.
The pointer can be compared only to pointers pointing into same tree.
Comparing disconnected pointers (for example pointing into two different
fragments) is disallowed and results in IllegalArgumentException.
| Field Summary | |
|---|---|
Node |
beforePoints
Pointer points right after this node. |
String |
beforePointsId
Id of node, after which pointer points. |
(package private) DomCore |
doc
Reference to document. |
InsertPoint |
ip
InsertPoint representation of pointer. |
Node |
parent
Pointer points to contents of this node. |
Node |
parentContainer
Pointer points to contents of this container - an ID-level node holder; it is never an entity reference, for example. |
Element |
parentElement
Pointer points to contents of this element. |
String |
parentElementId
Pointer points to contents of this element. |
String |
parentId
Id of parent element (the element, to which contents the pointer points). |
Node |
pointsTo
Pointer points to (before) this node. |
String |
pointsToId
Holds id of node, where the pointer points. |
| Constructor Summary | |
|---|---|
DomPointer(DomCore doc,
Node parent,
InsertPoint ip,
ElementRule parentElementRule,
Boolean inEntity)
Constructs instance of pointer. |
|
| Method Summary | |
|---|---|
int |
compareTo(Object obj)
|
boolean |
createsText(short type)
Queries, whether creating text at this point really creates a new text node, or it merely modifies corresponding adjacent node. |
boolean |
descendsFrom(Node node)
Checks, whether this pointer points into contents of given node. |
boolean |
equals(Object obj)
|
Document |
getDocument()
Returns the document where the pointer points. |
DomPointer |
getNext(EnumSet<DomPointerFlag> ptrFlags,
boolean canReturnSelf,
boolean dontGoIntoElements)
Returns pointer to next node, in Document order ordering (as if serialized, see W3C definition). |
DomPointer |
getNextSibling()
Creates new instance of pointer, that points to next node. |
(package private) ElementRule |
getParentElementRule()
Caches and returns rule for parent element. |
DomPointer |
getPrevious(EnumSet<DomPointerFlag> ptrFlags,
boolean canReturnSelf,
boolean dontGoIntoElements)
Returns pointer to previous node in Document order ordering (as if serialized, see W3C definition). |
DomPointer |
getPreviousSibling()
Creates new instance of pointer, that points to the beforePoints node. |
int |
hashCode()
|
boolean |
inEntity()
Queries if this pointer points into contents of, or a descendant of an EntityReference node. |
boolean |
isPointingIntoText()
Checks if this pointer points into a text node. |
DomPointer |
normalize()
Normalizes the pointer. |
DomPointer |
skipFromEntities()
Skips forwards and backwards out from entities as much as possible. |
DomPointer |
skipFromEntities(boolean forward)
Tries to skip out of entities as much as possible. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final Node parent
null. May
be instance of Element,EntityReference,
Document and DocumentFragment.
public final String parentId
null only if this parent is not an element.
public final Element parentElement
null in
case when there is no parent element (pointer points onto root element,
into child of document fragment etc). If parent is
Element node then this value represents same instance as
parent.
public final String parentElementId
null if
and only if parentElement is null. If
parent is Element node then this value is
equal to parentId.
public final Node parentContainer
null.
It is equal to parentElement if it is not
null. If parentElement is
null then this container is a Document or document
fragment instance.
public final InsertPoint ip
InsertPoint representation of pointer.
public final Node pointsTo
null.
public final String pointsToId
null if
and only if pointsTo is null or
pointsTo cannot have ID (EntityReference
node, for example).
public final Node beforePoints
pointsTo node. It can be null - then pointer points at the
start of node sequence.
public final String beforePointsId
null if and
only if beforePoints is null or
beforePoints cannot have ID (EntityReference
node, for example).
final DomCore doc
null: in that case the
PTR_INSERT_TEXT and PTR_INSERT_ELEMENT
cannot be used.
| Constructor Detail |
|---|
DomPointer(DomCore doc,
Node parent,
InsertPoint ip,
ElementRule parentElementRule,
Boolean inEntity)
doc - the document instance. It may be null: then
parentId,pointsToId,
beforePointsId and getParentElementRule()
will always be null, and PTR_INSERT_TEXT
and PTR_INSERT_ELEMENT will be ignored.parent - Pointer points to contents of this element. It must not be
null. It may be element, entity reference, document or
document fragment node.ip - insertpoint, where the pointer points.parentElementRule - rule for parent. If null, it
will be computed when needed.inEntity - if this pointer points into an entity. If
null, it will be computed when needed.| Method Detail |
|---|
ElementRule getParentElementRule()
public DomPointer getNext(EnumSet<DomPointerFlag> ptrFlags,
boolean canReturnSelf,
boolean dontGoIntoElements)
ptrFlags - flags, that must result pointer comply.canReturnSelf - if false then the pointer returned
must not be equal to this pointer.dontGoIntoElements - if true then the algorithm may
leave an element but it may never enter an element and enumerate its
content.
this if PTR_CAN_RETURN_SELF is specified.
If null, then there is no such next node.public DomPointer getNextSibling()
public DomPointer getPreviousSibling()
beforePoints node. If this pointer points to start of
nodelist, then returns null.
public DomPointer getPrevious(EnumSet<DomPointerFlag> ptrFlags,
boolean canReturnSelf,
boolean dontGoIntoElements)
ptrFlags - flags, that must result pointer comply.canReturnSelf - if false then the pointer returned
must not be equal to this pointer.dontGoIntoElements - if true then the algorithm may
leave an element but it may never enter an element and enumerate its
content.
this if PTR_CAN_RETURN_SELF is
specified. If null, then there is no such previous node.public boolean createsText(short type)
type - desired type of new node, one of Node.TEXT_NODE
or Node.CDATA_SECTION_NODE values.
public boolean inEntity()
EntityReference node. It also means that these contents
are unmodifiable.
EntityReference node.public boolean descendsFrom(Node node)
node - node to check.
true if it points into children of given node or
into children of descendant of the node.public boolean equals(Object obj)
equals in class Objectpublic int compareTo(Object obj)
compareTo in interface Comparablepublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectpublic DomPointer skipFromEntities(boolean forward)
IdDomMapper for details)].
forward - if try to move from entity backwards or forwards.
this. If forward then the pointer
shall point right after the entity node (if available). If backwards then
the pointer points onto the entity node (if available).public DomPointer skipFromEntities()
this, nearest to the
root.public DomPointer normalize()
ip.pos is
checked and if it points after the last character of the text node then
returned pointer shall point to next node.
this is returned.public Document getDocument()
null.
public boolean isPointingIntoText()
true if this pointer points onto a text node,
false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||