From 5b60019015e889cfb481912ca11f6a98321c9d4e Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Sun, 16 Dec 2018 18:40:14 +0800 Subject: [PATCH] Update ContentNode.java --- .../java/com/xenoamess/x8l/ContentNode.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/com/xenoamess/x8l/ContentNode.java b/src/main/java/com/xenoamess/x8l/ContentNode.java index 4799398..65b0d00 100644 --- a/src/main/java/com/xenoamess/x8l/ContentNode.java +++ b/src/main/java/com/xenoamess/x8l/ContentNode.java @@ -216,5 +216,29 @@ public List getCommentNodesFromChildren(int maxSize) { return res; } + public String getName() { + if (!this.attributesKeyList.isEmpty()) { + return this.attributesKeyList.get(0); + } else { + return ""; + } + } + + public List getContentNodesFromChildrenThatNameIs(String name) { + return this.getContentNodesFromChildrenThatNameIs(name, 0); + } + + public List getContentNodesFromChildrenThatNameIs(String name, int maxSize) { + List res = new ArrayList(); + 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; + } }