Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jasig.portal.serialize
Class XHTMLSerializer

    java.lang.Object
      org.jasig.portal.serialize.BaseMarkupSerializer
          org.jasig.portal.serialize.XHTMLSerializer

All Implemented Interfaces:
  IAnchoringSerializer, DOMSerializer, Serializer, org.xml.sax.ContentHandler, org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.LexicalHandler

Direct Known Subclasses:
  CachingXHTMLSerializer

    public class XHTMLSerializer

extends BaseMarkupSerializer

Implements an XHTML serializer supporting both DOM and SAX pretty serializing. For usage instructions see either `Serializer` or `BaseMarkupSerializer`.

Version:
  $Revision: 1.5 $ $Date: 2005/05/13 20:12:57 $
Author:
  Assaf Arkin, Freddy Lopez, Bart Grebowiec Bart :: Simplified mechanism to support XHTML compliant markup
See Also:
  `Serializer`

Field Summary
`private static java.lang.String[]` | `emptyElementsToNotExpand` Array of element tag names that are expanded when empty
`static java.lang.String` | `XHTMLNamespace`

Fields inherited from class org.jasig.portal.serialize.BaseMarkupSerializer
`_docTypePublicId, _docTypeSystemId, _format, _indenting, _prefixes, _printer, _started, anchorId`

Constructor Summary
`XHTMLSerializer()` Constructs a new serializer.
`XHTMLSerializer(OutputFormat format)` Constructs a new serializer.
`XHTMLSerializer(java.io.OutputStream output, OutputFormat format)` Constructs a new serializer that writes to the specified output stream using the specified output format.
`XHTMLSerializer(java.io.Writer writer, OutputFormat format)` Constructs a new serializer that writes to the specified writer using the specified output format.

Method Summary
`void` | `characters(char[] chars, int start, int length)`
`protected ElementState` | `content()` Must be called by a method about to print any type of content.
`void` | `endElement(java.lang.String tagName)`
`void` | `endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String rawName)`
`void` | `endElementIO(java.lang.String namespaceURI, java.lang.String localName, java.lang.String rawName)`
`protected java.lang.String` | `getEntityRef(int ch)` Returns the suitable entity reference for this character value, or null if no such entity exists.
`protected void` | `serializeElement(org.w3c.dom.Element elem)` Called to serializee the DOM element.
`void` | `setOutputFormat(OutputFormat format)` Specifies an output format for this serializer.
`boolean` | `shouldNotExpandEndTagForEmptyElement(java.lang.String elementName)`
`protected void` | `startDocument(java.lang.String rootTagName)`
`void` | `startElement(java.lang.String tagName, org.xml.sax.AttributeList attrs)`
`void` | `startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attrs)`

Methods inherited from class org.jasig.portal.serialize.BaseMarkupSerializer
`appendAnchorIfNecessary, asContentHandler, asDocumentHandler, asDOMSerializer, attributeDecl, characters, comment, comment, 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, setOutputByteStream, setOutputCharStream, skippedEntity, startAnchoring, startCDATA, startDocument, startDTD, startEntity, startNonEscaping, startPrefixMapping, startPreserving, stopAnchoring, unparsedEntityDecl`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### XHTMLNamespace

    public static java.lang.String XHTMLNamespace

### emptyElementsToNotExpand

    private static final java.lang.String[] emptyElementsToNotExpand

  Array of element tag names that are expanded when empty

Constructor Detail

### XHTMLSerializer

    public XHTMLSerializer()

  Constructs a new serializer. The serializer cannot be used without calling `BaseMarkupSerializer.setOutputCharStream(Writer)` or `BaseMarkupSerializer.setOutputByteStream(OutputStream)` first.

### XHTMLSerializer

    public XHTMLSerializer(OutputFormat format)

  Constructs a new serializer. The serializer cannot be used without calling `BaseMarkupSerializer.setOutputCharStream(Writer)` or `BaseMarkupSerializer.setOutputByteStream(OutputStream)` first.

### XHTMLSerializer

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

### XHTMLSerializer

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

### 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 `BaseMarkupSerializer`
  Parameters:
    `format` - The output format to use

### characters

    public void characters(char[] chars,
                           int start,
                           int length)
                    throws org.xml.sax.SAXException

  Specified by:
    `characters` in interface `org.xml.sax.ContentHandler`
  Specified by:
    `characters` in interface `org.xml.sax.DocumentHandler`
  Overrides:
    `characters` in class `BaseMarkupSerializer`
  Throws:
    `org.xml.sax.SAXException`

### startElement

    public void startElement(java.lang.String namespaceURI,
                             java.lang.String localName,
                             java.lang.String rawName,
                             org.xml.sax.Attributes attrs)
                      throws org.xml.sax.SAXException

  Throws:
    `org.xml.sax.SAXException`

### endElementIO

    public void endElementIO(java.lang.String namespaceURI,
                             java.lang.String localName,
                             java.lang.String rawName)
                      throws java.io.IOException

  Throws:
    `java.io.IOException`

### startDocument

    protected void startDocument(java.lang.String rootTagName)
                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### serializeElement

    protected void serializeElement(org.w3c.dom.Element elem)
                             throws java.io.IOException

  Description copied from class: `BaseMarkupSerializer`
  Called to serializee the DOM element. The element is serialized based on the serializer's method (XML, HTML, XHTML).

  Specified by:
    `serializeElement` in class `BaseMarkupSerializer`
  Parameters:
    `elem` - The element to serialize
  Throws:
    `java.io.IOException` - An I/O exception occured while serializing

### shouldNotExpandEndTagForEmptyElement

    public boolean shouldNotExpandEndTagForEmptyElement(java.lang.String elementName)

### getEntityRef

    protected java.lang.String getEntityRef(int ch)

  Description copied from class: `BaseMarkupSerializer`
  Returns the suitable entity reference for this character value, or null if no such entity exists. Calling this method with `'&'` will return `"&amp;"`.

  Specified by:
    `getEntityRef` in class `BaseMarkupSerializer`
  Parameters:
    `ch` - Character value
  Returns:
    Character entity name, or null

### startElement

    public void startElement(java.lang.String tagName,
                             org.xml.sax.AttributeList attrs)
                      throws org.xml.sax.SAXException

  Throws:
    `org.xml.sax.SAXException`

### endElement

    public void endElement(java.lang.String namespaceURI,
                           java.lang.String localName,
                           java.lang.String rawName)
                    throws org.xml.sax.SAXException

  Throws:
    `org.xml.sax.SAXException`

### endElement

    public void endElement(java.lang.String tagName)
                    throws org.xml.sax.SAXException

  Throws:
    `org.xml.sax.SAXException`

### content

    protected ElementState content()
                            throws java.io.IOException

  Must be called by a method about to print any type of content. If the element was just opened, the opening tag is closed and will be matched to a closing tag. Returns the current element state with `empty` and `afterElement` set to false.

  Overrides:
    `content` in class `BaseMarkupSerializer`
  Returns:
    The current element state
  Throws:
    `java.io.IOException` - An I/O exception occured while serializing

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD