com.edustructures.sifworks
Class SIFWriter

java.lang.Object
  extended by com.edustructures.sifworks.SIFWriter

public class SIFWriter
extends java.lang.Object

Renders a SIFElement to an XML stream in SIF format.

Agents do not typically use the SIFWriter class directly, but may do so to render a SIF Data Object or a SIF Message to an output stream. The following code demonstrates how to write a SIFDataObject to System.out:

       StudentPersonal sp = ...
       SIFWriter out = new SIFWriter( System.out );
       out.write( sp );
  

Version:
1.0

Constructor Summary
SIFWriter(java.io.OutputStream out)
          Creates an instance of SIFWriter to wrap the given stream
SIFWriter(java.io.OutputStream out, boolean autoFlush)
          Creates an instance of SIFWriter to wrap the given stream
SIFWriter(java.io.OutputStream out, Zone zone)
          Creates an instance of SIFWriter to wrap the given stream.
SIFWriter(java.io.Writer out)
          Constructor
SIFWriter(java.io.Writer out, boolean autoFlush)
          Constructor
SIFWriter(java.io.Writer out, Zone zone)
          Constructor that allows agent properties to be passed to the SIFWriter
 
Method Summary
 void clearFilter()
          Clears the filter previously set with the setFilter method
 void close()
           
 void flush()
           
 void setFilter(ElementDef[] elements)
          Places a filter on this SIFWriter such that only elements (and their children) identified in the array will be included in the output.
 void suppressNamespace(boolean suppress)
          By Default, SIFWriter writes an XML Namespace when it starts writing to an element stream.
 void write(char[] chars)
           
 void write(SIFDataObject o)
          Write a SIF Data Object in the version of SIF in effect for that object.
 void write(SIFDataObjectXML o)
          Write a SIF Data Object to the output stream using whatever XML content is currently defined for that object.
 void write(SIFElement o)
          Write a SIF element in the version of SIF currently in effect for this SIFWriter.
 void write(SIFMessagePayload o)
          Write a SIF Message in the version of SIF in effect for that object.
 void write(SIFVersion version, SIFElement o)
          Write a SIF element in the version of SIF specified.
 void write(java.lang.String value)
          Writes the given string, after xml encoding it.
 void writeRaw(java.lang.String value)
          Writes the given string without doing any xml encoding
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SIFWriter

public SIFWriter(java.io.OutputStream out)
Creates an instance of SIFWriter to wrap the given stream

Parameters:
out - The OutputStream to write to, using SIF Encoding rules

SIFWriter

public SIFWriter(java.io.OutputStream out,
                 boolean autoFlush)
Creates an instance of SIFWriter to wrap the given stream

Parameters:
out - The OutputStream to write elements to, using SIF Encoding rules
autoFlush - true to flush the stream after each write

SIFWriter

public SIFWriter(java.io.OutputStream out,
                 Zone zone)
Creates an instance of SIFWriter to wrap the given stream. This constructor allows agent properties to be passed to the SIFWriter

The agent property, adk.compatibility.enableXMLEscaping is checked in this constructor. If the falue is false, XmlElement and Attribute data will not be escaped

Parameters:
out - The OutputStream to write elements to
zone - the Zone to read properties from

SIFWriter

public SIFWriter(java.io.Writer out)
Constructor

Parameters:
out - The Writer to write elements to

SIFWriter

public SIFWriter(java.io.Writer out,
                 Zone zone)
Constructor that allows agent properties to be passed to the SIFWriter

The agent property, adk.compatibility.enableXMLEscaping is checked in this constructor. If the falue is false, XmlElement and Attribute data will not be escaped

Parameters:
out - the Writer to write elements to
zone - the Zone to read properties from

SIFWriter

public SIFWriter(java.io.Writer out,
                 boolean autoFlush)
Constructor

Parameters:
out - The Writer to write elements to
autoFlush - true to flush the Writer after each write
Method Detail

setFilter

public void setFilter(ElementDef[] elements)
Places a filter on this SIFWriter such that only elements (and their children) identified in the array will be included in the output. Note that attributes are always included even if not specified in the filter list, as are top-level SIF Data Objects like StudentPersonal.

The filter remains in effect until the clearFilter method is called or a null array is passed to this method.

Parameters:
elements - An array of ElementDef constants from the SIFDTD class that identify elements to include in the output, or null to clear the current filter

clearFilter

public void clearFilter()
Clears the filter previously set with the setFilter method


write

public void write(SIFMessagePayload o)
Write a SIF Message in the version of SIF in effect for that object. To change the version of SIF that is used, call the SIFMessagePayload.setSIFVersion method prior to calling this function.

Parameters:
o - The SIF Message to write to the output stream

write

public void write(SIFDataObject o)
Write a SIF Data Object in the version of SIF in effect for that object. To change the version of SIF that is used, call the SIFDataObject.setSIFVersion method prior to calling this function.

Parameters:
o - The SIFDataObject instance to write to the output stream

write

public void write(SIFDataObjectXML o)
Write a SIF Data Object to the output stream using whatever XML content is currently defined for that object.

Parameters:
o - The SIFDataObjectXML instance to write to the output stream

write

public void write(SIFVersion version,
                  SIFElement o)
Write a SIF element in the version of SIF specified.

Parameters:
version - The version of SIF to use when rendering the SIF element
o - The SIF Element instance to write to the output stream

write

public void write(SIFElement o)
Write a SIF element in the version of SIF currently in effect for this SIFWriter.

Parameters:
o - The SIF Element instance to write to the output stream

writeRaw

public void writeRaw(java.lang.String value)
Writes the given string without doing any xml encoding

Parameters:
value -

write

public void write(java.lang.String value)
Writes the given string, after xml encoding it.

Parameters:
value -

write

public void write(char[] chars)

flush

public void flush()

close

public void close()

suppressNamespace

public void suppressNamespace(boolean suppress)
By Default, SIFWriter writes an XML Namespace when it starts writing to an element stream. If this is not desirable, it can be suppressed with this call

Parameters:
suppress -


Copyright © 2001-2007 Edustructures LLC. All Rights Reserved. SIFWorks® and ADK® are registered trademarks of Edustructures LLC. SIF™ and Schools Interoperability Framework are trademarks of the Schools Interoperability Framework Association.