Here you can find the source of addAttribute(final AttributesImpl attributes, final String localName, final Object value)
localName
to attributes
if value is not null.
Parameter | Description |
---|---|
attributes | to add to. |
localName | of attribute to add. |
value | to add to attribute. |
static public void addAttribute(final AttributesImpl attributes, final String localName, final Object value)
//package com.java2s; import javax.xml.XMLConstants; import org.xml.sax.helpers.AttributesImpl; public class Main { /**/*from w w w . j av a2s . c om*/ * Adds attribute with <code>localName</code> to <code>attributes</code> if * value is not null. Follows the same rules as * {@link AttributesImpl#addAttribute(String, String, String, String, String)} * . * * @param attributes * to add to. * @param localName * of attribute to add. * @param value * to add to attribute. * @since 8.1 */ static public void addAttribute(final AttributesImpl attributes, final String localName, final Object value) { if (null != value) { attributes.addAttribute(XMLConstants.NULL_NS_URI, localName, localName, "", value.toString()); } } /** * Adds attribute with <code>prefix</code> and <code>localName</code> to * <code>attributes</code> if value is not null. Follows the same rules as * {@link AttributesImpl#addAttribute(String, String, String, String, String)} * . * * @param attributes * to add to. * @param prefix * of the attribute. * @param localName * of attribute to add. * @param value * to add to attribute. * @since 8.1 */ static public void addAttribute(final AttributesImpl attributes, final String prefix, final String localName, final Object value) { if (null != value) { attributes.addAttribute(XMLConstants.NULL_NS_URI, localName, prefix + ":" + localName, "", value.toString()); } } }