org.decisiondeck.jmcda.persist.xmcda2.utils
Class XMCDAWriteUtils

java.lang.Object
  extended by org.decisiondeck.jmcda.persist.xmcda2.utils.XMCDAWriteUtils

public class XMCDAWriteUtils
extends Object


Constructor Summary
XMCDAWriteUtils()
           
 
Method Summary
 void appendTo(Collection<? extends XmlObject> xFragments, XMCDADoc.XMCDA xmcda)
           
static void appendTo(Collection<? extends XmlObject> xFragments, XMCDADoc.XMCDA xmcda, boolean validate)
           
 void appendTo(XmlObject fragment, XMCDADoc.XMCDA xmcda)
           
static void appendTo(XmlObject fragment, XMCDADoc.XMCDA xmcda, boolean validate)
           
 boolean doesValidate()
          Retrieves the information whether this object only accepts to write valid documents.
 XMCDADoc getDoc(XmlObject fragment)
          Returns a new XMCDA document containing only the given fragment.
static XMCDADoc getDoc(XmlObject fragment, boolean validate)
          Returns a new XMCDA document containing only the given fragment.
 XmlOptions getSaveOptions()
          Retrieves a writable view of the options used to save XML streams.
 void setValidate(boolean validate)
          Enables or disables the check for validation before writing any document.
 void write(XMCDADoc doc, OutputSupplier<? extends OutputStream> destination)
          Writes the given XMCDA document to the given destination.
 void write(XMCDADoc doc, OutputSupplier<? extends OutputStream> destination, String versionToWrite)
          Writes the given XMCDA document to the given destination.
 void write(XmlObject fragment, OutputSupplier<? extends OutputStream> destination)
          Writes an XMCDA document containing only the given fragment to the given destination.
static void write(XmlObject fragment, OutputSupplier<? extends OutputStream> destination, boolean validate)
          Writes an XMCDA document containing only the given fragment to the given destination.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMCDAWriteUtils

public XMCDAWriteUtils()
Method Detail

appendTo

public static void appendTo(Collection<? extends XmlObject> xFragments,
                            XMCDADoc.XMCDA xmcda,
                            boolean validate)

appendTo

public void appendTo(Collection<? extends XmlObject> xFragments,
                     XMCDADoc.XMCDA xmcda)

appendTo

public static void appendTo(XmlObject fragment,
                            XMCDADoc.XMCDA xmcda,
                            boolean validate)

appendTo

public void appendTo(XmlObject fragment,
                     XMCDADoc.XMCDA xmcda)

write

public void write(XMCDADoc doc,
                  OutputSupplier<? extends OutputStream> destination)
           throws IOException
Writes the given XMCDA document to the given destination. The document must be valid, except if this object is specifically set to not validate documents.

Parameters:
doc - not null, must conform to the XMCDA schema.
destination - not null.
Throws:
IOException - if an exception happens while opening or closing the given writer, or while writing to the destination.

write

public void write(XmlObject fragment,
                  OutputSupplier<? extends OutputStream> destination)
           throws IOException
Writes an XMCDA document containing only the given fragment to the given destination. The fragment must be valid, except if this object is specifically set to not validate documents.

Parameters:
fragment - not null, must conform to the relevant schema, must be allowed as a direct child of the XMCDA tag.
destination - not null.
Throws:
IOException - if an exception happens while opening or closing the given writer, or while writing to the destination.

write

public static void write(XmlObject fragment,
                         OutputSupplier<? extends OutputStream> destination,
                         boolean validate)
                  throws IOException
Writes an XMCDA document containing only the given fragment to the given destination. If validate is true, the fragment must be valid and the written document is guaranteed to be valid.

Parameters:
fragment - not null, must conform to the relevant schema, must be allowed as a direct child of the XMCDA tag.
destination - not null.
validate - if true, this method will assert that the written document is valid. This is recommanded.
Throws:
IOException - if an exception happens while opening or closing the given writer, or while writing to the destination.

getDoc

public static XMCDADoc getDoc(XmlObject fragment,
                              boolean validate)
Returns a new XMCDA document containing only the given fragment.

Parameters:
fragment - not null, must conform to the relevant schema, must be allowed as a direct child of the XMCDA tag.
validate - if true, this method will assert that the returned document is valid. This is recommanded.
Returns:
not null.

getDoc

public XMCDADoc getDoc(XmlObject fragment)
Returns a new XMCDA document containing only the given fragment. The fragment must be valid, and the document is guaranteed to be valid, except if this object is not set to validate xml.

Parameters:
fragment - not null, must conform to the relevant schema, must be allowed as a direct child of the XMCDA tag.
Returns:
not null.
See Also:
setValidate(boolean)

doesValidate

public boolean doesValidate()
Retrieves the information whether this object only accepts to write valid documents. The default is true.

Returns:
true if this object validates documents before writing them.

setValidate

public void setValidate(boolean validate)
Enables or disables the check for validation before writing any document. The default is true, thus this object validates each document before returning or writing them. It is not recommanded to disable validation but it can be useful for debug.

Parameters:
validate - false to allow invalid documents.

write

public void write(XMCDADoc doc,
                  OutputSupplier<? extends OutputStream> destination,
                  String versionToWrite)
           throws IOException
Writes the given XMCDA document to the given destination. The document must be valid, except if this object is specifically set to not validate documents.

Parameters:
doc - not null, must conform to the XMCDA schema.
destination - not null.
versionToWrite - null for .
Throws:
IOException - if an exception happens while opening or closing the given writer, or while writing to the destination.
See Also:
setValidate(boolean)

getSaveOptions

public XmlOptions getSaveOptions()
Retrieves a writable view of the options used to save XML streams. Default options are to use pretty print and to use the UTF-8 encoding.

Returns:
not null.


Copyright © 2011. All Rights Reserved.