org.jbind.xml.facade
Class JBindFacade

java.lang.Object
  extended byorg.jbind.xml.facade.JBindFacade

public class JBindFacade
extends java.lang.Object

Facade of the JBind framework that provides easy access to its core functionalities.


Field Summary
static java.lang.String DEFAULT_ENCODING
          Default encoding ("UTF-8").
 
Method Summary
static IApplicationCode createApplicationCode(org.xml.sax.InputSource anInputSource, IDataContext aContext)
           
static IApplicationCode createApplicationCode(java.net.URL aUrl, IDataContext aContext)
           
static IConfigurationCode createConfigurationCode(org.xml.sax.InputSource anInputSource, IDataContext aContext)
           
static IConfigurationCode createConfigurationCode(java.net.URL aUrl, IDataContext aContext)
           
static IImplBuilder createImplBuilder(IDataContext aContext)
          Creates a data builder.
static IImplBuilder createImplBuilder(IDataContext aContext, boolean aUseBuiltInClassesOnly)
           
static javax.xml.transform.sax.SAXSource createSaxSource(IAnyTypeData aData)
          Creates a SAXSource that can be supplied to a stylesheet processor.
static ISchemaReader createSchemaReader()
          Creates a schema reader.
static int execute(org.xml.sax.InputSource anInputSource, IDataContext aContext)
           
static int execute(java.net.URL aUrl, IDataContext aContext)
           
static java.lang.String marshal(IAnyTypeData aData, java.util.Map aNamespaceToPrefixMapping, java.util.Map aTopLevelAttributes)
          Marshals a data object.
static void marshal(java.io.OutputStream anOutputStream, java.lang.String anEncoding, boolean anOutputXmlDeclaration, IAnyTypeData aData, java.util.Map aNamespaceToPrefixMapping, java.util.Map aTopLevelAttributes)
          Marshals a data object.
static void marshal(java.io.Writer aWriter, IAnyTypeData aData, java.util.Map aNamespaceToPrefixMapping, java.util.Map aTopLevelAttributes)
          Marshals a data object.
static void outputSaxEvents(IAnyTypeData aData, org.xml.sax.ContentHandler aHandler)
           
static void outputXmlDeclaration(java.io.Writer aWriter, java.lang.String anEncoding)
          Outputs the XML declaration "
static ISchema readSchema(java.net.URL aUrl)
          Reads a schema.
static IAnyTypeData unmarshal(org.xml.sax.InputSource anInputSource, IDataContext aContext)
          Unmarshals an instance document.
static java.util.List unmarshal(java.util.List aUrls, IDataContext aContext)
          Unmarshals a list of instance documents.
static IAnyTypeData unmarshal(java.net.URL aUrl, IDataContext aContext)
          Unmarshals an instance document.
static void validateData(IAnyTypeData aData, IDataContext aContext)
          Validates a data object.
static boolean valueEquals(IAnyTypeData aData1, IAnyTypeData aData2)
          Check value equality of two data objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

public static final java.lang.String DEFAULT_ENCODING
Default encoding ("UTF-8").

See Also:
Constant Field Values
Method Detail

createSchemaReader

public static ISchemaReader createSchemaReader()
Creates a schema reader.

Returns:
(required).

readSchema

public static ISchema readSchema(java.net.URL aUrl)
                          throws XmlException
Reads a schema.

The schema will use generated classes and their package must be configured in the schema itself or by the Config class.

Parameters:
aUrl - (required).
Returns:
(required).
Throws:
XmlException

createImplBuilder

public static IImplBuilder createImplBuilder(IDataContext aContext)
Creates a data builder.

Parameters:
aContext - (optional).
Returns:
(required).

createImplBuilder

public static IImplBuilder createImplBuilder(IDataContext aContext,
                                             boolean aUseBuiltInClassesOnly)

validateData

public static void validateData(IAnyTypeData aData,
                                IDataContext aContext)
                         throws XmlException
Validates a data object.

Parameters:
aData - (required).
aContext - (optional).
Throws:
XmlException - Raised iff the data object is not valid.

unmarshal

public static java.util.List unmarshal(java.util.List aUrls,
                                       IDataContext aContext)
                                throws XmlException
Unmarshals a list of instance documents.

Parameters:
aUrls - (required). A list of URLs.
aContext - (optional).
Returns:
(required). A list of IAnyTypeData - the root data of the unmarshalled documents in the same sequence as the supplied URLs.
Throws:
XmlException - Raised iff an instance document could not be unmarshalled.

unmarshal

public static IAnyTypeData unmarshal(java.net.URL aUrl,
                                     IDataContext aContext)
                              throws XmlException
Unmarshals an instance document.

