public final class XmlMethods extends Object
Contains one-liners for reading and writing to XML.
Constructor and Description |
---|
XmlMethods() |
Modifier and Type | Method and Description |
---|---|
static io.toro.gloop.object.cursor.GloopCursor |
getInputCursorFromFile(String filename,
String encoding,
List<String> xmlNodeNames,
io.toro.gloop.engine.GloopExecutionContext context)
Return a Gloop input cursor for reading the entries of a large XML file.
|
static io.toro.gloop.object.cursor.GloopCursor |
getInputCursorFromInputStream(InputStream inputStream,
String encoding,
List<String> xmlNodeNames,
io.toro.gloop.engine.GloopExecutionContext context)
Return a Gloop input cursor for reading the entries of a large XML stream.
|
static String |
gloopObjectToXmlString(io.toro.gloop.object.property.GloopObject gloopObject,
boolean insertHeader,
Map declaredNamespaces)
Marshals a Gloop object to an XML string.
|
static io.toro.gloop.object.property.GloopModel |
openXmlOutputCursor(String elementName,
boolean insertHeader,
Map declaredNamespaces,
boolean includeNamespaces,
String indent,
boolean closeDestination,
Object destination,
io.toro.gloop.engine.GloopExecutionContext context)
Return a Gloop output cursor for writing a large amount of XML data.
|
static io.toro.gloop.object.property.GloopObject |
readerToGloopObject(Reader xmlString)
Unmarshal an XML string within a reader to a Gloop object.
|
static void |
setCursorElementName(io.toro.gloop.cursor.xml.GloopXmlOutputCursor gloopCursor,
String elementName)
Sets the element name of an XML output cursor.
|
static io.toro.gloop.object.property.GloopObject |
streamToGloopObject(InputStream xmlString)
Unmarshal an XML string within an input stream to a Gloop object.
|
static void |
writeXml(Writer writer,
io.toro.gloop.object.property.GloopObject gloopObject,
boolean insertHeader,
boolean includeNamespaces,
Map declaredNamespaces,
boolean includeNulls)
Marshals a Gloop object to an XML string, written to a writer.
|
static io.toro.gloop.object.property.GloopObject |
xmlStringToGloopObject(String xmlString)
Unmarshal an XML string to a Gloop object.
|
@GloopParameter(name="gloopXml") public static String gloopObjectToXmlString(io.toro.gloop.object.property.GloopObject gloopObject, @GloopParameter(defaultValue="true") boolean insertHeader, Map declaredNamespaces)
Marshals a Gloop object to an XML string.
gloopObject
- the object to marshallinsertHeader
- flag stating whether to include the <xml version = "1.0">; headerdeclaredNamespaces
- map of pre-declared namespaces already declared (if any);
the key should contain the namespace URIs, and the values should contain their prefixespublic static io.toro.gloop.object.property.GloopObject xmlStringToGloopObject(String xmlString) throws SAXException
Unmarshal an XML string to a Gloop object.
xmlString
- the XML to convertSAXException
public static io.toro.gloop.object.property.GloopObject streamToGloopObject(InputStream xmlString) throws SAXException
Unmarshal an XML string within an input stream to a Gloop object.
xmlString
- the input stream containing the XMLSAXException
public static io.toro.gloop.object.property.GloopObject readerToGloopObject(Reader xmlString) throws SAXException
Unmarshal an XML string within a reader to a Gloop object.
xmlString
- the reader containing the XMLSAXException
public static void writeXml(@GloopParameter(allowNull=false) Writer writer, @GloopParameter(allowNull=false) io.toro.gloop.object.property.GloopObject gloopObject, @GloopParameter(defaultValue="false") boolean insertHeader, @GloopParameter(defaultValue="true") boolean includeNamespaces, Map declaredNamespaces, @GloopParameter(defaultValue="false") boolean includeNulls)
Marshals a Gloop object to an XML string, written to a writer.
writer
- writer to write the XML togloopObject
- Gloop object to marshalinsertHeader
- flag stating whether to include the <xml version = "1.0"> headerincludeNamespaces
- flag stating whether to include namespace declarationsdeclaredNamespaces
- map of pre-declared namespaces already declared (if any);
the key should contain the namespace URIs, and the values should contain their prefixesincludeNulls
- flag stating whether to include empty elements for properties that have a null value@GloopObjectParameter(value="gloopXmlCursor{\n gloopXmlCursor[]{\n nodeName\n cursorRecord:object\n }\n}") public static io.toro.gloop.object.cursor.GloopCursor getInputCursorFromFile(String filename, @GloopParameter(defaultValue="UTF-8") String encoding, List<String> xmlNodeNames, io.toro.gloop.engine.GloopExecutionContext context) throws FileNotFoundException, XMLStreamException, TransformerConfigurationException
Return a Gloop input cursor for reading the entries of a large XML file.
filename
- the name of the large XML file to readencoding
- encoding used by the XML filexmlNodeNames
- the element names the cursor should be seekingcontext
- the Gloop execution context (automatically mapped by Gloop)xmlNodeNames
parameterFileNotFoundException
XMLStreamException
TransformerConfigurationException
@GloopObjectParameter(value="gloopXmlCursor{\n gloopXmlCursor[]{\n nodeName\n cursorRecord:object\n }\n}") public static io.toro.gloop.object.cursor.GloopCursor getInputCursorFromInputStream(InputStream inputStream, @GloopParameter(defaultValue="UTF-8") String encoding, List<String> xmlNodeNames, io.toro.gloop.engine.GloopExecutionContext context) throws XMLStreamException, TransformerConfigurationException
Return a Gloop input cursor for reading the entries of a large XML stream.
inputStream
- input stream containing the XML to readencoding
- encoding used by the XML streamxmlNodeNames
- the element names the cursor should be seekingcontext
- the Gloop execution context (automatically mapped by Gloop)xmlNodeNames
parameterXMLStreamException
TransformerConfigurationException
@GloopObjectParameter(value="output{\n cursorXmlOutput{\n writer:object:printer used to write the xml out to::::java.io.Writer\n outputXmlCursor[]*{\n }\n }\n}") public static io.toro.gloop.object.property.GloopModel openXmlOutputCursor(String elementName, @GloopParameter(defaultValue="true") boolean insertHeader, Map declaredNamespaces, @GloopParameter(defaultValue="true") boolean includeNamespaces, @GloopParameter(allowNull=false,defaultValue=" ") String indent, @GloopParameter(defaultValue="true") boolean closeDestination, Object destination, io.toro.gloop.engine.GloopExecutionContext context) throws IOException
Return a Gloop output cursor for writing a large amount of XML data.
elementName
- the name given to the XML element that this cursor will writeinsertHeader
- whether to print the XML header <xml version = "1.0">declaredNamespaces
- map of declared namespaces for this XMLincludeNamespaces
- whether to include the namespaces in the XML elementsindent
- indent to use if pretty printing; default is 4 spacescloseDestination
- set to true if the cursor will close the underlying destination
after printing closing textdestination
- where to write the data to;
must be a StringBuffer
, Writer
, OutputStream
, Path
, or File
context
- the Gloop execution context (automatically mapped by Gloop)IOException
public static void setCursorElementName(io.toro.gloop.cursor.xml.GloopXmlOutputCursor gloopCursor, String elementName)
gloopCursor
- XML output cursorelementName
- element nameCopyright © 2020. All rights reserved.