|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ajax4jsf.xml.serializer.SerializerBase
org.ajax4jsf.xml.serializer.ToStream
org.ajax4jsf.xml.serializer.ToHTMLStream
public final class ToHTMLStream
This serializer takes a series of SAX or SAX-like events and writes its output to the given stream. This class is not a public API, it is public because it is used from another package.
Field Summary | |
---|---|
static java.lang.String |
CDATA_CONTINUE
To insert ]]> in a CDATA section by ending the last CDATA section with ]] and starting the next CDATA section with > |
static java.lang.String |
CDATA_DELIMITER_CLOSE
The constant "]]>" |
static java.lang.String |
CDATA_DELIMITER_OPEN
|
static java.lang.String |
DEFAULT_SAX_SERIALIZER
|
static java.lang.String |
EMPTYSTRING
|
static java.lang.String |
ENTITY_AMP
|
static java.lang.String |
ENTITY_CRLF
|
static java.lang.String |
ENTITY_GT
|
static java.lang.String |
ENTITY_LT
|
static java.lang.String |
ENTITY_QUOT
|
static int |
HTML_ATTREMPTY
|
static int |
HTML_ATTRURL
|
protected boolean |
m_inDTD
This flag is set while receiving events from the DTD |
static int |
NO_BAD_CHARS
|
static java.lang.String |
XML_PREFIX
|
static java.lang.String |
XMLNS_PREFIX
|
static java.lang.String |
XMLNS_URI
|
static java.lang.String |
XMLVERSION10
|
static java.lang.String |
XMLVERSION11
Define the XML version. |
Fields inherited from class org.ajax4jsf.xml.serializer.ToStream |
---|
m_cdataStartCalled, m_charInfo, m_disableOutputEscapingStates, m_format, m_inDoctype, m_ispreserve, m_isprevtext, m_lineSep, m_lineSepLen, m_lineSepUse, m_preserves, m_spaceBeforeClose |
Fields inherited from class org.ajax4jsf.xml.serializer.SerializerBase |
---|
m_attrBuff, m_attributes, m_cdataSectionElements, m_cdataTagOpen, m_charsBuff, m_doIndent, m_elemContext, m_indentAmount, m_inEntityRef, m_inExternalDTD, m_needToCallStartDocument, m_prefixMap, m_sourceLocator, m_standaloneWasSpecified, m_tracer, m_writer |
Constructor Summary | |
---|---|
ToHTMLStream()
Default constructor. |
Method Summary | |
---|---|
void |
addUniqueAttribute(java.lang.String name,
java.lang.String value,
int flags)
This method is used to add an attribute to the currently open element. |
void |
attributeDecl(java.lang.String eName,
java.lang.String aName,
java.lang.String type,
java.lang.String valueDefault,
java.lang.String value)
This method does nothing. |
void |
cdata(char[] ch,
int start,
int length)
Receive notification of cdata. |
void |
characters(char[] chars,
int start,
int length)
Receive notification of character data. |
protected void |
closeStartTag()
For the enclosing elements starting tag write out out any attributes followed by ">" |
void |
comment(char[] ch,
int start,
int length)
Receive notification of an XML comment anywhere in the document. |
void |
elementDecl(java.lang.String name,
java.lang.String model)
This method does nothing. |
void |
endDocument()
Receive notification of the end of a document. |
void |
endDTD()
Report the end of DTD declarations. |
void |
endElement(java.lang.String elemName)
Receive notification of the end of an element. |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String name)
Receive notification of the end of an element. |
void |
entityReference(java.lang.String name)
Receive notivication of a entityReference. |
void |
externalEntityDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
This method does nothing. |
static ElemDesc |
getElemDesc(java.lang.String name)
Get a description of the given element. |
protected void |
init(java.io.OutputStream output,
java.util.Properties format)
Initialize the serializer with the specified output stream and output format. |
void |
internalEntityDecl(java.lang.String name,
java.lang.String value)
This method does nothing. |
void |
namespaceAfterStartElement(java.lang.String prefix,
java.lang.String uri)
This method is used when a prefix/uri namespace mapping is indicated after the element was started with a startElement() and before and endElement(). |
protected void |
processAttribute(java.io.Writer writer,
java.lang.String name,
java.lang.String value,
ElemDesc elemDesc)
Process an attribute. |
void |
processAttributes(java.io.Writer writer,
int nAttrs)
Process the attributes, which means to write out the currently collected attributes to the writer. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Receive notification of a processing instruction. |
boolean |
reset()
Try's to reset the super class and reset this class for re-use, so that you don't need to create a new serializer (mostly for performance reasons). |
void |
setOmitMetaTag(boolean bool)
Tells if the formatter should omit the META tag. |
void |
setOutputFormat(java.util.Properties format)
Specifies an output format for this serializer. |
void |
setOutputStream(java.io.OutputStream output)
Specifies an output stream to which the document should be serialized. |
void |
setSpecialEscapeURLs(boolean bool)
Tells if the formatter should use special URL escaping. |
protected void |
startDocumentInternal()
Receive notification of the beginning of a document. |
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Report the start of DTD declarations, if any. |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String name,
org.xml.sax.Attributes atts)
Receive notification of the beginning of an element. |
void |
writeAttrString(java.io.Writer writer,
java.lang.String string,
java.lang.String encoding)
Writes the specified string after substituting specials, and UTF-16 surrogates for character references &#xnn . |
void |
writeAttrURI(java.io.Writer writer,
java.lang.String string,
boolean doURLEscaping)
Write the specified string after substituting non ASCII characters, with %HH , where HH is the hex of the byte value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean m_inDTD
public static final int NO_BAD_CHARS
public static final int HTML_ATTREMPTY
public static final int HTML_ATTRURL
public static final java.lang.String CDATA_CONTINUE
public static final java.lang.String CDATA_DELIMITER_CLOSE
public static final java.lang.String CDATA_DELIMITER_OPEN
public static final java.lang.String EMPTYSTRING
public static final java.lang.String ENTITY_AMP
public static final java.lang.String ENTITY_CRLF
public static final java.lang.String ENTITY_GT
public static final java.lang.String ENTITY_LT
public static final java.lang.String ENTITY_QUOT
public static final java.lang.String XML_PREFIX
public static final java.lang.String XMLNS_PREFIX
public static final java.lang.String XMLNS_URI
public static final java.lang.String DEFAULT_SAX_SERIALIZER
public static final java.lang.String XMLVERSION11
public static final java.lang.String XMLVERSION10
Constructor Detail |
---|
public ToHTMLStream()
Method Detail |
---|
public void setSpecialEscapeURLs(boolean bool)
bool
- True if URLs should be specially escaped with the %xx form.public void setOmitMetaTag(boolean bool)
bool
- True if the META tag should be omitted.public void setOutputFormat(java.util.Properties format)
setOutputFormat
in interface Serializer
setOutputFormat
in class ToStream
format
- The output format or serialzation parameters
to use.public static final ElemDesc getElemDesc(java.lang.String name)
name
- non-null name of element, case insensitive.
protected void startDocumentInternal() throws org.xml.sax.SAXException
startDocumentInternal
in class SerializerBase
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.
org.xml.sax.SAXException
public final void endDocument() throws org.xml.sax.SAXException
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.
org.xml.sax.SAXException
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
startElement
in class ToStream
namespaceURI
- localName
- name
- The element type name.atts
- The attributes attached to the element, if any.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(java.lang.String, java.lang.String, java.lang.String)
,
AttributeList
public final void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String name) throws org.xml.sax.SAXException
endElement
in class ToStream
namespaceURI
- localName
- name
- The element type name
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.protected void processAttribute(java.io.Writer writer, java.lang.String name, java.lang.String value, ElemDesc elemDesc) throws java.io.IOException
writer
- The writer to write the processed output to.name
- The name of the attribute.value
- The value of the attribute.elemDesc
- The description of the HTML element
that has this attribute.
org.xml.sax.SAXException
java.io.IOException
public void writeAttrURI(java.io.Writer writer, java.lang.String string, boolean doURLEscaping) throws java.io.IOException
%HH
, where HH is the hex of the byte value.
string
- String to convert to XML format.doURLEscaping
- True if we should try to encode as
per http://www.ietf.org/rfc/rfc2396.txt.
org.xml.sax.SAXException
- if a bad surrogate pair is detected.
java.io.IOException
public void writeAttrString(java.io.Writer writer, java.lang.String string, java.lang.String encoding) throws java.io.IOException
&#xnn
.
writeAttrString
in class ToStream
string
- String to convert to XML format.encoding
- CURRENTLY NOT IMPLEMENTED.
org.xml.sax.SAXException
java.io.IOException
public final void characters(char[] chars, int start, int length) throws org.xml.sax.SAXException
The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.
The application must not attempt to read from the array outside of the specified range.
Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).
characters
in class ToStream
chars
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.
org.xml.sax.SAXException
ToStream.ignorableWhitespace(char[], int, int)
,
Locator
public final void cdata(char[] ch, int start, int length) throws org.xml.sax.SAXException
The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.
The application must not attempt to read from the array outside of the specified range.
Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).
cdata
in class ToStream
ch
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.
org.xml.sax.SAXException
ToStream.ignorableWhitespace(char[], int, int)
,
Locator
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
target
- The processing instruction target.data
- The processing instruction data, or null if
none was supplied.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.
org.xml.sax.SAXException
public final void entityReference(java.lang.String name) throws org.xml.sax.SAXException
entityReference
in class SerializerBase
name
- non-null reference to entity name string.
org.xml.sax.SAXException
public final void endElement(java.lang.String elemName) throws org.xml.sax.SAXException
ToStream
endElement
in class ToStream
elemName
- The element type name
org.xml.sax.SAXException
ExtendedContentHandler.endElement(String)
public void processAttributes(java.io.Writer writer, int nAttrs) throws java.io.IOException, org.xml.sax.SAXException
processAttributes
in class ToStream
writer
- the writer to write processed attributes to.nAttrs
- the number of attributes in m_attributes
to be processed
org.xml.sax.SAXException
java.io.IOException
protected void closeStartTag() throws org.xml.sax.SAXException
closeStartTag
in class ToStream
org.xml.sax.SAXException
protected void init(java.io.OutputStream output, java.util.Properties format) throws java.io.UnsupportedEncodingException
output
- The output stream to useformat
- The output format
java.io.UnsupportedEncodingException
- The encoding specified in the
output format is not supportedpublic void setOutputStream(java.io.OutputStream output)
The encoding specified in the output properties is used, or if no encoding was specified, the default for the selected output method.
setOutputStream
in interface Serializer
setOutputStream
in class ToStream
output
- The output streampublic void namespaceAfterStartElement(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
namespaceAfterStartElement
in class SerializerBase
uri
- the URI of the namespaceprefix
- the prefix associated with the given URI.
org.xml.sax.SAXException
ExtendedContentHandler.namespaceAfterStartElement(String, String)
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
ToStream
startDTD
in class ToStream
name
- The document type name.publicId
- The declared public identifier for the
external DTD subset, or null if none was declared.systemId
- The declared system identifier for the
external DTD subset, or null if none was declared.
org.xml.sax.SAXException
- The application may raise an
exception.ToStream.endDTD()
,
ToStream.startEntity(java.lang.String)
public void endDTD() throws org.xml.sax.SAXException
endDTD
in class ToStream
org.xml.sax.SAXException
- The application may raise an exception.startDTD(java.lang.String, java.lang.String, java.lang.String)
public void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value) throws org.xml.sax.SAXException
attributeDecl
in interface org.xml.sax.ext.DeclHandler
attributeDecl
in class ToStream
eName
- The name of the associated element.aName
- The name of the attribute.type
- A string representing the attribute type.valueDefault
- A string representing the attribute default
("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
none of these applies.value
- A string representing the attribute's default value,
or null if there is none.
org.xml.sax.SAXException
- The application may raise an exception.public void elementDecl(java.lang.String name, java.lang.String model) throws org.xml.sax.SAXException
elementDecl
in interface org.xml.sax.ext.DeclHandler
elementDecl
in class ToStream
name
- The element type name.model
- The content model as a normalized string.
org.xml.sax.SAXException
- The application may raise an exception.public void internalEntityDecl(java.lang.String name, java.lang.String value) throws org.xml.sax.SAXException
internalEntityDecl
in interface org.xml.sax.ext.DeclHandler
internalEntityDecl
in class ToStream
name
- The name of the entity. If it is a parameter
entity, the name will begin with '%'.value
- The replacement text of the entity.
org.xml.sax.SAXException
- The application may raise an exception.ToStream.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
,
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
externalEntityDecl
in interface org.xml.sax.ext.DeclHandler
externalEntityDecl
in class ToStream
name
- The name of the entity. If it is a parameter
entity, the name will begin with '%'.publicId
- The declared public identifier of the entity, or
null if none was declared.systemId
- The declared system identifier of the entity.
org.xml.sax.SAXException
- The application may raise an exception.ToStream.internalEntityDecl(java.lang.String, java.lang.String)
,
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void addUniqueAttribute(java.lang.String name, java.lang.String value, int flags) throws org.xml.sax.SAXException
name
- the qualified name of the attributevalue
- the value of the attribute which can contain only
ASCII printable characters characters in the range 32 to 127 inclusive.flags
- the bit values of this integer give optimization information.
org.xml.sax.SAXException
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException
ToStream
comment
in class ToStream
ch
- An array holding the characters in the comment.start
- The starting position in the array.length
- The number of characters to use from the array.
org.xml.sax.SAXException
- The application may raise an exception.public boolean reset()
ToStream
reset
in interface Serializer
reset
in class ToStream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |