List of usage examples for org.dom4j Namespace get
public static Namespace get(String uri)
From source file:de.tu_berlin.cit.intercloud.xmpp.core.packet.Roster.java
License:Open Source License
/** * Returns an unmodifiable copy of the {@link Item Items} in the roster packet. * * @return an unmodifable copy of the {@link Item Items} in the roster packet. */// w w w . j ava 2 s .com @SuppressWarnings("unchecked") public Collection<Item> getItems() { Collection<Item> items = new ArrayList<Item>(); Element query = element.element(new QName("query", Namespace.get("jabber:iq:roster"))); if (query != null) { for (Iterator<Element> i = query.elementIterator("item"); i.hasNext();) { Element item = i.next(); String jid = item.attributeValue("jid"); String name = item.attributeValue("name"); String ask = item.attributeValue("ask"); String subscription = item.attributeValue("subscription"); Collection<String> groups = new ArrayList<String>(); for (Iterator<Element> j = item.elementIterator("group"); j.hasNext();) { Element group = j.next(); groups.add(group.getText().trim()); } Ask askStatus = ask == null ? null : Ask.valueOf(ask); Subscription subStatus = subscription == null ? null : Subscription.valueOf(subscription); items.add(new Item(new JID(jid), name, askStatus, subStatus, groups)); } } return Collections.unmodifiableCollection(items); }
From source file:esa.mo.tools.stubgen.GeneratorXsd.java
License:Open Source License
private Object updateMessageField(Object any) { if (null != any) { if (any instanceof JAXBElement) { JAXBElement re = (JAXBElement) any; if (re.getValue() instanceof TypeReference) { throw new IllegalArgumentException("Direct type not supported in message body of : " + re.getValue().getClass().getSimpleName()); } else if (re.getValue() instanceof NamedElementReferenceWithCommentType) { NamedElementReferenceWithCommentType ne = (NamedElementReferenceWithCommentType) re.getValue(); String partType = createCompositeElementsDetails(null, false, null, ne.getType(), true, true, null).getTypeName(); if (ne.getType().isList()) { // the message part is a list, XML schema does not support this at this level so we need to warn getLog().warn(//from ww w .ja v a2 s .co m "XML Schema does not support top level elements with multiple occurrences of type " + partType); } DOMElement e = new DOMElement( new org.dom4j.QName("element", Namespace.get("http://www.w3.org/2001/XMLSchema")), 2); e.setAttribute("name", ne.getName()); e.setAttribute("type", partType); return e; } else { throw new IllegalArgumentException( "Unexpected type in message body of : " + re.getValue().getClass().getSimpleName()); } } else if (!(any instanceof Element)) { throw new IllegalArgumentException( "Unexpected type in message body of : " + any.getClass().getSimpleName()); } } return any; }
From source file:org.arquillian.graphene.visual.testing.impl.JCRMaskHandler.java
private void addMasksToConfiguration(List<MaskFromREST> masks, Document doc) { Namespace ns = Namespace.get(RushEye.NAMESPACE_VISUAL_SUITE); String xPath = "/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"visual-suite\"]/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"global-configuration\"]"; Element configurationNode = (Element) doc.selectSingleNode(xPath); for (MaskFromREST mask : masks) { Element maskElement = configurationNode.addElement(QName.get("mask", ns)); maskElement.addAttribute("id", mask.getId()); maskElement.addAttribute("source", mask.getSourceUrl()); maskElement.addAttribute("type", mask.getMaskType().value()); }/*from ww w.j av a2 s. co m*/ }
From source file:org.arquillian.graphene.visual.testing.impl.JCRMaskHandler.java
private void deleteMaskFromConfiguration(String maskID, Document doc) { Namespace ns = Namespace.get(RushEye.NAMESPACE_VISUAL_SUITE); String xPath = "/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"visual-suite\"]/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"global-configuration\"]/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"mask\" and @id=\"" + maskID + "\"]"; Node maskElement = doc.selectSingleNode(xPath); maskElement.detach();//from w w w . j av a 2 s. c o m }
From source file:org.arquillian.graphene.visual.testing.impl.JCRMaskHandler.java
private void deleteMaskFromTest(String maskID, Document doc) { Namespace ns = Namespace.get(RushEye.NAMESPACE_VISUAL_SUITE); String xPath = "/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"visual-suite\"]/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"test\"]/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"mask\" and @id=\"" + maskID + "\"]"; Node maskElement = doc.selectSingleNode(xPath); maskElement.detach();/*from ww w. j ava 2s. co m*/ }
From source file:org.arquillian.graphene.visual.testing.impl.JCRMaskHandler.java
private void addMasksToTest(List<MaskFromREST> masks, Document doc) { Namespace ns = Namespace.get(RushEye.NAMESPACE_VISUAL_SUITE); for (MaskFromREST mask : masks) { String testName = mask.getName().split(":")[1].replaceAll("/", "."); testName = testName.substring(0, testName.lastIndexOf(".png")); String xPath = "/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"visual-suite\"]/*[namespace-uri()=\"" + ns.getURI() + "\" and name()=\"test\" and @name=\"" + testName + "\"]"; Element testElement = (Element) doc.selectSingleNode(xPath); Element patternElement = testElement.element(QName.get("pattern", ns)); patternElement.detach();//from w w w. j a v a 2 s . co m Element maskElement = testElement.addElement(QName.get("mask", ns)); maskElement.addAttribute("id", mask.getId()); maskElement.addAttribute("source", mask.getSourceUrl()); maskElement.addAttribute("type", mask.getMaskType().value()); testElement.add(patternElement); } }
From source file:org.jboss.rusheye.CommandCrawl.java
License:Open Source License
private void addDocumentRoot() { ns = Namespace.get(RushEye.NAMESPACE_VISUAL_SUITE); Element root = document.addElement(QName.get("visual-suite", ns)); Namespace xsi = Namespace.get("xsi", "http://www.w3.org/2001/XMLSchema-instance"); QName schemaLocation = QName.get("schemaLocation", xsi); root.addNamespace("", ns.getURI()); root.addNamespace(xsi.getPrefix(), xsi.getURI()); root.addAttribute(schemaLocation, ns.getURI() + " " + RushEye.SCHEMA_LOCATION_VISUAL_SUITE); Element globalConfiguration = root.addElement(QName.get("global-configuration", ns)); addSuiteListener(globalConfiguration); addRetrievers(globalConfiguration);// w w w . j av a 2s. co m addPerception(globalConfiguration); addMasksByType(base, globalConfiguration); addTests(base, root); }
From source file:org.jivesoftware.smack.sasl.SASLMechanism.java
License:Open Source License
private static Element createAuthEl(String name, String authenticationText) { if (name == null) { throw new NullPointerException("SASL mechanism name shouldn't be null."); }/*from w w w.ja v a 2 s . co m*/ DefaultElement authEl = new DefaultElement("auth", Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl")); authEl.addAttribute("mechanism", name); if (authenticationText != null) { authEl.setText(authenticationText); } return authEl; }
From source file:org.jivesoftware.smack.sasl.SASLMechanism.java
License:Open Source License
private static Element createChallengeEl(String data) { DefaultElement authEl = new DefaultElement("challenge", Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl")); if (data != null) { authEl.setText(data);//from ww w .j a v a2s . c o m } return authEl; }
From source file:org.jivesoftware.smack.sasl.SASLMechanism.java
License:Open Source License
private static Element createResponseEl(String authenticationText) { DefaultElement authEl = new DefaultElement("response", Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl")); if (authenticationText != null && !authenticationText.isEmpty()) { authEl.setText(authenticationText); }/*from w w w . ja va 2 s . c om*/ return authEl; }