@Test public void testSolr() throws ParserConfigurationException, SAXException, IOException { InputStream is = SolrUtilsTest.class.getResourceAsStream("select.xml"); Document document = XMLUtils.parseDocument(is); Element topElm = XMLUtils.findElement(document.getDocumentElement(),"result"); List<Element> elements = XMLUtils.getElements(topElm); List<String> arr = SOLRUtils.array(elements.get(0),"collection", String.class); Assert.assertTrue(arr.size() == 1); }
public static <T> List<T> array(final Element doc, final String attributeName, Class<T> clz) { synchronized(doc.getOwnerDocument()) { List<T> ret = new ArrayList<T>(); List<Element> elms = XMLUtils.getElements(doc, new XMLUtils.ElementsFilter() { @Override public boolean acceptElement(Element element) { return (element.getNodeName().equals("arr") && element.hasAttribute("name") && element .getAttribute("name").equals(attributeName)); } }); for (Element e : elms) { ret.add(value(e.getTextContent(), clz)); } return ret; } }
SOLRUtils { public static <T> List<T> array(final Element doc, final String attributeName, Class<T> clz) { synchronized(doc.getOwnerDocument()) { List<T> ret = new ArrayList<T>(); List<Element> elms = XMLUtils.getElements(doc, new XMLUtils.ElementsFilter() { @Override public boolean acceptElement(Element element) { return (element.getNodeName().equals("arr") && element.hasAttribute("name") && element .getAttribute("name").equals(attributeName)); } }); for (Element e : elms) { ret.add(value(e.getTextContent(), clz)); } return ret; } } }
SOLRUtils { public static <T> List<T> array(final Element doc, final String attributeName, Class<T> clz) { synchronized(doc.getOwnerDocument()) { List<T> ret = new ArrayList<T>(); List<Element> elms = XMLUtils.getElements(doc, new XMLUtils.ElementsFilter() { @Override public boolean acceptElement(Element element) { return (element.getNodeName().equals("arr") && element.hasAttribute("name") && element .getAttribute("name").equals(attributeName)); } }); for (Element e : elms) { ret.add(value(e.getTextContent(), clz)); } return ret; } }  }
SOLRUtils { public static <T> List<T> array(final Element doc, final String attributeName, Class<T> clz) { synchronized(doc.getOwnerDocument()) { List<T> ret = new ArrayList<T>(); List<Element> elms = XMLUtils.getElements(doc, new XMLUtils.ElementsFilter() { @Override public boolean acceptElement(Element element) { return (element.getNodeName().equals("arr") && element.hasAttribute("name") && element .getAttribute("name").equals(attributeName)); } }); for (Element e : elms) { ret.add(value(e.getTextContent(), clz)); } return ret; } }  static T value(String val, Class<T> clz); static Element value(Document doc, String val); static Element value(Document doc, String attname, String val); static Element value(Document doc, Integer val); static Element value(Document doc, String attname, Integer val); static Element arr(Document doc, String attname, List vals); static T value(final Element doc, final String attributeName,
            Class<T> clz); static List<T> array(final Element doc,
            final String attributeName, Class<T> clz); static List<T> narray(final Element doc,
            final String attributeName, Class<T> clz); }
SOLRUtils { public static <T> List<T> array(final Element doc, final String attributeName, Class<T> clz) { synchronized(doc.getOwnerDocument()) { List<T> ret = new ArrayList<T>(); List<Element> elms = XMLUtils.getElements(doc, new XMLUtils.ElementsFilter() { @Override public boolean acceptElement(Element element) { return (element.getNodeName().equals("arr") && element.hasAttribute("name") && element .getAttribute("name").equals(attributeName)); } }); for (Element e : elms) { ret.add(value(e.getTextContent(), clz)); } return ret; } }  static T value(String val, Class<T> clz); static Element value(Document doc, String val); static Element value(Document doc, String attname, String val); static Element value(Document doc, Integer val); static Element value(Document doc, String attname, Integer val); static Element arr(Document doc, String attname, List vals); static T value(final Element doc, final String attributeName,
            Class<T> clz); static List<T> array(final Element doc,
            final String attributeName, Class<T> clz); static List<T> narray(final Element doc,
            final String attributeName, Class<T> clz); static final Logger LOGGER; static Map<Class, String> SOLR_TYPE_NAMES; }