|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sk.uniba.euromath.document.NodeListID
public final class NodeListID
Represents the nodelist that can be identified by some ID. The list can have more than one node only if:
The node returned by the item()
function may be only one of
the following: element, attribute, text, cdata, comment, processing
instruction. This list shall always contain at least one node.
WARNING! If you add some nodes between the nodes that this list is holding,
these changes are NOT reflected in this object! In such case you have to
re-query the id to get new instance of nodelist, or use the
recover
method. equals()
returns
true
when all nodes they represent are same. Two nodelists may
differ when they represent one ID: if one is queried, the node is inserted
and the second is queried.
Nested Class Summary | |
---|---|
class |
NodeListID.NodePtr
Points into contents of text/cdata/comment/pi node. |
Field Summary | |
---|---|
(package private) DomCore |
doc
The document. |
boolean |
inEntity
If true then all nodes represented by this nodelist are in
some entity. |
Element |
parentElement
'Parent' element of all nodes represented by this list. |
boolean |
parentElementInEntity
If true then parent element itself is in some entity. |
Constructor Summary | |
---|---|
NodeListID(DomPointer start,
DomPointer end,
DomCore doc)
The constructor. |
|
NodeListID(Node node,
DomCore doc)
Contructs the instance that shall contain only given node. |
Method Summary | |
---|---|
(package private) void |
checkDocument(DomCore doc)
Checks if this nodelist points into nodes belonging to given doc. |
boolean |
contains(DomPointer ptr)
Checks if given pointer points inside this nodelist. |
boolean |
equals(Object obj)
|
DomPointer |
getEnd()
Returns the ending pointer marking the end of this nodelist. |
int |
getLength()
Returns number of nodes represented by this nodelist. |
int |
getMaxPos()
Determines the maximum position that can be given as argument to functions. |
int |
getNearestInsertablePos(int pos,
boolean forward)
Computes nearest pos to given pos, that does not point into an entity. |
int |
getNodeIndex(Node node)
Determines the index of the node in the 'item' array. |
NodeListID.NodePtr |
getNodePtr(int pos,
boolean preferNext)
Converts the position in the textValue into node, that holds specified piece. |
int |
getNodeTextEnd(Node node)
Determines the end index of node text in global text value. |
static int |
getNodeTextLength(Node node)
Determines the length of the node text. |
int |
getNodeTextStart(Node node)
Determines the start index of node text in global text value. |
DomPointer |
getPointer(int pos,
boolean preferNext,
boolean preferModifiable)
Converts the position in the textValue into a DOM pointer instance. |
int |
getPos(DomPointer ptr)
From given nodeindex and text position computes the global position (position in the text value). |
int |
getPos(int nodeIndex,
int pos)
From given nodeindex and text position computes the global position (position in the text value). |
EntityReference |
getPrimaryEntity(int index)
Returns primary entity, where the node with given index is positioned. |
EntityReference |
getPrimaryEntity(Node node)
Returns primary entity, where the node is positioned. |
DomPointer |
getStart()
Returns the starting pointer marking the start of this nodelist. |
String |
getTextValue()
Returns the textual value of the node. |
InsertPoint |
getTopLevelIP(int pos)
Computes and returns the toplevel insertpoint (pointing into children of the context element), pointing onto given position in text value. |
int |
hashCode()
|
boolean |
inEntity(int nodeIndex)
Checks if the node with given index is contained in some entity, hence unmodifiable. |
boolean |
isDeletable(int start,
int end)
Checks if text between start and end indexes can be removed. |
boolean |
isPartiallySelectable()
Determines if this nodelist denotes one or more text/cdata nodes, or a single comment node. |
boolean |
isTextual()
Determines if this nodelist denotes one or more text/cdata nodes. |
Node |
item(int index)
Returns node with given index. |
(package private) static NodeListID |
newInstance(Node node,
DomCore doc)
Creates new instance of the nodelist. |
NodeListID |
recover()
Tries to recover from modification of underlying nodes. |
int |
resolveIndex(String transformResult,
int transformIndex)
Tries to resolve the index from given string back to the original string. |
DOMInterval |
toInterval()
Returns this node list as an interval. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final Element parentElement
null
.
final DomCore doc
public final boolean inEntity
true
then all nodes represented by this nodelist are in
some entity. If false
then some nodes may not be in an
entity, however there is a possibility that all nodes are in some
entity(ies).
public final boolean parentElementInEntity
true
then parent element itself is in some entity. If
true
then inEntity
is true
aswell. If there is no parent element then this value is
false
.
Constructor Detail |
---|
NodeListID(Node node, DomCore doc)
node
- the node.doc
- reference to the document.NodeListID(DomPointer start, DomPointer end, DomCore doc)
start
- the start of the range. The node where start points is
included in result set.end
- the end of the range. The node where end points is excluded.doc
- the instance of the document.Method Detail |
---|
static NodeListID newInstance(Node node, DomCore doc)
node
- the nodedoc
- the instance of the document.
public int getLength()
getLength
in interface NodeList
public Node item(int index)
item
in interface NodeList
null
if index is outside
valid range.public boolean isTextual()
true
if the list consists of text/cdata nodes,
false
otherwise.public boolean isPartiallySelectable()
true
if the list consists of text/cdata
nodes/comment node, false
otherwise.public String getTextValue()
null
in case
of element.public DomPointer getPointer(int pos, boolean preferNext, boolean preferModifiable)
pos
- the position in the textValue
string.preferNext
- if true and the pos points between adjacent text nodes,
then prefer next node.preferModifiable
- if pos points between adjacent text nodes then
prefer the one that is modifiable. It has higher priority than
preferNext
and it may even find a pointer that does not
point to none of these two nodes - it is the case when there are two
adjacent text entities, in such case the pointer shall point between
these two entities. However, if no place is suitable for inserting text
then this parameter has no meaning and will be ignored - the pointer
shall always point into one of the text nodes picked by the
preferNext
argument.
public DomPointer getStart()
public DomPointer getEnd()
public boolean contains(DomPointer ptr)
ptr
- pointer to check
true
if the pointer points inside this nodelist,
false
otherwise.public DOMInterval toInterval()
public InsertPoint getTopLevelIP(int pos)
null
. Applicable only to textual list.
pos
- the position in the textValue
string.
null
if no such
insertpoint exists.public NodeListID.NodePtr getNodePtr(int pos, boolean preferNext)
pos
- the position in the textValue
string.preferNext
- if pos points into the boundary between two text nodes,
then prefer the next one.
public int getMaxPos()
public int getPos(int nodeIndex, int pos)
nodeIndex
- the index of the ID-level node (into the 'item'
getfunction).pos
- position in the text of the node
public int getPos(DomPointer ptr)
ptr
- pointer to check
-1
if the pointer does not
point inside the node list.public int getNodeTextStart(Node node)
node
- the node to check.
getTextValue
where the text contained
in given node starts.public int getNodeTextEnd(Node node)
node
- the node to check.
getTextValue
where the text contained
in given node starts.public static int getNodeTextLength(Node node)
node
- the node to check.
public int getNodeIndex(Node node)
node
- the node.
-1
if
node haven't been found.public boolean isDeletable(int start, int end)
start
- start indexend
- end index
public boolean inEntity(int nodeIndex)
nodeIndex
- the node index
public int getNearestInsertablePos(int pos, boolean forward)
pos
- the starting position in global text.forward
- if true then scan goes forward.
public EntityReference getPrimaryEntity(int index)
index
- index of the node
null
if the node is not in an
entity or the context element is itself in an entity.public EntityReference getPrimaryEntity(Node node)
node
- the node
null
if the node is not in an
entity or the context element is itself in an entity.public String toString()
toString
in class Object
public NodeListID recover()
null
if recovery was unsuccesfull (all old nodes are
removed from the document).public int resolveIndex(String transformResult, int transformIndex)
transformResult
- the result of the transformationtransformIndex
- index into the transformResult
string.
textValue
, always within the range
of the textValue.public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
void checkDocument(DomCore doc)
doc
- the document.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |