org.syrup.helpers
Class XMLOutput

java.lang.Object
  extended byorg.syrup.helpers.XMLOutput
All Implemented Interfaces:
org.xml.sax.EntityResolver

public class XMLOutput
extends java.lang.Object
implements org.xml.sax.EntityResolver

Helper class that enables the serialization of Syrup types.

Author:
Robbert van Dalen

Constructor Summary
XMLOutput()
           
 
Method Summary
protected  void base64(byte[] b, org.apache.xml.serializer.SerializationHandler handler)
          Utility function that writes a Character SAX event with a base64 encoding of a byte array.
 void end(Context c, org.apache.xml.serializer.SerializationHandler handler)
          Description of the Method
 void end(LogEntry l, org.apache.xml.serializer.SerializationHandler handler)
           
 void end(PTask t, org.apache.xml.serializer.SerializationHandler handler)
          Ends the PTask to be serialized.
 void end(java.lang.String tag, org.apache.xml.serializer.SerializationHandler handler)
          Ends an element tag.
 void endDocument(java.lang.String tag, org.apache.xml.serializer.SerializationHandler handler)
          Ends the serialization with an end tag.
protected  void output(byte[] b, org.apache.xml.serializer.SerializationHandler handler)
          Writes the byte array as SAX event(s).
 void output(Context c, org.apache.xml.serializer.SerializationHandler handler)
          Serializes a Context.
 void output(Data d, org.apache.xml.serializer.SerializationHandler handler)
          Serializes a Data instance..
 void output(LogEntry l, org.apache.xml.serializer.SerializationHandler handler)
           
 void output(PTask t, org.apache.xml.serializer.SerializationHandler handler)
          Serializes a PTask.
protected  org.xml.sax.helpers.AttributesImpl portAttributes(Port p)
          Returns the mapped Attributes of a Port.
 org.xml.sax.InputSource resolveEntity(java.lang.String s1, java.lang.String s2)
           
 void start(Context c, org.apache.xml.serializer.SerializationHandler handler)
          Description of the Method
 void start(LogEntry l, org.apache.xml.serializer.SerializationHandler handler)
           
 void start(PTask t, org.apache.xml.serializer.SerializationHandler handler)
          Starts the PTask to be serialized.
 void start(java.lang.String tag, org.apache.xml.serializer.SerializationHandler handler)
          Starts a new element tag.
 void startDocument(java.lang.String tag, org.apache.xml.serializer.SerializationHandler handler)
          Starts the serialization with a start tag.
protected  org.xml.sax.helpers.AttributesImpl taskAttributes(PTask t)
          Returns the mapped Attributes of a PTask.
protected  org.xml.sax.helpers.AttributesImpl taskAttributes(Task t)
          Returns the mapped Attributes of a Task.
 org.apache.xml.serializer.SerializationHandler wrap(java.io.OutputStream o)
          Wraps an OutputStream with a SerializationHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLOutput

public XMLOutput()
Method Detail

wrap

public org.apache.xml.serializer.SerializationHandler wrap(java.io.OutputStream o)
                                                    throws java.lang.Exception
Wraps an OutputStream with a SerializationHandler.

Parameters:
o - The OutputStream to output XML.
Returns:
The SerializationHandler to send SAX-events to.
Throws:
java.lang.Exception

startDocument

public void startDocument(java.lang.String tag,
                          org.apache.xml.serializer.SerializationHandler handler)
                   throws java.lang.Exception
Starts the serialization with a start tag.

Parameters:
tag - The start tag.
handler - The serialization handler.
Throws:
java.lang.Exception

endDocument

public void endDocument(java.lang.String tag,
                        org.apache.xml.serializer.SerializationHandler handler)
                 throws java.lang.Exception
Ends the serialization with an end tag.

Parameters:
tag - The end tag.
handler - The serialization handler.
Throws:
java.lang.Exception

start

public void start(java.lang.String tag,
                  org.apache.xml.serializer.SerializationHandler handler)
           throws java.lang.Exception
Starts a new element tag.

Parameters:
tag - The element tag
handler - The serialization handler
Throws:
java.lang.Exception

end

public void end(java.lang.String tag,
                org.apache.xml.serializer.SerializationHandler handler)
         throws java.lang.Exception
