Skip to content

Commit

Permalink
Update ContentNode.java
Browse files Browse the repository at this point in the history
  • Loading branch information
XenoAmess committed Dec 16, 2018
1 parent edf0dae commit 5b60019
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/com/xenoamess/x8l/ContentNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,29 @@ public List<CommentNode> getCommentNodesFromChildren(int maxSize) {
return res;
}

public String getName() {
if (!this.attributesKeyList.isEmpty()) {
return this.attributesKeyList.get(0);
} else {
return "";
}
}

public List<ContentNode> getContentNodesFromChildrenThatNameIs(String name) {
return this.getContentNodesFromChildrenThatNameIs(name, 0);
}

public List<ContentNode> getContentNodesFromChildrenThatNameIs(String name, int maxSize) {
List<ContentNode> res = new ArrayList<ContentNode>();
for (TreeNode au : this.children) {
if (au instanceof CommentNode && ((ContentNode) au).getName().equals(name)) {
res.add((ContentNode) au);
if (res.size() == maxSize) {
return res;
}
}
}
return res;
}

}

0 comments on commit 5b60019

Please sign in to comment.