| Constructor and Description |
|---|
TagNode(TagNode parent,
String qName,
Attributes attributesarg) |
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(int index,
Node node)
Inserts provided node in the collection of children at the specified index
if
this node is set as a parent for the parameter. |
void |
addChild(Node node)
appends the provided node to the collection of children if
this node is set as the parameter's parent. |
Node |
copyTree() |
boolean |
equals(Object obj)
Considers tags from different trees equal
if they have same name and equivalent attributes.
|
void |
expandWhiteSpace() |
Attributes |
getAttributes() |
Node |
getChild(int i) |
String |
getEndTag() |
int |
getIndexOf(Node child)
If the provided parameter is in the same tree with
this object then this method fetches
index of the parameter object in the children collection. |
Node |
getLeftMostChild() |
double |
getMatchRatio(TagNode other,
org.eclipse.core.runtime.IProgressMonitor progressMonitor) |
List<Node> |
getMinimalDeletedSet(long id)
This recursive method considers a descendant deleted if all its
children had
TextNodes that now are marked as removed
with the provided id. |
int |
getNbChildren() |
String |
getOpeningTag()
Produces
String for the opening HTML tag for this node. |
String |
getQName() |
Node |
getRightMostChild() |
int |
hashCode()
Since we only consider so much information of the TagNode in
equals method, we need to re-write
hashCode method to correspond. |
boolean |
isBlockLevel() |
static boolean |
isBlockLevel(Node node) |
static boolean |
isBlockLevel(String qName) |
boolean |
isInline() |
static boolean |
isInline(Node node) |
static boolean |
isInline(String qName) |
boolean |
isPre() |
boolean |
isSameTag(TagNode other)
checks tags for being semantically equivalent if it's from
a different tree and for being the same object if it's
from the same tree as
this tag. |
protected boolean |
isSimilarTag(Node another)
Returns
true if this tag is similar to the given other tag. |
Iterator<Node> |
iterator() |
protected void |
setRoot(TagNode root) |
boolean |
splitUntill(TagNode parent,
Node split,
boolean includeLeft)
Attempts to create 2
TagNodes with
the same name and attributes as the original this node. |
String |
toString() |
detectIgnorableWhiteSpace, getLastCommonParent, getParent, getParentTree, getRoot, inPre, isWhiteAfter, isWhiteBefore, setParent, setWhiteAfter, setWhiteBeforeclone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic TagNode(TagNode parent, String qName, Attributes attributesarg)
public void addChild(Node node)
this node is set as the parameter's parent.
This method is used in the Node's constructornode - - child to add must have
this node set as its parent.IllegalStateException - - if the parameter
has different parent than this node.public int getIndexOf(Node child)
this object then this method fetches
index of the parameter object in the children collection.
If the parameter is from a different tree, then this method
attempts to return the index of first semantically equivalent
node to the parameter.child - - the template of a tag we need an index for.public void addChild(int index,
Node node)
this node is set as a parent for the parameter.index - - desired position among the childrennode - - the node to insert as a child.IllegalStateException - - if the provided node has
different parent from this node.public Node getChild(int i)
public Iterator<Node> iterator()
iterator in interface Iterable<Node>Iterator<Node> over children collectionNullPointerException - - if children collection is nullpublic int getNbChildren()
nullpublic String getQName()
public Attributes getAttributes()
public boolean isSameTag(TagNode other)
this tag.other - - tag to compare topublic boolean equals(Object obj)
protected boolean isSimilarTag(Node another)
true if this tag is similar to the given other tag.
The tags may be from different trees. If the tag name and attributes
are the same, the result will be true.another - the tag to compare withpublic int hashCode()
equals method, we need to re-write
hashCode method to correspond. Otherwise
HashTables and HashMaps might
behave unexpectedly.public String getOpeningTag()
String for the opening HTML tag for this node.
Includes the attributes. This probably doesn't work for image tag.String representation of the corresponding
opening HTML tag.public String getEndTag()
String representation of the closing HTML tag that
corresponds to the current node. Probably doesn't work for image tag.public List<Node> getMinimalDeletedSet(long id)
This recursive method considers a descendant deleted if all its
children had TextNodes that now are marked as removed
with the provided id. If all children of a descendant is considered
deleted, only that descendant is kept in the collection of the
deleted nodes, and its children are removed from the collection
of the deleted nodes.
The HTML tag nodes that never had any text content are never considered
removed
It actually might have nothing to do with being really deleted, because
the element might be kept after its text content was deleted.
Example:
table cells can be kept after its text content was deleted
horizontal rule has never had text content, but can be deleted
getMinimalDeletedSet in class Nodepublic boolean splitUntill(TagNode parent, Node split, boolean includeLeft)
TagNodes with
the same name and attributes as the original this node.
All children preceding split parameter are placed into the left part,
all children following the split parameter are placed into
the right part. Placement of the split node is determined by
includeLeft flag parameter. The newly created nodes are only added to
the parent of this node if they have some children.
The original this node is removed afterwards. The process
proceeds recursively hiking up the tree until the "parent" node is
reached. "Parent" node will not be touched.
This method is used when the parent tags of a deleted
TextNode can no longer be found in the new doc. (means
they either has been deleted or changed arguments). The "parent"
parameter in that case is the deepest common parent between the
deleted node and its surrounding remaining siblings.parent - - the node that should not participate in split operation
(where the split operation stops)split - - the node-divider to divide children among splitted partsincludeLeft - - if true the "split" node will be
included in the left part.true if single this node
was substituted with 2 new similar nodes with original children
divided among them.public static boolean isBlockLevel(String qName)
public static boolean isBlockLevel(Node node)
public boolean isBlockLevel()
public static boolean isInline(String qName)
public static boolean isInline(Node node)
public boolean isInline()
public double getMatchRatio(TagNode other, org.eclipse.core.runtime.IProgressMonitor progressMonitor)
public void expandWhiteSpace()
public Node getLeftMostChild()
getLeftMostChild in class Nodepublic Node getRightMostChild()
getRightMostChild in class Nodepublic boolean isPre()
Copyright © 2022. All rights reserved.