org.jasig.portal.serialize
Class CachingXHTMLSerializer

java.lang.Object
  extended by org.jasig.portal.serialize.BaseMarkupSerializer
      extended by org.jasig.portal.serialize.HTMLSerializer
          extended by org.jasig.portal.serialize.XHTMLSerializer
              extended by org.jasig.portal.serialize.CachingXHTMLSerializer
All Implemented Interfaces:
IAnchoringSerializer, CachingSerializer, DOMSerializer, MarkupSerializer, Serializer, ContentHandler, DocumentHandler, DTDHandler, DeclHandler, LexicalHandler

public final class CachingXHTMLSerializer
extends XHTMLSerializer
implements CachingSerializer

Caching version of the XHTML serializer

Author:
Peter Kharchenko, Assaf Arkin
See Also:
Serializer

Field Summary
 
Fields inherited from class org.jasig.portal.serialize.HTMLSerializer
XHTMLNamespace
 
Fields inherited from class org.jasig.portal.serialize.BaseMarkupSerializer
_docTypePublicId, _docTypeSystemId, _encodingInfo, _format, _indenting, _prefixes, _printer, _started, anchorId, fCurrentNode, fDOMError, fDOMErrorHandler, fDOMFilter, features, fStrBuffer
 
Constructor Summary
CachingXHTMLSerializer()
          Constructs a new serializer.
CachingXHTMLSerializer(OutputFormat format)
          Constructs a new serializer.
CachingXHTMLSerializer(OutputStream output, OutputFormat format)
          Constructs a new serializer that writes to the specified output stream using the specified output format.
CachingXHTMLSerializer(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
 String getCache()
          Asks serializer for an accumulated cache content.
 void printRawCharacters(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(OutputStream output)
          Specifies an output stream to which the document should be serialized.
 void setOutputCharStream(Writer writer)
          Specifies a writer to which the document should be serialized.
 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.XHTMLSerializer
setOutputFormat
 
Methods inherited from class org.jasig.portal.serialize.HTMLSerializer
appendAnchorIfNecessary, characters, characters, endElement, endElement, endElementIO, escapeURI, getEntityRef, serializeElement, setXHTMLNamespace, shouldNotExpandEndTagForEmptyElement, startAnchoring, startDocument, startElement, startElement, stopAnchoring
 
Methods inherited from class org.jasig.portal.serialize.BaseMarkupSerializer
asContentHandler, asDocumentHandler, asDOMSerializer, attributeDecl, checkUnboundNamespacePrefixedNode, comment, comment, content, elementDecl, endCDATA, endDocument, endDTD, endEntity, endNonEscaping, endPrefixMapping, endPreserving, enterElementState, externalEntityDecl, fatalError, getElementState, getPrefix, ignorableWhitespace, internalEntityDecl, isDocumentState, leaveElementState, modifyDOMError, notationDecl, prepare, printCDATAText, printDoctypeURL, printEscaped, printEscaped, printText, printText, processingInstruction, processingInstructionIO, reset, serialize, serialize, serialize, serializeNode, serializePreRoot, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startNonEscaping, startPrefixMapping, startPreserving, surrogates, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
 
Methods inherited from interface org.xml.sax.DocumentHandler
characters, endDocument, endElement, ignorableWhitespace, processingInstruction, setDocumentLocator, startDocument, startElement
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.xml.sax.DTDHandler
notationDecl, unparsedEntityDecl
 
Methods inherited from interface org.xml.sax.ext.DeclHandler
attributeDecl, elementDecl, externalEntityDecl, internalEntityDecl
 
Methods inherited from interface org.jasig.portal.serialize.DOMSerializer
serialize, serialize, serialize
 
Methods inherited from interface org.jasig.portal.serialize.Serializer
asContentHandler, asDocumentHandler, asDOMSerializer, setOutputFormat
 
Methods inherited from interface org.jasig.portal.IAnchoringSerializer
startAnchoring, stopAnchoring
 

Constructor Detail

CachingXHTMLSerializer

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


CachingXHTMLSerializer

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


CachingXHTMLSerializer

public CachingXHTMLSerializer(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

CachingXHTMLSerializer

public CachingXHTMLSerializer(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(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(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

startCaching

public boolean startCaching()
                     throws 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:
IOException

stopCaching

public boolean stopCaching()
                    throws 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:
IOException

getCache

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

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

printRawCharacters

public void printRawCharacters(String text)
                        throws 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:
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 IOException
Description copied from interface: CachingSerializer
Flushes all the buffers

Specified by:
flush in interface CachingSerializer
Specified by:
flush in interface MarkupSerializer
Overrides:
flush in class BaseMarkupSerializer
Throws:
IOException - if an error occurs


Copyright © 2010 Jasig. All Rights Reserved.