public String getValue() { return currentElement.getText(); }
private void assertRowElement(Element elem, String id, String name, String price) { Element idElem = (Element) elem.elements().get(0); Element nameElem = (Element) elem.elements().get(1); Element priceElem = (Element) elem.elements().get(2); assertEquals("ID incorrect.", id, idElem.getText()); assertEquals("Name incorrect.", name, nameElem.getText()); assertEquals("Price incorrect.", price, priceElem.getText()); }
/** * Returns the name of the application. * * @return the name of the application. */ public static synchronized String getAppName() { Element appName = (Element)generatedModel.selectSingleNode("//adminconsole/global/appname"); if (appName != null) { String pluginName = appName.attributeValue("plugin"); return getAdminText(appName.getText(), pluginName); } else { return null; } }
/** * Returns the URL of the main logo image for the admin console. * * @return the logo image. */ public static synchronized String getLogoImage() { Element globalLogoImage = (Element)generatedModel.selectSingleNode( "//adminconsole/global/logo-image"); if (globalLogoImage != null) { String pluginName = globalLogoImage.attributeValue("plugin"); return getAdminText(globalLogoImage.getText(), pluginName); } else { return null; } }
/** * Returns the URL of the login image for the admin console. * * @return the login image. */ public static synchronized String getLoginLogoImage() { Element globalLoginLogoImage = (Element)generatedModel.selectSingleNode( "//adminconsole/global/login-image"); if (globalLoginLogoImage != null) { String pluginName = globalLoginLogoImage.attributeValue("plugin"); return getAdminText(globalLoginLogoImage.getText(), pluginName); } else { return null; } }
public Reflections read(InputStream inputStream) { Reflections reflections; try { Constructor<Reflections> constructor = Reflections.class.getDeclaredConstructor(); constructor.setAccessible(true); reflections = constructor.newInstance(); } catch (Exception e) { reflections = new Reflections(new ConfigurationBuilder()); } try { Document document = new SAXReader().read(inputStream); for (Object e1 : document.getRootElement().elements()) { Element index = (Element) e1; for (Object e2 : index.elements()) { Element entry = (Element) e2; Element key = entry.element("key"); Element values = entry.element("values"); for (Object o3 : values.elements()) { Element value = (Element) o3; reflections.getStore().getOrCreate(index.getName()).put(key.getText(), value.getText()); } } } } catch (DocumentException e) { throw new ReflectionsException("could not read.", e); } catch (Throwable e) { throw new RuntimeException("Could not read. Make sure relevant dependencies exist on classpath.", e); } return reflections; }
public Reflections read(InputStream inputStream) { Reflections reflections; try { Constructor<Reflections> constructor = Reflections.class.getDeclaredConstructor(); constructor.setAccessible(true); reflections = constructor.newInstance(); } catch (Exception e) { reflections = new Reflections(new ConfigurationBuilder()); } try { Document document = new SAXReader().read(inputStream); for (Object e1 : document.getRootElement().elements()) { Element index = (Element) e1; for (Object e2 : index.elements()) { Element entry = (Element) e2; Element key = entry.element("key"); Element values = entry.element("values"); for (Object o3 : values.elements()) { Element value = (Element) o3; reflections.getStore().getOrCreate(index.getName()).put(key.getText(), value.getText()); } } } } catch (DocumentException e) { throw new ReflectionsException("could not read.", e); } catch (Throwable e) { throw new RuntimeException("Could not read. Make sure relevant dependencies exist on classpath.", e); } return reflections; }
final int max = Integer.parseInt(rsmElement.element("max").getText()); pointerUID = afterElement.getText(); } else if (beforeElement != null) { pointerUID = beforeElement.getText(); isForwardOriented = false; } else if (indexElement != null) { final int index = Integer.parseInt(indexElement.getText()); if (index > 0) { pointerUID = getUID(index - 1);
@Override protected void match(Node node) { // System.out.println(node.toString()); if (node instanceof Element) { Element element = (Element) node; System.out.println("Element: " + element.getQualifiedName()); System.out.println("\tText: " + element.getText()); System.out.println("\tAttributes:"); for (Iterator<?> i = element.attributeIterator(); i.hasNext();) { Attribute attribute = (Attribute) i.next(); System.out.println("\t\t" + attribute.getName() + "=" + attribute.getValue()); } } else if (node instanceof Attribute) { Attribute attribute = (Attribute) node; System.out.println("Attribute: " + attribute.getName() + "=" + attribute.getValue()); } } };
SAXReader reader = new SAXReader(); Document doc = reader.read(in); String path = doc.getRootElement().getText(); try { if (path != null) {
if (dbStorageEnabled && vcard != null && (vcard.element("PHOTO") == null || vcard.element("PHOTO").element("BINVAL") == null || vcard.element("PHOTO").element("BINVAL").getText().matches("\\s*"))) { Element avatarElement = loadAvatarFromDatabase(username); if (avatarElement != null) {
while (iter.hasNext()) { prop = iter.next(); value = prop.getText();
/** * Returns the version string displayed in the admin console. * * @return the version string. */ public static synchronized String getVersionString() { Element globalVersion = (Element)generatedModel.selectSingleNode( "//adminconsole/global/version"); if (globalVersion != null) { String pluginName = globalVersion.attributeValue("plugin"); return getAdminText(globalVersion.getText(), pluginName); } else { // Default to the Openfire version if none has been provided via XML. XMPPServer xmppServer = XMPPServer.getInstance(); return xmppServer.getServerInfo().getVersion().getVersionString(); } }
@Test public void withMultiList() throws Exception { List list = new ArrayList(); list.add(Country.COUNTRY_UK); list.add(Country.COUNTRY_AT); this.bean.setSomeList(list); this.tag.setPath("someList"); this.tag.setItems(Country.getCountries()); this.tag.setItemValue("isoCode"); int result = this.tag.doStartTag(); assertEquals(Tag.SKIP_BODY, result); String output = getOutput(); output = "<doc>" + output + "</doc>"; SAXReader reader = new SAXReader(); Document document = reader.read(new StringReader(output)); Element rootElement = document.getRootElement(); assertEquals(2, rootElement.elements().size()); Element selectElement = rootElement.element("select"); assertEquals("select", selectElement.getName()); assertEquals("someList", selectElement.attribute("name").getValue()); List children = selectElement.elements(); assertEquals("Incorrect number of children", 4, children.size()); Element e = (Element) selectElement.selectSingleNode("option[@value = 'UK']"); assertEquals("UK node not selected", "selected", e.attribute("selected").getValue()); assertEquals("United Kingdom(UK)", e.getText()); e = (Element) selectElement.selectSingleNode("option[@value = 'AT']"); assertEquals("AT node not selected", "selected", e.attribute("selected").getValue()); assertEquals("Austria(AT)", e.getText()); }
assertEquals("United Kingdom", e.getText());