@Override public void addElement(EName element, String value, Attributes attributes) { // Ignore empty root element if (! rootTag.equals(element)) { super.addElement(element, value, attributes); } }
/** * Adds the element to the metadata collection. * * @param element * the expanded name of the element * @param value * the value */ protected void addElement(EName element, String value) { if (element == null) throw new IllegalArgumentException("Expanded name must not be null"); addElement(new CatalogEntry(element, value, NO_ATTRIBUTES)); }
/** * Adds an element with attributes to the catalog. * * @param element * the expanded name of the element * @param value * the element's value * @param attributes * the attributes. May be null */ protected void addElement(EName element, String value, Attributes attributes) { if (element == null) throw new IllegalArgumentException("Expanded name must not be null"); Map<EName, String> attributeMap = new HashMap<>(); if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { attributeMap.put(new EName(attributes.getURI(i), attributes.getLocalName(i)), attributes.getValue(i)); } } addElement(new CatalogEntry(element, value, attributeMap)); }
/** * Adds an element with the <code>xml:lang</code> and <code>xsi:type</code> attributes to the metadata collection. * * @param element * the expanded name of the element * @param value * the value * @param language * the language identifier (two letter ISO 639) * @param type * the element type */ protected void addTypedLocalizedElement(EName element, String value, String language, EName type) { if (element == null) throw new IllegalArgumentException("EName name must not be null"); if (type == null) throw new IllegalArgumentException("Type must not be null"); if (language == null) throw new IllegalArgumentException("Language must not be null"); Map<EName, String> attributes = new HashMap<>(2); attributes.put(XML_LANG_ATTR, language); attributes.put(XSI_TYPE_ATTR, toQName(type)); addElement(new CatalogEntry(element, value, attributes)); }
/** * Adds the element with the <code>xml:lang</code> attribute to the metadata collection. * * @param element * the expanded name of the element * @param value * the value * @param language * the language identifier (two letter ISO 639) */ protected void addLocalizedElement(EName element, String value, String language) { RequireUtil.notNull(element, "expanded name"); RequireUtil.notNull(language, "language"); Map<EName, String> attributes = new HashMap<>(1); attributes.put(XML_LANG_ATTR, language); addElement(new CatalogEntry(element, value, attributes)); }
/** * Adds the element with the <code>xsi:type</code> attribute to the metadata collection. * * @param value * the value * @param type * the element type */ protected void addTypedElement(EName element, String value, EName type) { RequireUtil.notNull(element, "expanded name"); RequireUtil.notNull(type, "type"); Map<EName, String> attributes = new HashMap<>(1); attributes.put(XSI_TYPE_ATTR, toQName(type)); addElement(new CatalogEntry(element, value, attributes)); }