org.jasig.portal.serialize
Class CachingHTMLSerializer

java.lang.Object
  extended by org.jasig.portal.serialize.BaseMarkupSerializer
      extended by org.jasig.portal.serialize.HTMLSerializer
          extended by org.jasig.portal.serialize.CachingHTMLSerializer
All Implemented Interfaces:
IAnchoringSerializer, CachingSerializer, DOMSerializer, Serializer, org.xml.sax.ContentHandler, org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.LexicalHandler

public final class CachingHTMLSerializer
extends HTMLSerializer
implements CachingSerializer

Caching version of the HTML serializer

Author:
Peter Kharchenko, Assaf Arkin
See Also:
Serializer

Field Summary
(package private)  CharacterCachingWriter cacher
           
(package private)  java.lang.String encoding
           
 
Fields inherited from class org.jasig.portal.serialize.HTMLSerializer
XHTMLNamespace
 
Fields inherited from class org.jasig.portal.serialize.BaseMarkupSerializer
_docTypePublicId, _docTypeSystemId, _format, _indenting, _prefixes, _printer, _started
 
Constructor Summary
  CachingHTMLSerializer()
          Constructs a new serializer.
protected CachingHTMLSerializer(boolean xhtml, OutputFormat format)
          Constructs a new HTML/XHTML serializer depending on the value of xhtml.
  CachingHTMLSerializer(OutputFormat format)
          Constructs a new serializer.
  CachingHTMLSerializer(java.io.OutputStream output, OutputFormat format)
          Constructs a new serializer that writes to the specified output stream using the specified output format.
  CachingHTMLSerializer(java.io.Writer writer, OutputFormat format)
          Constructs a new serializer that writes to the specified writer using the specified output format.
 
Method Summary
 void flush()
          Flushes all the buffers
 java.lang.String getCache()
          Asks serializer for an accumulated cache content.
 void printRawCharacters(java.lang.String text)
          Allows one to print a String of characters directly to the output stream.
 void setDocumentStarted(boolean setting)
          Let the serializer know if the document has already been started.
 void setOutputByteStream(java.io.OutputStream output)
          Specifies an output stream to which the document should be serialized.
 void setOutputCharStream(java.io.Writer writer)
          Specifies a writer to which the document should be serialized.
 void setOutputFormat(OutputFormat format)
          Specifies an output format for this serializer.
 boolean startCaching()
          When starting caching if we are inside an opening tag the ">" will be written in order for the ">" to be included with the correct cache.
 boolean stopCaching()
          When stopping caching if we are inside an opening tag the ">" will be written in order for the ">" to be included with the correct cache.
 
Methods inherited from class org.jasig.portal.serialize.HTMLSerializer
appendAnchorIfNecessary, characters, characters, endElement, endElement, endElementIO, escapeURI, getEntityRef, serializeElement, startAnchoring, startDocument, startElement, startElement, stopAnchoring
 
Methods inherited from class org.jasig.portal.serialize.BaseMarkupSerializer
asContentHandler, asDocumentHandler, asDOMSerializer, attributeDecl, comment, comment, content, elementDecl, endCDATA, endDocument, endDTD, endEntity, endNonEscaping, endPrefixMapping, endPreserving, enterElementState, externalEntityDecl, getElementState, getPrefix, ignorableWhitespace, internalEntityDecl, isDocumentState, leaveElementState, notationDecl, prepare, printDoctypeURL, printEscaped, printEscaped, printText, printText, processingInstruction, processingInstructionIO, reset, serialize, serialize, serialize, serializeNode, serializePreRoot, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startNonEscaping, startPrefixMapping, startPreserving, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacher

CharacterCachingWriter cacher

encoding

java.lang.String encoding
Constructor Detail

CachingHTMLSerializer

public CachingHTMLSerializer()
Constructs a new serializer. The serializer cannot be used without calling setOutputCharStream(java.io.Writer) or setOutputByteStream(java.io.OutputStream) first.


CachingHTMLSerializer

protected CachingHTMLSerializer(boolean xhtml,
                                OutputFormat format)
