public Text createText(String text) { if (text == null) { String msg = "Adding text to an XML document must not be null"; throw new IllegalArgumentException(msg); } return new DefaultText(text); }
/** * Selects text nodes as list of strings * * @param xpath xpath expression, should end with text() function, example: "//name/text()" * @return list of found strings matching expression, never null. If nothing matches, list will be empty. */ private List<String> selectStrings(String xpath) { Object res = doc.selectObject(xpath); if(!(res instanceof List)){ throw new IllegalArgumentException("xpath expression must correspond to a list"); } List defaultTextList = (List) res; if(defaultTextList.size() > 0 && !(defaultTextList.get(0) instanceof DefaultText)){ throw new IllegalArgumentException("xpath expression must correspond to a list of text nodes, i.e. end with: text()"); } List<String> stringsList = new ArrayList<String>(); for (Object textNode : defaultTextList) { stringsList.add(((DefaultText)textNode).getText()); } return stringsList; }
protected Node createXPathResult(Element parent) { return new DefaultText(parent, getText()); } }
/** * Selects text nodes as list of strings * * @param xpath xpath expression, should end with text() function, example: "//name/text()" * @return list of found strings matching expression, never null. If nothing matches, list will be empty. */ private List<String> selectStrings(String xpath) { Object res = doc.selectObject(xpath); if(!(res instanceof List)){ throw new IllegalArgumentException("xpath expression must correspond to a list"); } List defaultTextList = (List) res; if(defaultTextList.size() > 0 && !(defaultTextList.get(0) instanceof DefaultText)){ throw new IllegalArgumentException("xpath expression must correspond to a list of text nodes, i.e. end with: text()"); } List<String> stringsList = new ArrayList<String>(); for (Object textNode : defaultTextList) { stringsList.add(((DefaultText)textNode).getText()); } return stringsList; }
public Text createText(String text) { if (text == null) { String msg = "Adding text to an XML document must not be null"; throw new IllegalArgumentException(msg); } return new DefaultText(text); }
/** * Selects text nodes as list of strings * * @param xpath xpath expression, should end with text() function, example: "//name/text()" * @return list of found strings matching expression, never null. If nothing matches, list will be empty. */ private List<String> selectStrings(String xpath) { Object res = doc.selectObject(xpath); if(!(res instanceof List)){ throw new IllegalArgumentException("xpath expression must correspond to a list"); } List defaultTextList = (List) res; if(defaultTextList.size() > 0 && !(defaultTextList.get(0) instanceof DefaultText)){ throw new IllegalArgumentException("xpath expression must correspond to a list of text nodes, i.e. end with: text()"); } List<String> stringsList = new ArrayList<String>(); for (Object textNode : defaultTextList) { stringsList.add(((DefaultText)textNode).getText()); } return stringsList; }
public Text createText(String text) { if (text == null) { String msg = "Adding text to an XML document must not be null"; throw new IllegalArgumentException(msg); } return new DefaultText(text); }
public Text createText(String text) { if (text == null) { String msg = "Adding text to an XML document must not be null"; throw new IllegalArgumentException(msg); } return new DefaultText(text); }
public Text createText(String text) { if (text == null) { String msg = "Adding text to an XML document must not be null"; throw new IllegalArgumentException(msg); } return new DefaultText(text); }
public Text createText(String text) { if (text == null) { String msg = "Adding text to an XML document must not be null"; throw new IllegalArgumentException(msg); } return new DefaultText(text); }
public Text createText(String text) { if (text == null) { String msg = "Adding text to an XML document must not be null"; throw new IllegalArgumentException(msg); } return new DefaultText(text); }
public Text createText(String text) { if (text == null) { String msg = "Adding text to an XML document must not be null"; throw new IllegalArgumentException(msg); } return new DefaultText(text); }
public Text createText(String text) { if (text == null) { String msg = "Adding text to an XML document must not be null"; throw new IllegalArgumentException(msg); } return new DefaultText(text); }
@Override public Text createText(@Nonnull final String text) { Assertions.notNull("text", text); return new DefaultText(text.intern()); } }
protected Node createXPathResult(Element parent) { return new DefaultText(parent, getText()); } }
protected Node createXPathResult(Element parent) { return new DefaultText(parent, getText()); } }
protected Node createXPathResult(Element parent) { return new DefaultText(parent, getText()); } }
public Node node(int index) { if (index >= 0) { final Object contentShadow = content; Object node; if (contentShadow instanceof List) { List list = (List) contentShadow; if (index >= list.size()) { return null; } node = list.get(index); } else { node = (index == 0) ? contentShadow : null; } if (node != null) { if (node instanceof Node) { return (Node) node; } else { return new DefaultText(node.toString()); } } } return null; }
public Node node(int index) { if (index >= 0) { final Object contentShadow = content; Object node; if (contentShadow instanceof List) { List list = (List) contentShadow; if (index >= list.size()) { return null; } node = list.get(index); } else { node = (index == 0) ? contentShadow : null; } if (node != null) { if (node instanceof Node) { return (Node) node; } else { return new DefaultText(node.toString()); } } } return null; }
protected Node createXPathResult(Element parent) { return new DefaultText(parent, getText()); } }