Methods Summary |
---|
public void | addAttribute(java.lang.String uri, java.lang.String localName, java.lang.String rawName, java.lang.String type, java.lang.String value, boolean XSLAttribute)Adds an attribute to the currenly open tag
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.addAttribute(uri, localName, rawName, type, value, XSLAttribute);
|
public void | addAttribute(java.lang.String rawName, java.lang.String value)Adds an attribute to the currenly open tag
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.addAttribute(rawName, value);
|
public void | addAttributes(org.xml.sax.Attributes atts)
m_handler.addAttributes(atts);
|
public void | addUniqueAttribute(java.lang.String rawName, java.lang.String value, int flags)Adds a unique attribute to the currenly open tag
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.addUniqueAttribute(rawName, value, flags);
|
public org.xml.sax.ContentHandler | asContentHandler()
/* don't return the real handler ( m_handler ) because
* that would expose the real handler to the outside.
* Keep m_handler private so it can be internally swapped
* to an HTML handler.
*/
return this;
|
public com.sun.org.apache.xml.internal.serializer.DOMSerializer | asDOMSerializer()
return m_handler.asDOMSerializer();
|
public void | attributeDecl(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4)Pass the call on to the underlying handler
m_handler.attributeDecl(arg0, arg1, arg2, arg3, arg4);
|
public void | characters(java.lang.String chars)Converts the String to a character array and calls the SAX method
characters(char[],int,int);
final int length = chars.length();
if (length > m_charsBuff.length)
{
m_charsBuff = new char[length*2 + 1];
}
chars.getChars(0, length, m_charsBuff, 0);
this.characters(m_charsBuff, 0, length);
|
public void | characters(char[] characters, int offset, int length)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.characters(characters, offset, length);
|
public void | close()
m_handler.close();
|
public void | comment(java.lang.String comment)Pass the call on to the underlying handler
if (m_firstTagNotEmitted && m_firstElementName != null)
{
emitFirstTag();
}
else if (m_needToCallStartDocument)
{
m_handler.startDocument();
m_needToCallStartDocument = false;
}
m_handler.comment(comment);
|
public void | comment(char[] ch, int start, int length)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.comment(ch, start, length);
|
public void | elementDecl(java.lang.String arg0, java.lang.String arg1)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
emitFirstTag();
}
m_handler.elementDecl(arg0, arg1);
|
private void | emitFirstTag()
if (m_firstElementName != null)
{
if (m_wrapped_handler_not_initialized)
{
initStreamOutput();
m_wrapped_handler_not_initialized = false;
}
// Output first tag
m_handler.startElement(m_firstElementURI, null, m_firstElementName, m_attributes);
// don't need the collected attributes of the first element anymore.
m_attributes = null;
// Output namespaces of first tag
if (m_namespacePrefix != null)
{
final int n = m_namespacePrefix.size();
for (int i = 0; i < n; i++)
{
final String prefix =
(String) m_namespacePrefix.elementAt(i);
final String uri = (String) m_namespaceURI.elementAt(i);
m_handler.startPrefixMapping(prefix, uri, false);
}
m_namespacePrefix = null;
m_namespaceURI = null;
}
m_firstTagNotEmitted = false;
}
|
public void | endCDATA()Pass the call on to the underlying handler
m_handler.endCDATA();
|
public void | endDTD()Pass the call on to the underlying handler
m_handler.endDTD();
|
public void | endDocument()Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.endDocument();
|
public void | endElement(java.lang.String elementName)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.endElement(elementName);
|
public void | endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
flush();
if (namespaceURI == null && m_firstElementURI != null)
namespaceURI = m_firstElementURI;
if (localName == null && m_firstElementLocalName != null)
localName = m_firstElementLocalName;
}
m_handler.endElement(namespaceURI, localName, qName);
|
public void | endEntity(java.lang.String name)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
emitFirstTag();
}
m_handler.endEntity(name);
|
public void | endPrefixMapping(java.lang.String prefix)Pass the call on to the underlying handler
m_handler.endPrefixMapping(prefix);
|
public void | entityReference(java.lang.String entityName)
m_handler.entityReference(entityName);
|
public void | externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.externalEntityDecl(name, publicId, systemId);
|
protected void | firePseudoElement(java.lang.String elementName)
if (m_tracer != null) {
StringBuffer sb = new StringBuffer();
sb.append('<");
sb.append(elementName);
// convert the StringBuffer to a char array and
// emit the trace event that these characters "might"
// be written
char ch[] = sb.toString().toCharArray();
m_tracer.fireGenerateEvent(
SerializerTrace.EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS,
ch,
0,
ch.length);
}
|
private void | flush()
try
{
if (m_firstTagNotEmitted)
{
emitFirstTag();
}
if (m_needToCallStartDocument)
{
m_handler.startDocument();
m_needToCallStartDocument = false;
}
}
catch(SAXException e)
{
throw new RuntimeException(e.toString());
}
|
public void | flushPending()
flush();
m_handler.flushPending();
|
public java.lang.String | getDoctypePublic()Pass the call on to the underlying handler
return m_handler.getDoctypePublic();
|
public java.lang.String | getDoctypeSystem()Pass the call on to the underlying handler
return m_handler.getDoctypeSystem();
|
public java.lang.String | getEncoding()Pass the call on to the underlying handler
return m_handler.getEncoding();
|
public boolean | getIndent()Pass the call on to the underlying handler
return m_handler.getIndent();
|
public int | getIndentAmount()Pass the call on to the underlying handler
return m_handler.getIndentAmount();
|
private java.lang.String | getLocalNameUnknown(java.lang.String value)Utility function for calls to local-name().
Don't want to override static function on SerializerBase
So added Unknown suffix to method name.
int idx = value.lastIndexOf(':");
if (idx >= 0)
value = value.substring(idx + 1);
idx = value.lastIndexOf('@");
if (idx >= 0)
value = value.substring(idx + 1);
return (value);
|
public java.lang.String | getMediaType()Pass the call on to the underlying handler
return m_handler.getMediaType();
|
public com.sun.org.apache.xml.internal.serializer.NamespaceMappings | getNamespaceMappings()Get the current namespace mappings.
Simply returns the mappings of the wrapped handler.
NamespaceMappings mappings = null;
if (m_handler != null)
{
mappings = m_handler.getNamespaceMappings();
}
return mappings;
|
public java.lang.String | getNamespaceURI(java.lang.String qname, boolean isElement)
return m_handler.getNamespaceURI(qname, isElement);
|
public java.lang.String | getNamespaceURIFromPrefix(java.lang.String prefix)
return m_handler.getNamespaceURIFromPrefix(prefix);
|
public boolean | getOmitXMLDeclaration()Pass the call on to the underlying handler
return m_handler.getOmitXMLDeclaration();
|
public java.util.Properties | getOutputFormat()
return m_handler.getOutputFormat();
|
public java.io.OutputStream | getOutputStream()
return m_handler.getOutputStream();
|
public java.lang.String | getPrefix(java.lang.String namespaceURI)
return m_handler.getPrefix(namespaceURI);
|
private java.lang.String | getPrefixPartUnknown(java.lang.String qname)Utility function to return prefix
Don't want to override static function on SerializerBase
So added Unknown suffix to method name.
final int index = qname.indexOf(':");
return (index > 0) ? qname.substring(0, index) : EMPTYSTRING;
|
public java.lang.String | getStandalone()Pass the call on to the underlying handler
return m_handler.getStandalone();
|
public javax.xml.transform.Transformer | getTransformer()
return m_handler.getTransformer();
|
public java.lang.String | getVersion()Pass the call on to the underlying handler
return m_handler.getVersion();
|
public java.io.Writer | getWriter()
return m_handler.getWriter();
|
public void | ignorableWhitespace(char[] ch, int start, int length)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.ignorableWhitespace(ch, start, length);
|
private void | initStreamOutput()Initialize the wrapped output stream (XML or HTML).
If the stream handler should be HTML, then replace the XML handler with
an HTML handler. After than send the starting method calls that were cached
to the wrapped handler.
// Try to rule out if this is an not to be an HTML document based on prefix
boolean firstElementIsHTML = isFirstElemHTML();
if (firstElementIsHTML)
{
// create an HTML output handler, and initialize it
// keep a reference to the old handler, ... it will soon be gone
SerializationHandler oldHandler = m_handler;
/* We have to make sure we get an output properties with the proper
* defaults for the HTML method. The easiest way to do this is to
* have the OutputProperties class do it.
*/
Properties htmlProperties =
OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
Serializer serializer =
SerializerFactory.getSerializer(htmlProperties);
// The factory should be returning a ToStream
// Don't know what to do if it doesn't
// i.e. the user has over-ridden the content-handler property
// for html
m_handler = (SerializationHandler) serializer;
//m_handler = new ToHTMLStream();
Writer writer = oldHandler.getWriter();
if (null != writer)
m_handler.setWriter(writer);
else
{
OutputStream os = oldHandler.getOutputStream();
if (null != os)
m_handler.setOutputStream(os);
}
// need to copy things from the old handler to the new one here
// if (_setVersion_called)
// {
m_handler.setVersion(oldHandler.getVersion());
// }
// if (_setDoctypeSystem_called)
// {
m_handler.setDoctypeSystem(oldHandler.getDoctypeSystem());
// }
// if (_setDoctypePublic_called)
// {
m_handler.setDoctypePublic(oldHandler.getDoctypePublic());
// }
// if (_setMediaType_called)
// {
m_handler.setMediaType(oldHandler.getMediaType());
// }
m_handler.setTransformer(oldHandler.getTransformer());
}
/* Now that we have a real wrapped handler (XML or HTML) lets
* pass any cached calls to it
*/
// Call startDocument() if necessary
if (m_needToCallStartDocument)
{
m_handler.startDocument();
m_needToCallStartDocument = false;
}
// the wrapped handler is now fully initialized
m_wrapped_handler_not_initialized = false;
|
public void | internalEntityDecl(java.lang.String arg0, java.lang.String arg1)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.internalEntityDecl(arg0, arg1);
|
private boolean | isFirstElemHTML()Determine if the firts element in the document is or
This uses the cached first element name, first element prefix and the
cached namespaces from previous method calls
boolean isHTML;
// is the first tag html, not considering the prefix ?
isHTML =
getLocalNameUnknown(m_firstElementName).equalsIgnoreCase("html");
// Try to rule out if this is not to be an HTML document based on URI
if (isHTML
&& m_firstElementURI != null
&& !EMPTYSTRING.equals(m_firstElementURI))
{
// the <html> element has a non-trivial namespace
isHTML = false;
}
// Try to rule out if this is an not to be an HTML document based on prefix
if (isHTML && m_namespacePrefix != null)
{
/* the first element has a name of "html", but lets check the prefix.
* If the prefix points to a namespace with a URL that is not ""
* then the doecument doesn't start with an <html> tag, and isn't html
*/
final int max = m_namespacePrefix.size();
for (int i = 0; i < max; i++)
{
final String prefix = (String) m_namespacePrefix.elementAt(i);
final String uri = (String) m_namespaceURI.elementAt(i);
if (m_firstElementPrefix != null
&& m_firstElementPrefix.equals(prefix)
&& !EMPTYSTRING.equals(uri))
{
// The first element has a prefix, so it can't be <html>
isHTML = false;
break;
}
}
}
return isHTML;
|
public 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().
startPrefixMapping(prefix,uri) would be used before the
startElement() call.
// hack for XSLTC with finding URI for default namespace
if (m_firstTagNotEmitted && m_firstElementURI == null && m_firstElementName != null)
{
String prefix1 = getPrefixPart(m_firstElementName);
if (prefix1 == null && EMPTYSTRING.equals(prefix))
{
// the elements URI is not known yet, and it
// doesn't have a prefix, and we are currently
// setting the uri for prefix "", so we have
// the uri for the element... lets remember it
m_firstElementURI = uri;
}
}
startPrefixMapping(prefix,uri, false);
|
public void | processingInstruction(java.lang.String target, java.lang.String data)Pass the call on to the underlying handler
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.processingInstruction(target, data);
|
public boolean | reset()passes the call on to the underlying HTML or XML handler
return m_handler.reset();
|
public void | serialize(org.w3c.dom.Node node)Converts the DOM node to output
if (m_firstTagNotEmitted)
{
flush();
}
m_handler.serialize(node);
|
public void | setCdataSectionElements(java.util.Vector URI_and_localNames)
m_handler.setCdataSectionElements(URI_and_localNames);
|
public void | setContentHandler(org.xml.sax.ContentHandler ch)
m_handler.setContentHandler(ch);
|
public void | setDoctype(java.lang.String system, java.lang.String pub)
m_handler.setDoctypePublic(pub);
m_handler.setDoctypeSystem(system);
|
public void | setDoctypePublic(java.lang.String doctype)Set the doctype in the underlying XML handler. Remember that this method
was called, just in case we need to transfer this doctype to an HTML handler
m_handler.setDoctypePublic(doctype);
m_setDoctypePublic_called = true;
|
public void | setDoctypeSystem(java.lang.String doctype)Set the doctype in the underlying XML handler. Remember that this method
was called, just in case we need to transfer this doctype to an HTML handler
m_handler.setDoctypeSystem(doctype);
m_setDoctypeSystem_called = true;
|
public void | setDocumentLocator(org.xml.sax.Locator locator)Pass the call on to the underlying handler
super.setDocumentLocator(locator);
m_handler.setDocumentLocator(locator);
|
public void | setEncoding(java.lang.String encoding)Pass the call on to the underlying handler
m_handler.setEncoding(encoding);
|
public boolean | setEscaping(boolean escape)
return m_handler.setEscaping(escape);
|
public void | setIndent(boolean indent)Pass the call on to the underlying handler
m_handler.setIndent(indent);
|
public void | setIndentAmount(int value)Pass the call on to the underlying handler
m_handler.setIndentAmount(value);
|
public void | setMediaType(java.lang.String mediaType)
m_handler.setMediaType(mediaType);
m_setMediaType_called = true;
|
public void | setOmitXMLDeclaration(boolean b)Pass the call on to the underlying handler
m_handler.setOmitXMLDeclaration(b);
|
public void | setOutputFormat(java.util.Properties format)Set the properties of the handler
m_handler.setOutputFormat(format);
|
public void | setOutputStream(java.io.OutputStream output)Sets the output stream to write to
m_handler.setOutputStream(output);
|
public void | setSourceLocator(javax.xml.transform.SourceLocator locator)This method is used to set the source locator, which might be used to
generated an error message.
m_handler.setSourceLocator(locator);
|
public void | setStandalone(java.lang.String standalone)Pass the call on to the underlying handler
m_handler.setStandalone(standalone);
|
public void | setTransformer(javax.xml.transform.Transformer t)
m_handler.setTransformer(t);
if ((t instanceof SerializerTrace) &&
(((SerializerTrace) t).hasTraceListeners())) {
m_tracer = (SerializerTrace) t;
} else {
m_tracer = null;
}
|
public void | setVersion(java.lang.String version)This method cannot be cached because default is different in
HTML and XML (we need more than a boolean).
m_handler.setVersion(version);
// Cache call to setVersion()
// super.setVersion(version);
m_setVersion_called = true;
|
public void | setWriter(java.io.Writer writer)Sets the writer to write to
m_handler.setWriter(writer);
|
public void | skippedEntity(java.lang.String name)Pass the call on to the underlying handler
m_handler.skippedEntity(name);
|
public void | startCDATA()Pass the call on to the underlying handler
m_handler.startCDATA();
|
public void | startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Pass the call on to the underlying handler
m_handler.startDTD(name, publicId, systemId);
|
public void | startDocument()
m_needToCallStartDocument = true;
|
public void | startElement(java.lang.String qName)
this.startElement(null, null, qName, null);
|
public void | startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
this.startElement(namespaceURI, localName, qName, null);
|
public void | startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String elementName, org.xml.sax.Attributes atts)
if (m_needToCallSetDocumentInfo){
super.setDocumentInfo();
m_needToCallSetDocumentInfo = false;
}
/* we are notified of the start of an element */
if (m_firstTagNotEmitted)
{
/* we have not yet sent the first element on its way */
if (m_firstElementName != null)
{
/* this is not the first element, but a later one.
* But we have the old element pending, so flush it out,
* then send this one on its way.
*/
flush();
m_handler.startElement(namespaceURI, localName, elementName, atts);
}
else
{
/* this is the very first element that we have seen,
* so save it for flushing later. We may yet get to know its
* URI due to added attributes.
*/
m_wrapped_handler_not_initialized = true;
m_firstElementName = elementName;
// null if not known
m_firstElementPrefix = getPrefixPartUnknown(elementName);
// null if not known
m_firstElementURI = namespaceURI;
// null if not known
m_firstElementLocalName = localName;
if (m_tracer != null)
firePseudoElement(elementName);
/* we don't want to call our own addAttributes, which
* merely delegates to the wrapped handler, but we want to
* add these attributes to m_attributes. So me must call super.
* addAttributes() In this case m_attributes is only used for the
* first element, after that this class totally delegates to the
* wrapped handler which is either XML or HTML.
*/
if (atts != null)
super.addAttributes(atts);
// if there are attributes, then lets make the flush()
// call the startElement on the handler and send the
// attributes on their way.
if (atts != null)
flush();
}
}
else
{
// this is not the first element, but a later one, so just
// send it on its way.
m_handler.startElement(namespaceURI, localName, elementName, atts);
}
|
public void | startEntity(java.lang.String name)Pass the call on to the underlying handler
m_handler.startEntity(name);
|
public void | startPrefixMapping(java.lang.String prefix, java.lang.String uri)
this.startPrefixMapping(prefix,uri, true);
|
public boolean | startPrefixMapping(java.lang.String prefix, java.lang.String uri, boolean shouldFlush)
boolean pushed = false;
if (m_firstTagNotEmitted)
{
if (m_firstElementName != null && shouldFlush)
{
/* we've already seen a startElement, and this is a prefix mapping
* for the up coming element, so flush the old element
* then send this event on its way.
*/
flush();
pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
}
else
{
if (m_namespacePrefix == null)
{
m_namespacePrefix = new Vector();
m_namespaceURI = new Vector();
}
m_namespacePrefix.addElement(prefix);
m_namespaceURI.addElement(uri);
if (m_firstElementURI == null)
{
if (prefix.equals(m_firstElementPrefix))
m_firstElementURI = uri;
}
}
}
else
{
pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
}
return pushed;
|