- java.lang.Object
-
- com.powsybl.commons.xml.XmlUtil
-
public final class XmlUtil extends Object
- Author:
- Geoffroy Jamgotchian
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
XmlUtil.XmlEventHandler
static interface
XmlUtil.XmlEventHandlerWithDepth
An richer event handler which give element depth with each start event.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
consumeOptionalBoolAttribute(XMLStreamReader reader, String attributeName, Consumer<Boolean> consumer)
static void
consumeOptionalIntAttribute(XMLStreamReader reader, String attributeName, IntConsumer consumer)
static void
gcXmlInputFactory(XMLInputFactory xmlInputFactory)
static XMLStreamWriter
initializeWriter(boolean indent, String indentString, OutputStream os)
static XMLStreamWriter
initializeWriter(boolean indent, String indentString, OutputStream os, Charset charset)
static XMLStreamWriter
initializeWriter(boolean indent, String indentString, Writer writer)
static boolean
readBoolAttribute(XMLStreamReader reader, String attributeName)
static double
readDoubleAttribute(XMLStreamReader reader, String attributeName)
static float
readFloatAttribute(XMLStreamReader reader, String attributeName)
static int
readIntAttribute(XMLStreamReader reader, String attributeName)
static boolean
readOptionalBoolAttribute(XMLStreamReader reader, String attributeName, boolean defaultValue)
static double
readOptionalDoubleAttribute(XMLStreamReader reader, String attributeName)
static double
readOptionalDoubleAttribute(XMLStreamReader reader, String attributeName, double defaultValue)
static <E extends Enum<E>>
EreadOptionalEnum(XMLStreamReader reader, String attributeName, Class<E> enumClass)
static float
readOptionalFloatAttribute(XMLStreamReader reader, String attributeName)
static float
readOptionalFloatAttribute(XMLStreamReader reader, String attributeName, float defaultValue)
static Integer
readOptionalIntegerAttribute(XMLStreamReader reader, String attributeName)
static int
readOptionalIntegerAttribute(XMLStreamReader reader, String attributeName, int defaultValue)
static String
readText(String endElementName, XMLStreamReader reader)
static String
readUntilEndElement(String endElementName, XMLStreamReader reader, XmlUtil.XmlEventHandler eventHandler)
static String
readUntilEndElementWithDepth(String endElementName, XMLStreamReader reader, XmlUtil.XmlEventHandlerWithDepth eventHandler)
static void
readUntilStartElement(String[] elements, XMLStreamReader reader, XmlUtil.XmlEventHandler handler)
static void
readUntilStartElement(String path, XMLStreamReader reader, XmlUtil.XmlEventHandler handler)
static void
writeDouble(String name, double value, XMLStreamWriter writer)
static void
writeFloat(String name, float value, XMLStreamWriter writer)
static void
writeInt(String name, int value, XMLStreamWriter writer)
static void
writeOptionalBoolean(String name, boolean value, boolean absentValue, XMLStreamWriter writer)
static void
writeOptionalBoolean(String name, Optional<Boolean> value, XMLStreamWriter writer)
static void
writeOptionalDouble(String name, double value, double absentValue, XMLStreamWriter writer)
static <E extends Enum<E>>
voidwriteOptionalEnum(String name, E value, XMLStreamWriter writer)
static void
writeOptionalFloat(String name, float value, float absentValue, XMLStreamWriter writer)
static void
writeOptionalInt(String name, int value, int absentValue, XMLStreamWriter writer)
static void
writeOptionalString(String name, String value, XMLStreamWriter writer)
-
-
-
Method Detail
-
readUntilStartElement
public static void readUntilStartElement(String path, XMLStreamReader reader, XmlUtil.XmlEventHandler handler) throws XMLStreamException
- Throws:
XMLStreamException
-
readUntilStartElement
public static void readUntilStartElement(String[] elements, XMLStreamReader reader, XmlUtil.XmlEventHandler handler) throws XMLStreamException
- Throws:
XMLStreamException
-
readUntilEndElement
public static String readUntilEndElement(String endElementName, XMLStreamReader reader, XmlUtil.XmlEventHandler eventHandler) throws XMLStreamException
- Throws:
XMLStreamException
-
readUntilEndElementWithDepth
public static String readUntilEndElementWithDepth(String endElementName, XMLStreamReader reader, XmlUtil.XmlEventHandlerWithDepth eventHandler) throws XMLStreamException
- Throws:
XMLStreamException
-
readText
public static String readText(String endElementName, XMLStreamReader reader) throws XMLStreamException
- Throws:
XMLStreamException
-
writeOptionalBoolean
public static void writeOptionalBoolean(String name, boolean value, boolean absentValue, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
writeOptionalBoolean
public static void writeOptionalBoolean(String name, Optional<Boolean> value, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
writeDouble
public static void writeDouble(String name, double value, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
writeOptionalDouble
public static void writeOptionalDouble(String name, double value, double absentValue, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
writeFloat
public static void writeFloat(String name, float value, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
writeOptionalFloat
public static void writeOptionalFloat(String name, float value, float absentValue, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
writeInt
public static void writeInt(String name, int value, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
writeOptionalInt
public static void writeOptionalInt(String name, int value, int absentValue, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
writeOptionalString
public static void writeOptionalString(String name, String value, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
writeOptionalEnum
public static <E extends Enum<E>> void writeOptionalEnum(String name, E value, XMLStreamWriter writer) throws XMLStreamException
- Throws:
XMLStreamException
-
readIntAttribute
public static int readIntAttribute(XMLStreamReader reader, String attributeName)
-
readBoolAttribute
public static boolean readBoolAttribute(XMLStreamReader reader, String attributeName)
-
readOptionalBoolAttribute
public static boolean readOptionalBoolAttribute(XMLStreamReader reader, String attributeName, boolean defaultValue)
-
readDoubleAttribute
public static double readDoubleAttribute(XMLStreamReader reader, String attributeName)
-
readOptionalDoubleAttribute
public static double readOptionalDoubleAttribute(XMLStreamReader reader, String attributeName)
-
readOptionalDoubleAttribute
public static double readOptionalDoubleAttribute(XMLStreamReader reader, String attributeName, double defaultValue)
-
readOptionalIntegerAttribute
public static Integer readOptionalIntegerAttribute(XMLStreamReader reader, String attributeName)
-
readOptionalIntegerAttribute
public static int readOptionalIntegerAttribute(XMLStreamReader reader, String attributeName, int defaultValue)
-
readFloatAttribute
public static float readFloatAttribute(XMLStreamReader reader, String attributeName)
-
readOptionalFloatAttribute
public static float readOptionalFloatAttribute(XMLStreamReader reader, String attributeName)
-
readOptionalFloatAttribute
public static float readOptionalFloatAttribute(XMLStreamReader reader, String attributeName, float defaultValue)
-
readOptionalEnum
public static <E extends Enum<E>> E readOptionalEnum(XMLStreamReader reader, String attributeName, Class<E> enumClass)
-
consumeOptionalBoolAttribute
public static void consumeOptionalBoolAttribute(XMLStreamReader reader, String attributeName, Consumer<Boolean> consumer)
-
consumeOptionalIntAttribute
public static void consumeOptionalIntAttribute(XMLStreamReader reader, String attributeName, IntConsumer consumer)
-
initializeWriter
public static XMLStreamWriter initializeWriter(boolean indent, String indentString, OutputStream os) throws XMLStreamException
- Throws:
XMLStreamException
-
initializeWriter
public static XMLStreamWriter initializeWriter(boolean indent, String indentString, OutputStream os, Charset charset) throws XMLStreamException
- Throws:
XMLStreamException
-
initializeWriter
public static XMLStreamWriter initializeWriter(boolean indent, String indentString, Writer writer) throws XMLStreamException
- Throws:
XMLStreamException
-
gcXmlInputFactory
public static void gcXmlInputFactory(XMLInputFactory xmlInputFactory)
-
-