public class Segment
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.util.List<Segment> |
childs |
java.lang.String |
name |
int |
numberOfLines |
Segment |
parent |
Position |
position |
static java.lang.String |
PROPERTY_NAME |
static java.lang.String |
PROPERTY_OCCURRENCE |
java.lang.String |
type |
Constructor and Description |
---|
Segment(java.lang.String name,
Position position,
java.lang.String type,
int numberOfLines)
Constructor setting all attributes.
|
Segment(java.lang.String name,
Position position,
java.lang.String type,
int numberOfLines,
java.lang.Boolean expanded)
Constructor setting all attributes.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(Segment child) |
Segment |
clone(Segment parent)
Creates a deep clone of this
Segment and it's childs.Please note that the clones Segments share the very same instance of the position and expanded attributes! |
boolean |
equals(java.lang.Object obj)
A segment is considered equal to an other if
the following attributs are the very same:
position
name
type
|
java.util.List<Segment> |
getChilds() |
int |
getEnd() |
long |
getHash() |
int |
getLength() |
int |
getOffset() |
Segment |
getParent() |
long |
getSimilarity(Segment other)
Indicates how "equal" the given Segment is to this instance.
|
boolean |
hasChilds() |
boolean |
isExpanded() |
void |
removeChild(Segment child)
Removes a single child from the list of childrens.
|
void |
removeChilds()
Removes all childs from the list of children.
|
void |
setExpanded(java.lang.Boolean expanded) |
void |
setExpandedIncludingChilds(java.lang.Boolean expanded)
Collapses ore expands the full sub-tree under the given
Segment . |
void |
setHash(java.lang.String plaintext)
Calculates and sets a hash value from the given text.
|
void |
setParent(Segment parent) |
java.lang.String |
toString() |
public static final java.lang.String PROPERTY_NAME
public static final java.lang.String PROPERTY_OCCURRENCE
public java.lang.String name
public Position position
public java.lang.String type
public int numberOfLines
public java.util.List<Segment> childs
public Segment parent
public Segment(java.lang.String name, Position position, java.lang.String type, int numberOfLines)
name
- The Segments nameposition
- The Segments positiontype
- The Segment typenumberOfLines
- The number of lines within the document.public Segment(java.lang.String name, Position position, java.lang.String type, int numberOfLines, java.lang.Boolean expanded)
name
- The Segments nameposition
- The Segments positiontype
- The Segment typenumberOfLines
- The number of lines within the document.expanded
- Whether the Segment is expanded or not.public java.lang.String toString()
toString
in class java.lang.Object
public java.util.List<Segment> getChilds()
List
of child Segment
nodes.public void addChild(Segment child)
child
- The Segement to be added to the child list.public void removeChilds()
public void removeChild(Segment child)
child
- The Segment
to be removed.public boolean hasChilds()
true
if this Segment
has at least
1
child, false
otherwise.public Segment getParent()
Segment
or null
it the
Segment has no parent.public void setParent(Segment parent)
parent
- The parent Segment
.public int getOffset()
-1
if no
position is set.public int getLength()
-1
if no
position is set.public int getEnd()
-1
if no
position is set.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public boolean isExpanded()
true
if the Segment
is expanded,
false
otherwise.public void setExpanded(java.lang.Boolean expanded)
expanded
- true
to indicate that the Segment
shall be expanded in the TreeView, false
if it shall be collapsed.public void setExpandedIncludingChilds(java.lang.Boolean expanded)
Segment
.expanded
- true
to indicate that the Segment
and all it's childs shall be expanded recursively in the TreeView,
false
if they shall be collapsed.public Segment clone(Segment parent)
Segment
and it's childs.position
and expanded
attributes!parent
- The parent Segment
to be used as the clones parent.Segment
.public long getHash()
Segment
.public void setHash(java.lang.String plaintext)
plaintext
- The text to be used to calculate the hash.public long getSimilarity(Segment other)
other
- The other Segment
to be compared withZero
of the Segments can be treated as equal,
otherwise a positive integer. The higher the return value the less equal
the objects are. If the other
Segment is null
Long.MAX_VALUE
is returned.