public String getAttributeValue(String namespaceUri, String name) { Attribute attribute = getAttribute(namespaceUri, name); if (attribute == null) return null; else return attribute.getValue(); }
/** * Create a property name that is unique for this query. eg this XMLElement: * <storage xmlns="storage:bookmarks"> is converted into this string: * storage-storage-bookmarks */ private String getKey(XMLElement x) { StringBuilder queryKey = new StringBuilder(); queryKey.append(x.getName()); queryKey.append("-"); queryKey.append(x.getAttribute("xmlns").getValue()); // Some characters are not valid for property names for (int i = 0; i < queryKey.length(); i++) { char c = queryKey.charAt(i); if (c == ' ' || c == ':') { queryKey.setCharAt(i, '-'); } } return queryKey.toString(); }
/** * example for "http://myNS.org/anything", this method returns "myNS" for * element <test xmlns:myNS="http://myNS.org/anything" /> * * @return the identifier for the given namespace definition */ public String getNamespaceIdentifier(String namespace) { for (Attribute attribute : element.getAttributes()) { if (attribute.getValue().equals(namespace) && attribute.getName().startsWith(Namespaces.XMLNS_AND_COLON)) { return attribute.getName().substring(Namespaces.XMLNS_AND_COLON.length()); } } return null; }
public boolean namespacePresent(String namespaceURI) { Collection<String> nsUris = element.getDeclaredNamespaces().values(); if (nsUris.contains(namespaceURI)) { return true; } for (Attribute attribute : element.getAttributes()) { if (attribute.getName().startsWith("xmlns") && attribute.getValue().equals(namespaceURI)) { return true; } } if (namespaceURI.equals(element.getNamespaceURI())) return true; return false; // not present }
public String getUniqueXMLNSValue() { Attribute found = null; for (Attribute attribute : element.getAttributes()) { if (isNamespaceAttribute(attribute)) { if (found != null) return null; // not unique else { found = attribute; } } } if (found == null) return null; return found.getValue(); }
private void renderAttribute(StringBuilder buffer, Attribute attribute, ResolverNamespaceResolver nsResolver) { String qname; if (!attribute.getNamespaceUri().equals("")) { // attribute is in a namespace, resolve prefix qname = nsResolver.resolvePrefix(attribute.getNamespaceUri()) + ":" + attribute.getName(); } else { qname = attribute.getName(); } renderAttribute(buffer, qname, attribute.getValue()); }
if (attributeJID == null || attributeJID.getValue() == null) throw new RosterBadRequestException("missing 'jid' attribute on item node"); String name = verifier.attributePresent("name") ? itemElement.getAttribute("name").getValue() : null; if (name != null && name.length() > RosterConfiguration.ROSTER_ITEM_NAME_MAX_LENGTH) { throw new RosterNotAcceptableException("roster name too long: " + name.length()); .valueOf(itemElement.getAttribute("subscription").getValue().toUpperCase()) : SubscriptionType.NONE; if (!parseSubscriptionTypes && subscription != SubscriptionType.REMOVE) if (parseSubscriptionTypes) { askSubscriptionType = verifier.attributePresent("ask") ? AskSubscriptionType.valueOf("ASK_" + itemElement.getAttribute("ask").getValue().toUpperCase()) : AskSubscriptionType.NOT_SET; String contactJid = attributeJID.getValue(); Entity contact; try {
if (xmppCoreStanza != null && typeAttribute != null) { String errorDescription = null; String type = typeAttribute.getValue(); if (IQStanzaType.ERROR.value().equals(type)) {
String ns = x.getAttribute("xmlns").getValue(); if (ns == null) { return ServerErrorResponses.getStanzaError(StanzaErrorCondition.NOT_ACCEPTABLE, stanza,