|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.codehaus.staxmate.out.SMOutputContext
public final class SMOutputContext
Class that encapsulates details about context in which StaxMate output is done. The most important of the details is the stream writer to use (since that is eventually invoked to do the real output), and its properties.
Usually the process of outputting XML content with StaxMate starts by
instantiating an SMOutputContext. It can then be used to create
output fragments; all of which bind to that context. Context is thus
what "connects" various fragments when they are buffered (when there
may or may not be child/parent relationships yet defined).
Context is also used (in addition to storing output relevant settings and acting as a fragment factory) as the owner of various other objects, most notable namespaces. All local namespaces are owned by one and only one context.
| Field Summary | |
|---|---|
protected static SMNamespace |
sNsEmpty
|
protected static SMNamespace |
sNsXml
|
protected static SMNamespace |
sNsXmlns
|
| Constructor Summary | |
|---|---|
protected |
SMOutputContext(org.codehaus.stax2.XMLStreamWriter2 sw,
javax.xml.namespace.NamespaceContext rootNsCtxt)
|
| Method Summary | |
|---|---|
SMOutputtable |
createAttribute(SMNamespace ns,
java.lang.String localName,
java.lang.String value)
|
SMBufferedFragment |
createBufferedFragment()
|
SMOutputtable |
createCData(char[] buf,
int offset,
int len)
|
SMOutputtable |
createCData(java.lang.String text)
|
SMOutputtable |
createCharacters(char[] buf,
int offset,
int len)
|
SMOutputtable |
createCharacters(java.lang.String text)
|
SMOutputtable |
createComment(java.lang.String text)
|
SMOutputDocument |
createDocument()
Method used to create a StaxMate output fragment that corresponds to a single well-formed XML document. |
SMOutputDocument |
createDocument(java.lang.String version,
java.lang.String encoding)
Method used to create a StaxMate output fragment that corresponds to a single well-formed XML document. |
SMOutputDocument |
createDocument(java.lang.String version,
java.lang.String encoding,
boolean standalone)
|
SMOutputtable |
createEntityRef(java.lang.String name)
|
static SMOutputContext |
createInstance(org.codehaus.stax2.XMLStreamWriter2 sw)
|
static SMOutputContext |
createInstance(org.codehaus.stax2.XMLStreamWriter2 sw,
javax.xml.namespace.NamespaceContext rootNsCtxt)
|
SMOutputtable |
createNonSharedCData(char[] buf,
int offset,
int len)
Specialized alternative to {link #createCData(char[],int,int)} that can count on the passed char array NOT being shared. |
SMOutputtable |
createNonSharedCharacters(char[] buf,
int offset,
int len)
Specialized alternative to {link #createCharacters(char[],int,int)} that can count on the passed char array NOT being shared. |
SMOutputtable |
createProcessingInstruction(java.lang.String target,
java.lang.String data)
|
SMRootFragment |
createRootFragment()
Method to use when outputting an XML sub-tree, in which case the underlying stream writer may be (or has been) used for outputting XML content in addition to content that is output using StaxMate. |
java.lang.String |
findRootPrefix(SMNamespace ns)
|
void |
flushWriter()
|
java.lang.String |
generateUnboundPrefix()
|
static SMNamespace |
getEmptyNamespace()
|
SMNamespace |
getNamespace(java.lang.String uri)
|
SMNamespace |
getNamespace(java.lang.String uri,
java.lang.String prefPrefix)
|
org.codehaus.stax2.XMLStreamWriter2 |
getWriter()
|
boolean |
isPrefixBound(java.lang.String prefix)
|
boolean |
isWriterRepairing()
|
void |
setIndentation(java.lang.String indentStr,
int startOffset,
int step)
This method can be called to enable or disable heuristic indentation for the output done using this output context. |
void |
writeAttribute(java.lang.String localName,
SMNamespace ns,
java.lang.String value)
|
void |
writeCData(char[] buf,
int offset,
int len)
|
void |
writeCData(java.lang.String text)
|
void |
writeCharacters(char[] buf,
int offset,
int len)
|
void |
writeCharacters(java.lang.String text)
|
void |
writeComment(java.lang.String text)
|
void |
writeDoctypeDecl(java.lang.String rootName,
java.lang.String systemId,
java.lang.String publicId,
java.lang.String intSubset)
|
void |
writeEndDocument()
|
void |
writeEndElement(int parentNsCount,
SMNamespace parentDefNs)
|
void |
writeEntityRef(java.lang.String name)
|
void |
writeProcessingInstruction(java.lang.String target,
java.lang.String data)
|
void |
writeStartDocument()
|
void |
writeStartDocument(java.lang.String version,
java.lang.String encoding)
|
void |
writeStartDocument(java.lang.String version,
java.lang.String encoding,
boolean standalone)
|
SMNamespace |
writeStartElement(SMNamespace ns,
java.lang.String localName)
Method called by the element object when it is about to get written out. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final SMNamespace sNsEmpty
protected static final SMNamespace sNsXml
protected static final SMNamespace sNsXmlns
| Constructor Detail |
|---|
protected SMOutputContext(org.codehaus.stax2.XMLStreamWriter2 sw,
javax.xml.namespace.NamespaceContext rootNsCtxt)
| Method Detail |
|---|
public void setIndentation(java.lang.String indentStr,
int startOffset,
int step)
Here are some example calls:
context.setIndentation("\n ", 1, 2); // indent by lf and 2 spaces per level context.setIndentation(null, 0, 0); // disable indentation context.setIndentation("\r\n\t\t\t\t\t\t\t\t", 2, 1); // indent by windows lf and 1 tab per level
indentStr - String to use for indentation; if non-null, will
enable indentation, if null, will disable it. Used in conjunction
with the other argumentsstartOffset - Initial character offset for the first level of
indentation (current context; usually root context): basically,
number of leading characters from indentStr to
output.step - Number of characters to add from the indentation
String for each new level (and to subtract when closing levels).
public static SMOutputContext createInstance(org.codehaus.stax2.XMLStreamWriter2 sw,
javax.xml.namespace.NamespaceContext rootNsCtxt)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public static SMOutputContext createInstance(org.codehaus.stax2.XMLStreamWriter2 sw)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public SMOutputDocument createDocument()
throws javax.xml.stream.XMLStreamException
This version of the method calls the matching no-arguments method in the stream writer.
javax.xml.stream.XMLStreamException
public SMOutputDocument createDocument(java.lang.String version,
java.lang.String encoding)
throws javax.xml.stream.XMLStreamException
This version of the method calls the matching stream writer method which takes full xml declaration information.
javax.xml.stream.XMLStreamException
public SMOutputDocument createDocument(java.lang.String version,
java.lang.String encoding,
boolean standalone)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public SMRootFragment createRootFragment()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public SMBufferedFragment createBufferedFragment()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public SMOutputtable createAttribute(SMNamespace ns,
java.lang.String localName,
java.lang.String value)
public SMOutputtable createCharacters(java.lang.String text)
public SMOutputtable createCharacters(char[] buf,
int offset,
int len)
public SMOutputtable createNonSharedCharacters(char[] buf,
int offset,
int len)
public SMOutputtable createCData(java.lang.String text)
public SMOutputtable createCData(char[] buf,
int offset,
int len)
public SMOutputtable createNonSharedCData(char[] buf,
int offset,
int len)
public SMOutputtable createComment(java.lang.String text)
public SMOutputtable createEntityRef(java.lang.String name)
public SMOutputtable createProcessingInstruction(java.lang.String target,
java.lang.String data)
public final SMNamespace getNamespace(java.lang.String uri)
public final SMNamespace getNamespace(java.lang.String uri,
java.lang.String prefPrefix)
public static final SMNamespace getEmptyNamespace()
public final org.codehaus.stax2.XMLStreamWriter2 getWriter()
public final boolean isWriterRepairing()
public void flushWriter()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeCharacters(java.lang.String text)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeCharacters(char[] buf,
int offset,
int len)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeCData(java.lang.String text)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeCData(char[] buf,
int offset,
int len)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeComment(java.lang.String text)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeEntityRef(java.lang.String name)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeProcessingInstruction(java.lang.String target,
java.lang.String data)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeAttribute(java.lang.String localName,
SMNamespace ns,
java.lang.String value)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public SMNamespace writeStartElement(SMNamespace ns,
java.lang.String localName)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeEndElement(int parentNsCount,
SMNamespace parentDefNs)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeStartDocument()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String version,
java.lang.String encoding)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String version,
java.lang.String encoding,
boolean standalone)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeEndDocument()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeDoctypeDecl(java.lang.String rootName,
java.lang.String systemId,
java.lang.String publicId,
java.lang.String intSubset)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionpublic java.lang.String generateUnboundPrefix()
public boolean isPrefixBound(java.lang.String prefix)
public java.lang.String findRootPrefix(SMNamespace ns)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||