|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sk.baka.ikslibs.interval.DOMIntervalSet
public final class DOMIntervalSet
An ordered set of disjunctive non-empty intervals. Mutable, thread unsafe.
References live instance of the document - the interval may become invalid when the document is changed.
Constructor Summary | |
---|---|
DOMIntervalSet()
Constructs an empty set. |
|
DOMIntervalSet(DOMInterval interval)
Constructs set with one item. |
|
DOMIntervalSet(DOMIntervalSet other)
Copy-constructor. |
Method Summary | |
---|---|
void |
clear()
Removes all intervals from this set. |
DocumentFragment |
cloneContents(Node factoryReference)
The 'copy' operation. |
DOMIntervalSet |
complement(Node root,
IDManager idManager,
MutableReference<List<IDSelectionAction>> actions)
Inverts the interval set - all nodes that were not part of the set will become contents of the set and vice versa. |
boolean |
contains(DOMInterval interval)
Checks if this set fully covers given interval. |
void |
deleteContents(boolean deleteEmptyNode)
The 'delete' operation. |
boolean |
equals(Object obj)
|
DocumentFragment |
extractContents(Node factoryReference,
boolean deleteEmptyNode)
The 'cut' operation. |
IntervalOrInsertPoint |
findIntervalOrInsertPoint(DomPointer ptr)
Finds index of interval that contains given pointer, or an insert point where interval starting with given pointer would be inserted. |
Set<String> |
getContentIds(IDManager idManager)
Returns set of IDs, covered (partially) by some interval(s). |
List<Node> |
getContents()
Returns set of IDs, covered (partially) by some interval(s) contained in this interval set. |
List<DOMInterval> |
getIntervals()
Returns an list of all intervals. |
int |
hashCode()
|
DOMIntervalSet |
intersect(DOMInterval interval,
MutableReference<DOMIntervalSet> diff)
Intersects given interval with this set. |
DOMIntervalSet |
intersect(DOMIntervalSet other,
MutableReference<DOMIntervalSet> diff)
Intersects given set with this set. |
DOMIntervalSet |
invert(DOMInterval other)
Inverts intervals covered by given interval. |
DOMIntervalSet |
invert(DOMIntervalSet other)
Inverts intervals covered by the 'other' set. |
boolean |
isEmpty()
Checks if this set covers at least one node (or some characters of some node). |
Iterator<DOMInterval> |
iterator()
|
DOMIntervalSet |
subtract(DOMInterval interval,
MutableReference<DOMIntervalSet> diff)
Subtracts given interval to this interval set. |
DOMIntervalSet |
subtract(DOMIntervalSet other,
MutableReference<DOMIntervalSet> diff)
Subtracts all intervals from given set to this interval set. |
List<IDSelectionAction> |
toSelectionActions(boolean select,
IDManager idManager)
Returns this set as a list of IDSelectionAction elements. |
String |
toString()
|
DOMIntervalSet |
union(DOMInterval interval,
MutableReference<DOMIntervalSet> diff)
Adds given interval to this interval set. |
DOMIntervalSet |
union(DOMIntervalSet other,
MutableReference<DOMIntervalSet> diff)
Adds all intervals from given set to this interval set. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DOMIntervalSet()
public DOMIntervalSet(DOMIntervalSet other)
other
- clone this interval set.public DOMIntervalSet(DOMInterval interval)
interval
- the interval.Method Detail |
---|
public Iterator<DOMInterval> iterator()
iterator
in interface Iterable<DOMInterval>
public List<DOMInterval> getIntervals()
public List<Node> getContents()
DOMInterval.getContents()
method, removing duplicate nodes. For
details please look there
.
public Set<String> getContentIds(IDManager idManager)
idManager
- the ID manager.
public DOMIntervalSet union(DOMInterval interval, MutableReference<DOMIntervalSet> diff)
O(log(|this|))
in worst case.
interval
- interval to add. Adjacent nodes are merged automatically.diff
- receives a never-null set difference between new set and the
old set. A list of intervals that would have been added to the old set in
order to obtain the new set. This parameter may be null
if
you do not want to compute the diff set.
public DOMIntervalSet union(DOMIntervalSet other, MutableReference<DOMIntervalSet> diff)
|other|.O(log(|this|))
in worst case.
other
- set of intervals to add. Adjacent nodes are merged
automatically.diff
- receives a never-null set difference between new set and the
old set. A list of intervals that would have been added to the old set in
order to obtain the new set. This parameter may be null
if
you do not want to compute the diff set.
public DOMIntervalSet subtract(DOMInterval interval, MutableReference<DOMIntervalSet> diff)
O(log(|this|))
in worst case.
interval
- interval to subtract.diff
- receives a never-null set difference between new set and the
old set. A list of intervals that would have been removed from the old
set in order to obtain the new set. This parameter may be
null
if you do not want to compute the diff set.
public DOMIntervalSet subtract(DOMIntervalSet other, MutableReference<DOMIntervalSet> diff)
|other|.O(log(|this|))
in worst case.
other
- set of intervals to add.diff
- receives a non-null set difference between new set and the
old set. A list of intervals that would have been removed from the old
set in order to obtain the new set. This parameter may be
null
if you do not want to compute the diff set.
public DOMIntervalSet intersect(DOMIntervalSet other, MutableReference<DOMIntervalSet> diff)
|other|.O(log(|this|))
in worst case.
other
- the set to intersect with.diff
- receives a non-null set difference between new set and the
old set. A list of intervals that would have been removed from the old
set in order to obtain the new set. This parameter may be
null
if you do not want to compute the diff set.
public DOMIntervalSet intersect(DOMInterval interval, MutableReference<DOMIntervalSet> diff)
O(log(|this|))
in the worst case.
interval
- the set to intersect with.diff
- receives a non-null set difference between new set and the
old set. A list of intervals that would have been removed from the old
set in order to obtain the new set. This parameter may be
null
if you do not want to compute the diff set.
public boolean contains(DOMInterval interval)
O(log(|this|))
in worst case.
interval
- interval to check
true
if all content of given interval is fully
covered by the set, false
if some nodes (or parts of
nodes) are outside the set.public DOMIntervalSet complement(Node root, IDManager idManager, MutableReference<List<IDSelectionAction>> actions)
root
- if the interval is empty then the complement will contain all
child nodes of this node. If the interval is not empty then this
parameter is ignored and may be null
- the complement will
be computed in the context of the whole document.idManager
- the ID manager. If null
then all actions
will have null
id.actions
- receives a non-null list of selection action that needs to
be executed in order for the selection to be in sync with the set. This
parameter may be null
if you do not want to compute the
action list.
public List<IDSelectionAction> toSelectionActions(boolean select, IDManager idManager)
IDSelectionAction
elements.
select
- the value of the IDSelectionAction.select
attribute
for all returned instances.idManager
- the ID manager. If null
then all actions
will have null
id.
null
, may be empty if this set is
empty.public boolean isEmpty()
true
if this set is empty, false
if
it contains at least one non-empty interval.public IntervalOrInsertPoint findIntervalOrInsertPoint(DomPointer ptr)
Finds index of interval that contains given pointer, or an insert point where interval starting with given pointer would be inserted. This will take O(log(n)) in worst case.
ptr
- pointer to check.
IntervalOrInsertPoint
class providing
information about the pointer.public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public void clear()
public void deleteContents(boolean deleteEmptyNode)
Range.deleteContents()
on each covered interval. Please
note that the set and all its intervals becomes invalid and should not be
used further.
deleteEmptyNode
- if true
then empty
text/cdata/comment/attribute/PI nodes are removed when their content is
completely covered by the interval. For example,
DOMInterval.create(attr).deleteContents(false)
will leave
empty attribute while
DOMInterval.create(attr).deleteContents(true)
will remove
the attribute aswell.public DocumentFragment cloneContents(Node factoryReference)
The 'copy' operation. Clones contents of all intervals using the
Range.cloneContents()
and places extracted contents into a single
fragment. Node.normalize()
is called on the result fragment.
Attribute intervals are ignored.
factoryReference
- if the interval set is empty then the empty
result document fragment will be constructed using owner of this node. If
the interval is not empty then this parameter is ignored and may be
null
.
public DocumentFragment extractContents(Node factoryReference, boolean deleteEmptyNode)
The 'cut' operation. Extracts contents of all intervals using the
Range.extractContents()
and places extracted contents into a
single fragment. Node.normalize()
is called on the result
fragment.
Please note that the set and all its intervals becomes invalid and should not be used further.
Attribute intervals are ignored.
factoryReference
- if the interval set is empty then the empty
result document fragment will be constructed using owner of this node. If
the interval is not empty then this parameter is ignored and may be
null
.deleteEmptyNode
- if true
then empty
text/cdata/comment/attribute/PI nodes are removed when their content is
completely covered by the interval. For example,
DOMInterval.create(attr).deleteContents(false)
will leave
empty attribute while
DOMInterval.create(attr).deleteContents(true)
will remove
the attribute aswell.
public DOMIntervalSet invert(DOMIntervalSet other)
other
- inverts intervals present in this set. The set is not
modified.
public DOMIntervalSet invert(DOMInterval other)
other
- inverts intervals covered by this interval.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |