@SuppressWarnings( "unchecked" ) private void appendElement( Element source, Element target ) { for ( Iterator<Attribute> itr = source.getAttributes().iterator(); itr.hasNext(); ) { Attribute a = itr.next(); itr.remove(); Attribute mergedAtt = target.getAttribute( a.getName(), a.getNamespace() ); if ( mergedAtt == null ) { target.setAttribute( a ); } } for ( Iterator<Element> itr = source.getChildren().iterator(); itr.hasNext(); ) { Content n = itr.next(); itr.remove(); target.addContent( n ); } }
@Override public final String getAttributeName(Object attribute) { return ((Attribute)attribute).getName(); }
/** * Return index of the <code>Attribute</code> with the given <i>name</i> and * the same Namespace URI as <i>namespace</i>. * * @param name * name of <code>Attribute</code> to retrieve * @param namespace * indicate what <code>Namespace</code> URI to consider * @return the index of the attribute that matches the conditions, or * <code>-1</code> if there is none. */ int indexOf(final String name, final Namespace namespace) { if (attributeData != null) { if (namespace == null) { return indexOf(name, Namespace.NO_NAMESPACE); } final String uri = namespace.getURI(); for (int i = 0; i < size; i++) { final Attribute att = attributeData[i]; if (uri.equals(att.getNamespaceURI()) && name.equals(att.getName())) { return i; } } } return -1; }
/** * Return index of attribute with same name and Namespace, or -1 if one * doesn't exist */ private int indexOfDuplicate(final Attribute attribute) { return indexOf(attribute.getName(), attribute.getNamespace()); }
continue; atts.addAttribute(a.getNamespaceURI(), a.getName(), a.getQualifiedName(), getAttributeTypeName(a.getAttributeType()),
/** * Check to see if the Content matches a predefined set of rules. * * @param content The Content to verify. * @return <code>true</code> if the objected matched a predfined * set of rules. */ @Override public Attribute filter(Object content) { if (content instanceof Attribute) { Attribute att = (Attribute) content; if (name == null) { if (namespace == null) { return att; } return namespace.equals(att.getNamespace()) ? att : null; } if (!name.equals(att.getName())) { return null; } if (namespace == null) { return att; } return namespace.equals(att.getNamespace()) ? att : null; } return null; }
@Override public javax.xml.stream.events.Attribute next() { final Attribute att = source.next(); final Namespace ns = att.getNamespace(); if (ns == Namespace.NO_NAMESPACE) { return fac.createAttribute(att.getName(), att.getValue()); } return fac.createAttribute(ns.getPrefix(), ns.getURI(), att.getName(), att.getValue()); }
ObjectNode toJson(Element element) { ObjectNode n = mapper.createObjectNode(); element.getAttributes().forEach(it -> { n.put(it.getName(), it.getValue()); }); n.put("ucsManagerId", getUCSClient().getUCSManagerId()); return n; }
/** * This will handle printing of an <code>{@link Attribute}</code>. * * @param out * <code>XMLStreamWriter</code> to use. * @param fstack * The current FormatStack * @param attribute * <code>Attribute</code> to output * @throws XMLStreamException * if the output fails */ protected void printAttribute(final XMLStreamWriter out, final FormatStack fstack, final Attribute attribute) throws XMLStreamException { if (!attribute.isSpecified() && fstack.isSpecifiedAttributesOnly()) { return; } final Namespace ns = attribute.getNamespace(); if (ns == Namespace.NO_NAMESPACE) { out.writeAttribute(attribute.getName(), attribute.getValue()); } else { out.writeAttribute(ns.getPrefix(), ns.getURI(), attribute.getName(), attribute.getValue()); } }
public LikeFilter( String type, Element selectorNode ) { this.type = type; if ( selectorNode.hasAttributes() ) { this.attrMap = new HashMap<String,String>(); for ( Attribute attr : selectorNode.getAttributes() ) { attrMap.put( attr.getName(), attr.getValue() ); } } this.value = selectorNode.getTextTrim(); if ( this.value.length() == 0 ) this.value = null; }
public void undo(MCRChangeData data) { Attribute attribute = data.getAttribute(); data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace()); } }
/** * @return Map with all attributes of the anchor element. Returns null if anchor element is null. */ public Map<String, String> getAnchorAttributes() { if (getAnchor() == null) { return null; } Map<String, String> attributes = new HashMap<>(); for (Attribute attribute : getAnchor().getAttributes()) { attributes.put(attribute.getName(), attribute.getValue()); } return attributes; }
/** * Copies those attributes from the other's element into this' element that do not exist in this' element. */ protected void mergeAttributes(MCRMerger other) { for (Attribute attribute : other.element.getAttributes()) { if (this.element.getAttribute(attribute.getName(), attribute.getNamespace()) == null) { this.element.setAttribute(attribute.clone()); } } }
@Override public void setAttribute(final Element parent, final Attribute a) { if ("id".equals(a.getName())) { if (dataCache.getIdCache().containsKey(a.getValue())) { logger.warning("id already exists in id cache: " + a.getValue()); } dataCache.getIdCache().put(a.getValue(), parent); } else if ("sid".equals(a.getName())) { dataCache.getSidCache().put(a.getValue(), parent); } else if ("count".equals(a.getName())) { try { count = a.getIntValue(); } catch (final DataConversionException e) { e.printStackTrace(); } } super.setAttribute(parent, a); }
public void undo(MCRChangeData data) { Attribute attribute = data.getAttribute(); data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace()); data.getContext().setAttribute(attribute); } }
/** * There are dummy attributes in the root element of the XSL, which are removed here. * Those attributes were generated during transformation to force passing through namespace nodes. */ private MCRContent removeDummyAttributes(MCRContent xsl) throws JDOMException, IOException, SAXException { Document doc = xsl.asXML(); List<Attribute> attributes = doc.getRootElement().getAttributes(); for (Iterator<Attribute> iter = attributes.iterator(); iter.hasNext();) { if ("dummy".equals(iter.next().getName())) { iter.remove(); } } MCRJDOMContent out = new MCRJDOMContent(doc); out.setFormat(Format.getPrettyFormat().setIndent(" ")); return out; } }