Ends an element tag.

Parameters:
tag - The element tag
handler - The serialization handler
Throws:
java.lang.Exception

output

public void output(PTask t,
                   org.apache.xml.serializer.SerializationHandler handler)
            throws java.lang.Exception
Serializes a PTask.

Parameters:
t - The Ptask to be serialized.
handler - The serialization handler.
Throws:
java.lang.Exception

start

public void start(PTask t,
                  org.apache.xml.serializer.SerializationHandler handler)
           throws java.lang.Exception
Starts the PTask to be serialized.

Parameters:
t - The Ptask to start serializing.
handler - The serialization handler.
Throws:
java.lang.Exception

end

public void end(PTask t,
                org.apache.xml.serializer.SerializationHandler handler)
         throws java.lang.Exception
Ends the PTask to be serialized.

Parameters:
t - The Ptask to end serializing.
handler - The serialization handler.
Throws:
java.lang.Exception

output

public void output(Context c,
                   org.apache.xml.serializer.SerializationHandler handler)
            throws java.lang.Exception
Serializes a Context.

Parameters:
handler - The serialization handler.
c - The Context to be serialized
Throws:
java.lang.Exception

output

public void output(LogEntry l,
                   org.apache.xml.serializer.SerializationHandler handler)
            throws java.lang.Exception
Throws:
java.lang.Exception

start

public void start(LogEntry l,
                  org.apache.xml.serializer.SerializationHandler handler)
           throws java.lang.Exception
Throws:
java.lang.Exception

end

public void end(LogEntry l,
                org.apache.xml.serializer.SerializationHandler handler)
         throws java.lang.Exception
Throws:
java.lang.Exception

start

public void start(Context c,
                  org.apache.xml.serializer.SerializationHandler handler)
           throws java.lang.Exception
Description of the Method

Parameters:
c - Description of the Parameter
handler - Description of the Parameter
Throws:
java.lang.Exception

end

public void end(Context c,
                org.apache.xml.serializer.SerializationHandler handler)
         throws java.lang.Exception
Description of the Method

Parameters:
c - Description of the Parameter
handler - Description of the Parameter
Throws:
java.lang.Exception

output

public void output(Data d,
                   org.apache.xml.serializer.SerializationHandler handler)
            throws java.lang.Exception
Serializes a Data instance..

Parameters:
handler - The serialization handler.
d - The Data instance.
Throws:
java.lang.Exception

taskAttributes

protected org.xml.sax.helpers.AttributesImpl taskAttributes(Task t)
Returns the mapped Attributes of a Task.

Parameters:
t - The Task to map the Attributes to.
Returns:
The mapped Attributes of a Task.

portAttributes

protected org.xml.sax.helpers.AttributesImpl portAttributes(Port p)
Returns the mapped Attributes of a Port.

Parameters:
p - The Port to map the Attributes to.
Returns:
the mapped Attributes of a Port.

taskAttributes

protected org.xml.sax.helpers.AttributesImpl taskAttributes(PTask t)
Returns the mapped Attributes of a PTask.

Parameters:
t - The PTask to map the Attributes to.
Returns:
The mapped Attributes of a PTask.

output

protected void output(byte[] b,
                      org.apache.xml.serializer.SerializationHandler handler)
               throws java.lang.Exception
Writes the byte array as SAX event(s). If the byte array can be parsed by an XML reader, the fired SAX events will be the events generated by the XML Reader.
If the byte array can be turned into UTF-8 String, and a Characters SAX Event will be fired with the (encoded) UTF-8 String.
Otherwise, the byte array will be encoded in base64 and with this encoded string a Character event will be fired.

Parameters:
b - The byte array to be mapped to SAX events.
handler - The handler to send SAX events to.
Throws:
java.lang.Exception

base64

protected void base64(byte[] b,
                      org.apache.xml.serializer.SerializationHandler handler)
               throws java.lang.Exception
Utility function that writes a Character SAX event with a base64 encoding of a byte array.

Parameters:
b - The byte array to be encoded.
handler - The handler to send SAX events to.
Throws:
java.lang.Exception

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String s1,
                                             java.lang.String s2)
Specified by:
resolveEntity in interface org.xml.sax.EntityResolver