Parameters:
aUrl - (required).
aContext - (optional).
Returns:
(required). The root data oj the instance.
Throws:
XmlException - Raised iff the instance document could not be unmarshalled.

unmarshal

public static IAnyTypeData unmarshal(org.xml.sax.InputSource anInputSource,
                                     IDataContext aContext)
                              throws XmlException
Unmarshals an instance document.

Parameters:
anInputSource - (required).
aContext - (optional).
Returns:
(required).
Throws:
XmlException - Raised iff the instance document could not be unmarshalled.

createConfigurationCode

public static IConfigurationCode createConfigurationCode(java.net.URL aUrl,
                                                         IDataContext aContext)

createConfigurationCode

public static IConfigurationCode createConfigurationCode(org.xml.sax.InputSource anInputSource,
                                                         IDataContext aContext)

createApplicationCode

public static IApplicationCode createApplicationCode(org.xml.sax.InputSource anInputSource,
                                                     IDataContext aContext)

createApplicationCode

public static IApplicationCode createApplicationCode(java.net.URL aUrl,
                                                     IDataContext aContext)

execute

public static int execute(org.xml.sax.InputSource anInputSource,
                          IDataContext aContext)
                   throws XmlException
Throws:
XmlException

execute

public static int execute(java.net.URL aUrl,
                          IDataContext aContext)
                   throws XmlException
Throws:
XmlException

marshal

public static void marshal(java.io.Writer aWriter,
                           IAnyTypeData aData,
                           java.util.Map aNamespaceToPrefixMapping,
                           java.util.Map aTopLevelAttributes)
                    throws XmlException
Marshals a data object. No initial XML declaration (<?xml ... ?>) is output.

Parameters:
aData - (required).
aWriter - (required).
aNamespaceToPrefixMapping - (optional). An initial mapping that is output as "xmlns" attributes. If the data object that is unmarshalled uses namespaces that are not contained in the initial mapping then new mappings are created.
aTopLevelAttributes - (optional). A set of attributes that is output as additional attributes of the root element. This feature can be used to supply schema location attributes.
Throws:
XmlException - Raised iff the data object could not be unmarshalled.

marshal

public static java.lang.String marshal(IAnyTypeData aData,
                                       java.util.Map aNamespaceToPrefixMapping,
                                       java.util.Map aTopLevelAttributes)
                                throws XmlException
Marshals a data object. No initial XML declaration (<?xml ... ?>) is output.

Parameters:
aData - (required). The data that is marshalled.
aNamespaceToPrefixMapping - (optional). (cf. marshal(Writer, IAnyTypeData, Map, Map))
aTopLevelAttributes - (optional). (cf. marshal(Writer, IAnyTypeData, Map, Map))
Throws:
XmlException

marshal

public static void marshal(java.io.OutputStream anOutputStream,
                           java.lang.String anEncoding,
                           boolean anOutputXmlDeclaration,
                           IAnyTypeData aData,
                           java.util.Map aNamespaceToPrefixMapping,
                           java.util.Map aTopLevelAttributes)
                    throws XmlException
Marshals a data object.

Parameters:
anOutputStream - (required). The stream that is used for output.
anEncoding - (optional). If no encoding is specified then the DEFAULT_ENCODING is used.
anOutputXmlDeclaration - Controls whether the initial XML declaration <?xml version="1.0" encoding="..."?> or not.
aData - (required). The data that is marshalled.
aNamespaceToPrefixMapping - (optional). (cf. marshal(Writer, IAnyTypeData, Map, Map))
aTopLevelAttributes - (optional). (cf. marshal(Writer, IAnyTypeData, Map, Map))
Throws:
XmlException

outputXmlDeclaration

public static void outputXmlDeclaration(java.io.Writer aWriter,
                                        java.lang.String anEncoding)
                                 throws XmlException
Outputs the XML declaration ""

Parameters:
aWriter - (required).
anEncoding - (required).
Throws:
XmlException

outputSaxEvents

public static void outputSaxEvents(IAnyTypeData aData,
                                   org.xml.sax.ContentHandler aHandler)
                            throws XmlException
Throws:
XmlException

valueEquals

public static boolean valueEquals(IAnyTypeData aData1,
                                  IAnyTypeData aData2)
Check value equality of two data objects. For simple data objects their simple content is compared whereas for complex data object the whole data trees (including attributes) are compared.

Parameters:
aData1 - (optional).
aData2 - (optional).
Returns:
Returns true if the two data objects have the same value.

createSaxSource

public static javax.xml.transform.sax.SAXSource createSaxSource(IAnyTypeData aData)
Creates a SAXSource that can be supplied to a stylesheet processor.

Parameters:
aData - (required). The data that is output by SAX.
Returns:
(required).