List of usage examples for org.w3c.dom Node getNextSibling
public Node getNextSibling();
From source file:tvraterplugin.Updater.java
/** * Gets the Text within a Node/*w ww.j a v a2 s .c om*/ * * @param data Node to rip the Text from * @return Text in the Node */ private String getTextFromNode(Node data) { Node child = data.getFirstChild(); StringBuilder text = new StringBuilder(); while (child != null) { if (child.getNodeType() == Node.TEXT_NODE) { text.append(child.getNodeValue()); } child = child.getNextSibling(); } return text.toString(); }
From source file:tvraterplugin.Updater.java
/** * Reads the String returned by the PHP-Skript and parses the DOM * *//*from ww w .jav a2 s.co m*/ private void readData(Node node) { Node child = node.getFirstChild(); while (child != null) { if (child.getNodeName().equals("data")) { readRatingData(child); } child = child.getNextSibling(); } }
From source file:tvraterplugin.Updater.java
/** * Reads the Data in this Node//from w ww .j av a 2 s . co m * * @param node Node to analyse */ private void readRatingData(Node node) { mPlugin.getDatabase().clearServer(); Node child = node.getFirstChild(); while (child != null) { if (child.getNodeName().equals("rating")) { readRating(child); } child = child.getNextSibling(); } }
From source file:tvraterplugin.Updater.java
/** * Reads a single Rating/*from w ww. j av a2 s . c om*/ * * @param node Rating as DOM-Node */ private void readRating(Node node) { Rating rating = new Rating(); Node child = node.getFirstChild(); while (child != null) { String nodename = child.getNodeName(); if (nodename.equals("title")) { rating.setTitle(getNodeValue(child)); } else if (nodename.equals("overall")) { int overall = Integer.parseInt(getNodeValue(child)); rating.setOverallRating(overall); } else if (nodename.equals("action")) { int action = Integer.parseInt(getNodeValue(child)); rating.setActionRating(action); } else if (nodename.equals("entitlement")) { int entitlement = Integer.parseInt(getNodeValue(child)); rating.setEntitlementRating(entitlement); } else if (nodename.equals("fun")) { int fun = Integer.parseInt(getNodeValue(child)); rating.setFunRating(fun); } else if (nodename.equals("tension")) { int tension = Integer.parseInt(getNodeValue(child)); rating.setTensionRating(tension); } else if (nodename.equals("erotic")) { int erotic = Integer.parseInt(getNodeValue(child)); rating.setEroticRating(erotic); } else if (nodename.equals("count")) { int userCount = Integer.parseInt(getNodeValue(child)); rating.setUserCount(userCount); } else if (nodename.equals("genre")) { int genre = Integer.parseInt(getNodeValue(child)); rating.setGenre(genre); } else if (nodename.equals("id")) { int onlineID = Integer.parseInt(getNodeValue(child)); rating.setOnlineID(onlineID); if (rating.getTitle() != null) { Rating personal = mPlugin.getDatabase().getPersonalRating(rating.getTitle()); if (personal != null) { personal.setOnlineID(onlineID); } } else { System.out.println("No Title"); } } child = child.getNextSibling(); } mPlugin.getDatabase().setServerRating(rating); }
From source file:tvraterplugin.Updater.java
/** * Returns the Text-Value in this Node/*from w w w.j av a2s. co m*/ * * @param node get Text from this Node * @return Text in this Node */ private String getNodeValue(Node node) { StringBuilder value = new StringBuilder(); Node child = node.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.TEXT_NODE) { value.append(child.getNodeValue()); } child = child.getNextSibling(); } return value.toString(); }
From source file:ua.utility.kfsdbupgrade.MaintainableXMLConversionServiceImpl.java
private void deleteAllNoneListProxyChildren(Node ecrdPositionsNode) { Node childNode = ecrdPositionsNode.getFirstChild(); while (childNode != null) { if (!childNode.getNodeName().equals(LIST_PROXY_NAME)) { // Not a list proxy node, so remove it ecrdPositionsNode.removeChild(childNode); }//ww w .jav a 2 s. co m childNode = childNode.getNextSibling(); } }
From source file:utils.form.WebFormUserInputsCollector.java
private void fillOutNonLabeledFieldLabelDomPointer(UserInputDom valueHolder, Node searchStartingNode, Node searchUpEndingNode, boolean endingNodeInclusive, boolean leftLabeled) { Node tempParent2 = searchStartingNode; if (leftLabeled) { while (tempParent2.getPreviousSibling() == null && tempParent2 != searchUpEndingNode) { tempParent2 = tempParent2.getParentNode(); }/*from w w w . ja v a 2 s .com*/ // if tempParent2 is form node, we will use the form's // previous sibling as the label node; // Or we will use the nearest input sibling node as the // label node; if (tempParent2 == searchUpEndingNode && !endingNodeInclusive) return; valueHolder.setLabelDomPointer(tempParent2.getPreviousSibling()); } else { while (tempParent2.getNextSibling() == null && tempParent2 != searchUpEndingNode) { tempParent2 = tempParent2.getParentNode(); } // if tempParent2 is form node, we will use the form's // previous sibling as the label node; // Or we will use the nearest input sibling node as the // label node; if (tempParent2 == searchUpEndingNode && !endingNodeInclusive) return; valueHolder.setLabelDomPointer(tempParent2.getNextSibling()); } }
From source file:utils.form.WebFormUserInputsCollector.java
private void fillOutAddtionalInfoNode(UserInputDom valueHolder, Node searchStartingNode, Node searchUpEndingNode, boolean endingNodeInclusive, boolean nextSiblingOnly) { // fill out addtional info nodes Node tempParent2 = searchStartingNode; Node tempNode = tempParent2;//from w w w . j a v a 2s .c om List<Node> additionalInfoNodes = new ArrayList<Node>(); while (tempParent2.getNextSibling() == null && tempParent2 != searchUpEndingNode) { tempParent2 = tempParent2.getParentNode(); tempNode = tempParent2; } if (tempNode == searchUpEndingNode && !endingNodeInclusive) return; if (nextSiblingOnly) additionalInfoNodes.add(tempNode.getNextSibling()); else while (tempNode.getNextSibling() != null) { additionalInfoNodes.add(tempNode.getNextSibling()); if (tempNode.getNodeName().equalsIgnoreCase("form")) break; tempNode = tempNode.getNextSibling(); } valueHolder.setAdditionalInfoNodes(additionalInfoNodes); }
From source file:utils.form.WebFormUserInputsCollector.java
private void fillOutUserViewableNextSibling(UserInputDom valueHolder, Node maxInputParentNoOtherChild, Node searchUpEndingNode, boolean endingNodeInclusive) { Node tempParent2 = maxInputParentNoOtherChild; while (tempParent2.getNextSibling() == null && tempParent2 != searchUpEndingNode) { tempParent2 = tempParent2.getParentNode(); }//w w w . ja v a 2 s. c o m if (tempParent2 == searchUpEndingNode && !endingNodeInclusive) return; valueHolder.setNextUserViewableHtmlSibling(tempParent2.getNextSibling()); }
From source file:utils.form.WebFormUserInputsCollector.java
private boolean siblingHasInput(Node node) { boolean retVal = false; for (int i = 0; i < USER_CHANGABLE_INPUT_TAGS.length; i++) { boolean nextSiblingIsInput = false; if (node.getNextSibling() != null) { nextSiblingIsInput = Arrays.asList(USER_CHANGABLE_INPUT_TAGS) .contains($(node.getNextSibling()).tag().toLowerCase()) || $(node.getNextSibling()).find(USER_CHANGABLE_INPUT_TAGS[i]).isNotEmpty(); }//from ww w .j av a2s. c om boolean previousSiblingIsInput = false; if (node.getPreviousSibling() != null) { previousSiblingIsInput = Arrays.asList(USER_CHANGABLE_INPUT_TAGS) .contains($(node.getPreviousSibling()).tag().toLowerCase()) || $(node.getPreviousSibling()).find(USER_CHANGABLE_INPUT_TAGS[i]).isNotEmpty(); } retVal = nextSiblingIsInput || previousSiblingIsInput; if (retVal) break; } return retVal; }