Constructs a new HTML/XHTML serializer depending on the value of xhtml. The serializer cannot be used without calling init() first.

Parameters:
xhtml - True if XHTML serializing

CachingHTMLSerializer

public CachingHTMLSerializer(OutputFormat format)
Constructs a new serializer. The serializer cannot be used without calling setOutputCharStream(java.io.Writer) or setOutputByteStream(java.io.OutputStream) first.


CachingHTMLSerializer

public CachingHTMLSerializer(java.io.Writer writer,
                             OutputFormat format)
Constructs a new serializer that writes to the specified writer using the specified output format. If format is null, will use a default output format.

Parameters:
writer - The writer to use
format - The output format to use, null for the default

CachingHTMLSerializer

public CachingHTMLSerializer(java.io.OutputStream output,
                             OutputFormat format)
Constructs a new serializer that writes to the specified output stream using the specified output format. If format is null, will use a default output format.

Parameters:
output - The output stream to use
format - The output format to use, null for the default
Method Detail

setOutputCharStream

public void setOutputCharStream(java.io.Writer writer)
Description copied from interface: Serializer
Specifies a writer to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

Specified by:
setOutputCharStream in interface Serializer
Overrides:
setOutputCharStream in class BaseMarkupSerializer

setOutputByteStream

public void setOutputByteStream(java.io.OutputStream output)
Description copied from interface: Serializer
Specifies an output stream to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

Specified by:
setOutputByteStream in interface Serializer
Overrides:
setOutputByteStream in class BaseMarkupSerializer

setOutputFormat

public void setOutputFormat(OutputFormat format)
Description copied from interface: Serializer
Specifies an output format for this serializer. It the serializer has already been associated with an output format, it will switch to the new format. This method should not be called while the serializer is in the process of serializing a document.

Specified by:
setOutputFormat in interface Serializer
Overrides:
setOutputFormat in class HTMLSerializer
Parameters:
format - The output format to use

startCaching

public boolean startCaching()
                     throws java.io.IOException
When starting caching if we are inside an opening tag the ">" will be written in order for the ">" to be included with the correct cache. Normally the serializer doesn't know if a ">" or "/>" should be written until some content is received or the tag is closed. When starting caching after an opening tag the tag will be assumed to have some content and will write out the ">" before starting the cache.

Specified by:
startCaching in interface CachingSerializer
Returns:
false if the serializer is already caching.
Throws:
java.io.IOException

stopCaching

public boolean stopCaching()
                    throws java.io.IOException
When stopping caching if we are inside an opening tag the ">" will be written in order for the ">" to be included with the correct cache. Normally the serializer doesn't know if a ">" or "/>" should be written until some content is received or the tag is closed. When starting caching after an opening tag the tag will be assumed to have some content and will write out the ">" before starting the cache.

Specified by:
stopCaching in interface CachingSerializer
Returns:
false if the serializer was NOT caching.
Throws:
java.io.IOException

getCache

public java.lang.String getCache()
                          throws java.io.UnsupportedEncodingException,
                                 java.io.IOException
Description copied from interface: CachingSerializer
Asks serializer for an accumulated cache content.

Specified by:
getCache in interface CachingSerializer
Returns:
a String cache.
Throws:
java.io.UnsupportedEncodingException - if the OutputFormat specified unsupported encoding
java.io.IOException

printRawCharacters

public void printRawCharacters(java.lang.String text)
                        throws java.io.IOException
Allows one to print a String of characters directly to the output stream.

Specified by:
printRawCharacters in interface CachingSerializer
Parameters:
text - a String value
Throws:
java.io.IOException

setDocumentStarted

public void setDocumentStarted(boolean setting)
Let the serializer know if the document has already been started.

Specified by:
setDocumentStarted in interface CachingSerializer
Parameters:
setting - a boolean value

flush

public void flush()
           throws java.io.IOException
Description copied from interface: CachingSerializer
Flushes all the buffers

Specified by:
flush in interface CachingSerializer
Throws:
java.io.IOException - if an error occurs