Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
1
  • Loading branch information
XenoAmess committed Dec 16, 2018
1 parent a8b297e commit 83b182a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.xenoamess</groupId>
<artifactId>x8l</artifactId>
<version>0.27</version>
<version>0.28</version>
</project>
59 changes: 58 additions & 1 deletion src/main/java/com/xenoamess/x8l/ContentNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ContentNode extends TreeNode {
Expand All @@ -24,8 +25,10 @@ public void addAttribute(String key, String value) {
if (value == null) {
value = "";
}
if (!this.attributes.containsKey(key)) {
attributesKeyList.add(key);
}
attributes.put(key, value);
attributesKeyList.add(key);
}


Expand Down Expand Up @@ -114,4 +117,58 @@ public void output(Writer writer) {
e.printStackTrace();
}
}

public List<TextNode> getTextNodesFromChildren() {
return this.getTextNodesFromChildren(0);
}

public List<TextNode> getTextNodesFromChildren(int maxSize) {
List<TextNode> res = new ArrayList<TextNode>();
for (TreeNode au : this.children) {
if (au instanceof TextNode) {
res.add((TextNode) au);
if (res.size() == maxSize) {
return res;
}
}
}
return res;
}

public List<ContentNode> getContentNodesFromChildren() {
return this.getContentNodesFromChildren(0);
}

public List<ContentNode> getContentNodesFromChildren(int maxSize) {
List<ContentNode> res = new ArrayList<ContentNode>();
for (TreeNode au : this.children) {
if (au instanceof ContentNode) {
res.add((ContentNode) au);
if (res.size() == maxSize) {
return res;
}
}
}
return res;
}


public List<CommentNode> getCommentNodesFromChildren() {
return this.getCommentNodesFromChildren(0);
}

public List<CommentNode> getCommentNodesFromChildren(int maxSize) {
List<CommentNode> res = new ArrayList<CommentNode>();
for (TreeNode au : this.children) {
if (au instanceof CommentNode) {
res.add((CommentNode) au);
if (res.size() == maxSize) {
return res;
}
}
}
return res;
}


}

0 comments on commit 83b182a

Please sign in to comment.