Java XML Attribute Create writeSvgAttributes(XMLStreamWriter w, Supplier cssClass, Supplier fill, Supplier stroke)

Here you can find the source of writeSvgAttributes(XMLStreamWriter w, Supplier cssClass, Supplier fill, Supplier stroke)

Description

Write common attributes to the XMLStreamWriter

License

Apache License

Parameter

Parameter Description
w XMLStreamWriter
cssClass Supplier of css class or null if none
fill Supplier of fill or null if none
stroke Supplier of stroke or null if none <p>

Exception

Parameter Description
XMLStreamException on failure

Declaration

public static void writeSvgAttributes(XMLStreamWriter w, Supplier<String> cssClass, Supplier<String> fill,
        Supplier<String> stroke) throws XMLStreamException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.function.Supplier;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

public class Main {
    /**/*from  w  ww.  j  a v  a 2s  .  c o  m*/
     * Write common attributes to the {@link XMLStreamWriter}
     * <p>
     * @param w        XMLStreamWriter
     * @param cssClass Supplier of css class or null if none
     * @param fill     Supplier of fill or null if none
     * @param stroke   Supplier of stroke or null if none
     * <p>
     * @throws XMLStreamException on failure
     */
    public static void writeSvgAttributes(XMLStreamWriter w, Supplier<String> cssClass, Supplier<String> fill,
            Supplier<String> stroke) throws XMLStreamException {

        if (cssClass != null) {
            w.writeAttribute("class", cssClass.get());
        }

        if (fill != null) {
            w.writeAttribute("fill", fill.get());
        }

        if (stroke != null) {
            w.writeAttribute("stroke", stroke.get());
        }
    }
}

Related

  1. writeAttribute(XMLStreamWriter xmlw, String name, String value)
  2. writeAttributeEvent(XMLEvent event, XMLStreamWriter writer)
  3. writeAttributes(Node node, Writer out)
  4. writeBoolAttr(Element element, String attributeName, boolean value)
  5. writeOutAttributesForNode(String[][] attributes, Node node)
  6. writeXmlAttribute(XMLStreamWriter out, String name, Date value)