org.ow2.petals.component.framework.api.util
Interface SourceUtil


public interface SourceUtil

Contains utilities for the Source management.

Author:
Frederic Gardes

Method Summary
 Document createDocument(Source source)
          Create a Document from a Source.
 Document createDocument(Source source, boolean forkSource)
          Create a Document from a Source.
 DOMSource createDOMSource(Document document)
          Create a DOM Source from the DOM document.
 Document createSoapFaultDocument(Throwable e, QName errorCode)
           Creates an SOAP fault, as a DOM document, according to provided exception and code:
<s:Fault xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <faultcode>{org.objectweb.petals}ERROR</faultcode>
   <faultstring>mesage</faultstring>
   <faultactor>component</faultactor>
   <detail>
      ...
 Source createSource(String message)
          Create a Source from the String.
 Source createSource(String message, String charFormat)
          Create a Source from the String with a specified encoding format.
 StreamSource createStreamSource(Document document)
          Create a Stream Source from the DOM document.
 String createString(Source source)
          Create a String from a Source.
 String createString(Source source, boolean forkSource)
          Create a String from a Source.
 boolean isDOM3(Document document)
          Test if the document is a DOM3 document
 

Method Detail

createSoapFaultDocument

Document createSoapFaultDocument(Throwable e,
                                 QName errorCode)

Creates an SOAP fault, as a DOM document, according to provided exception and code:
<s:Fault xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <faultcode>{org.objectweb.petals}ERROR</faultcode>
   <faultstring>mesage</faultstring>
   <faultactor>component</faultactor>
   <detail>
      ...
   </detail>
<s:Fault>

If the provided exception is an instance of DocumentException:

If the provided exception is an instance of FaultException:

otherwise:

Parameters:
e - An exception used to provide faultstring and detail
errorCode - The QName of the fault code. It is not used if the exception is an instance of FaultException or DocumentException.
Returns:
A Document containing the Soap Fault

createSource

Source createSource(String message)
                    throws PEtALSCDKException
Create a Source from the String. The message must be a valid XML String. If an encoding is specified in the XML String header it is used to create the XML bytes stream, otherwise the default JVM encoding is used.

Parameters:
message - a valid XML String
Returns:
the Source built from the XML String
Throws:
PEtALSCDKException - if an error occurs during Source creation

createSource

Source createSource(String message,
                    String charFormat)
                    throws PEtALSCDKException
Create a Source from the String with a specified encoding format. The message must be a valid XML String. The encoding must match the XML declaration in the message.

Parameters:
message - a valid XML String
charFormat - the encoding format, must be non null
Returns:
the Source built from the XML String
Throws:
PEtALSCDKException - if an error occurs during Source creation

createDOMSource

DOMSource createDOMSource(Document document)
Create a DOM Source from the DOM document.

Parameters:
document - A DOM document
Returns:
the DOM source built from the DOM document

createStreamSource

StreamSource createStreamSource(Document document)
                                throws PEtALSCDKException
Create a Stream Source from the DOM document.

Parameters:
document - A DOM document
Returns:
the Stream source built from the DOM document
Throws:
PEtALSCDKException

createDocument

Document createDocument(Source source)
                        throws PEtALSCDKException
Create a Document from a Source.
-If the Source is a StreamSource, the source would be still available.
-If the Source is a DomSource and contains a Document, the returned document is a clone of this document.

Parameters:
source - the Source
Returns:
the DOM document built from the Source
Throws:
PEtALSCDKException

createDocument

Document createDocument(Source source,
                        boolean forkSource)
                        throws PEtALSCDKException
Create a Document from a Source.
-If the Source is a StreamSource and forkSource is set to true, the source would be still available. Otherwise the source is no more available.
If the Source is a DomSource and contains a Document and forkSource is set to true, the returned document is a clone of this document. Otherwise the original Document is returned.

Parameters:
source - the Source
forkSource - true to fork the content of the source if necessary
Returns:
a DOM document
Throws:
PEtALSCDKException

createString

String createString(Source source)
                    throws PEtALSCDKException
Create a String from a Source.
-If the Source is a StreamSource, the source would be still available.

Parameters:
source - the Source
Returns:
the String built from the Source
Throws:
PEtALSCDKException

createString

String createString(Source source,
                    boolean forkSource)
                    throws PEtALSCDKException
Create a String from a Source.
-If the Source is a StreamSource and forkSource is set to true, the source would be still available. Otherwise the source is no more available.

Parameters:
source - the Source
Returns:
the String built from the Source
Throws:
PEtALSCDKException

isDOM3

boolean isDOM3(Document document)
Test if the document is a DOM3 document

Parameters:
document - the document to test
Returns:
true if the document is DOM3, false else


Copyright © 2005-2012 Petals Link (EBM Websourcing). All Rights Reserved.