public final class Tree extends java.lang.Object implements java.lang.Iterable<Tree>, java.io.Serializable
offer(Tree)
method ony any
tree in it. Any tree that get offered
into a structure of another
tree will be removed from its previous structure.
z-index
. The tree with the higher z-index can fit inside the tree
with the lower z-index.Constructor and Description |
---|
Tree(@NotNull Document document)
Construct a new tree for the whole given
document . |
Tree(@NotNull Document document,
int zIndex)
Construct a new tree for the whole given
document . |
Tree(@NotNull Document document,
@NotNull Reference reference)
Construct a new tree with the given
reference . |
Tree(@NotNull Document document,
@NotNull Reference reference,
int zIndex)
Construct a new tree with the given
reference . |
Tree(@NotNull Document document,
@NotNull Reference reference,
@NotNull Sketch sketch)
Construct a new tree with the given
reference and the given sketch . |
Tree(@NotNull Document document,
@NotNull Reference reference,
@NotNull Sketch sketch,
int zIndex)
Construct a new tree with the given
reference and the given sketch . |
Tree(@NotNull Document document,
@NotNull Sketch sketch)
Construct a new tree for the whole given
document . |
Tree(@NotNull Document document,
@NotNull Sketch sketch,
int zIndex)
Construct a new tree for the whole given
document . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all the children of this tree without removing the structure between them.
|
@NotNull Document |
document()
Get the document of this tree.
|
boolean |
equals(@Nullable java.lang.Object object) |
@Nullable Tree |
getChild()
Get the first child tree of this tree.
|
@Nullable Tree |
getNext()
Get the tree after this tree.
|
@Nullable Tree |
getParent()
Get the tree containing this tree.
|
@Nullable Tree |
getPrevious()
Get the tree before this tree.
|
@NotNull Sketch |
getSketch()
Return the sketch assigned to this tree.
|
int |
getZIndex()
Return the Z-index of this tree.
|
int |
hashCode() |
@NotNull java.util.Iterator<Tree> |
iterator() |
void |
offer(@NotNull Tree tree)
Offer the given
tree to the structure of this tree. |
void |
pop()
Cleanly remove this tree from the structure it is on.
|
@NotNull Reference |
reference()
Get the reference of this tree.
|
void |
remove()
Remove this tree from its parent, the tree before it and the tree after it.
|
void |
setSketch(@NotNull Sketch sketch)
Set the sketch of this tree to be the given
sketch . |
@NotNull java.lang.String |
toString() |
public Tree(@NotNull @NotNull Document document)
document
.document
- the document the constructed tree is for.java.lang.NullPointerException
- if the given document
is null.java.io.IOError
- if any I/O error occurred while reading the given
document
to get its length.DocumentNotFoundError
- if the given document
is not available for
reading.@Contract(mutates="param2") public Tree(@NotNull @NotNull Document document, @NotNull @NotNull Sketch sketch)
document
.
sketch
will be set to this.document
- the document the constructed tree is for.sketch
- the initial sketch set to this tree.java.lang.NullPointerException
- if the given document
or sketch
is
null.java.lang.IllegalStateException
- if the given sketch
already has a tree.java.io.IOError
- if any I/O error occurred while reading the given
document
to get its length.DocumentNotFoundError
- if the given document
is not available for
reading.public Tree(@NotNull @NotNull Document document, @NotNull @NotNull Reference reference)
reference
.document
- the document of the constructed tree.reference
- the reference of the constructed tree.java.lang.NullPointerException
- if the given document
or reference
is
null.@Contract(mutates="param3") public Tree(@NotNull @NotNull Document document, @NotNull @NotNull Reference reference, @NotNull @NotNull Sketch sketch)
reference
and the given sketch
.
sketch
will be set to this.document
- the document of the constructed tree.reference
- the reference of the contracted tree.sketch
- the initial sketch set to this tree.java.lang.NullPointerException
- if the given document
or reference
or
sketch
is null.java.lang.IllegalStateException
- if the given sketch
already has a tree.public Tree(@NotNull @NotNull Document document, int zIndex)
document
.document
- the document the constructed tree is for.zIndex
- the z-index for the constructed tree.java.lang.NullPointerException
- if the given document
is null.java.io.IOError
- if any I/O error occurred while reading the given
document
to get its length.DocumentNotFoundError
- if the given document
is not available for
reading.@Contract(mutates="param2") public Tree(@NotNull @NotNull Document document, @NotNull @NotNull Sketch sketch, int zIndex)
document
.
sketch
will be set to this.document
- the document the constructed tree is for.sketch
- the initial sketch set to this tree.zIndex
- the z-index for the constructed tree.java.lang.NullPointerException
- if the given document
or sketch
is
null.java.lang.IllegalStateException
- if the given sketch
already has a tree.java.io.IOError
- if any I/O error occurred while reading the given
document
to get its length.DocumentNotFoundError
- if the given document
is not available for
reading.public Tree(@NotNull @NotNull Document document, @NotNull @NotNull Reference reference, int zIndex)
reference
.document
- the document of the constructed tree.reference
- the reference of the constructed tree.zIndex
- the z-index for the constructed tree.java.lang.NullPointerException
- if the given document
or reference
is
null.@Contract(mutates="param3") public Tree(@NotNull @NotNull Document document, @NotNull @NotNull Reference reference, @NotNull @NotNull Sketch sketch, int zIndex)
reference
and the given sketch
.
sketch
will be set to this.document
- the document of the constructed tree.reference
- the reference of the contracted tree.sketch
- the initial sketch set to this tree.zIndex
- the z-index for the constructed tree.java.lang.NullPointerException
- if the given document
or reference
or
sketch
is null.java.lang.IllegalStateException
- if the given sketch
already has a tree.@Contract(value="null->false", pure=true) public boolean equals(@Nullable @Nullable java.lang.Object object)
equals
in class java.lang.Object
@Contract(pure=true) public int hashCode()
hashCode
in class java.lang.Object
@NotNull @Contract(value="->new", pure=true) public @NotNull java.util.Iterator<Tree> iterator()
iterator
in interface java.lang.Iterable<Tree>
@NotNull @Contract(pure=true) public @NotNull java.lang.String toString()
toString
in class java.lang.Object
@Contract(mutates="this") public void clear()
@NotNull @Contract(pure=true) public @NotNull Document document()
@Nullable @Contract(pure=true) public @Nullable Tree getChild()
null
if this tree has no children.@Nullable @Contract(pure=true) public @Nullable Tree getNext()
null
if this tree is the last tree.@Nullable @Contract(pure=true) public @Nullable Tree getParent()
null
if this tree has no parent.@Nullable @Contract(pure=true) public @Nullable Tree getPrevious()
null
if this tree is the first tree.@NotNull @Contract(pure=true) public @NotNull Sketch getSketch()
@Contract(pure=true) public int getZIndex()
@Contract(mutates="this,param") public void offer(@NotNull @NotNull Tree tree)
tree
to the structure of this tree. The given tree
will be removed from its structure then put to the proper place in the structure of
this tree.
tree
because of an IllegalTreeException
, then the method will exit without anything changed.tree
- the tree to be added.java.lang.NullPointerException
- if the given tree
is null.TreeOutOfBoundsException
- if the given tree
does not fit in the
parent of this tree.TreeTakeoverException
- if the given tree
has the same range as a
tree in the structure of this tree.TreeClashException
- if the given tree
clashes with another
tree in the structure of this tree.@Contract(mutates="this") public void pop()
@NotNull @Contract(pure=true) public @NotNull Reference reference()
@Contract(mutates="this") public void remove()
@Contract(mutates="this") public void setSketch(@NotNull @NotNull Sketch sketch)
sketch
. The previous tree of
the given sketch
will have a new sketch set to it.sketch
- the sketch to be set.