private static List<Attribute> createAttributes(Integer maxstanzas, Integer maxchars, Integer seconds, Calendar since) { List<Attribute> attributes = new ArrayList<Attribute>(); if (maxstanzas != null) attributes.add(new Attribute(ATTRIBUTE_MAXSTANZAS, maxstanzas.toString())); if (maxchars != null) attributes.add(new Attribute(ATTRIBUTE_MAXCHARS, maxchars.toString())); if (seconds != null) attributes.add(new Attribute(ATTRIBUTE_SECONDS, seconds.toString())); if (since != null) attributes.add(new Attribute(ATTRIBUTE_SINCE, DateTimeProfile.getInstance().getDateTimeInUTC( since.getTime()))); return attributes; }
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()); }
public Attribute getAttribute(String namespaceUri, String name) { for (Attribute attribute : attributes) { // name must match and must be in empty namespace if (attribute.getName().equals(name) && attribute.getNamespaceUri().equals(namespaceUri)) return attribute; } return null; }
public String getAttributeValue(String namespaceUri, String name) { Attribute attribute = getAttribute(namespaceUri, name); if (attribute == null) return null; else return attribute.getValue(); }
boolean found = false; for(Attribute thatAttribute : that.attributes) { if(thatAttribute.equals(attribute)) { found = true; break;
String attrNs = attribute.getNamespaceUri(); if (attrNs.length() > 0 && resolvePrefix(attrNs, false) == null) {
/** * 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; }
/** * 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(); }
private boolean hasXmlnsReservedName(Attribute attribute) { String name = attribute.getName(); return name.equals("xmlns") || name.startsWith("xmlns:"); }
public B addAttribute(Attribute attribute) { checkReset(); // check if attribute already exists for(Attribute existing : currentElement.attributes) { if(existing.getName().equals(attribute.getName()) && existing.getNamespaceUri().equals(attribute.getNamespaceUri())) { currentElement.attributes.remove(existing); break; } } currentElement.attributes.add(attribute); return (B) this; }
private static List<Attribute> createAttributes(Entity jid, String nick, Affiliation affiliation, Role role) { List<Attribute> attributes = new ArrayList<Attribute>(); if (jid != null) attributes.add(new Attribute("jid", jid.getFullQualifiedName())); if (nick != null) attributes.add(new Attribute("nick", nick)); if (affiliation != null) attributes.add(new Attribute("affiliation", affiliation.toString())); if (role != null) attributes.add(new Attribute("role", role.toString())); return attributes; }
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(); }
if (!attribute.getName().startsWith("xmlns")) { openElementBuffer.append(" "); renderAttribute(openElementBuffer, attribute, nsResolver);
private static List<Attribute> createAttributes(StatusCode code) { List<Attribute> attributes = new ArrayList<Attribute>(); if (code != null) attributes.add(new Attribute("code", Integer.toString(code.code()))); return attributes; }
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 {
private static List<Attribute> createAttributes(Entity from, Entity to) { List<Attribute> attributes = new ArrayList<Attribute>(); if (to != null) attributes.add(new Attribute("to", to.getFullQualifiedName())); if (from != null) attributes.add(new Attribute("from", from.getFullQualifiedName())); return attributes; }