public class XMLWriterImpl extends Object implements XMLWriter
XMLWriter
. Works with Java 1.2 and
later.Constructor and Description |
---|
XMLWriterImpl() |
Modifier and Type | Method and Description |
---|---|
boolean |
canEncode(char c)
Returns whether the XMLWriter can encode the character
c without an escape sequence like &#ddd;. |
void |
characters(char[] ch,
int start,
int length)
Inserts a string of characters into the document.
|
void |
endDocument()
This method finishs the handlers action.
|
void |
endElement(String namespaceURI,
String localName,
String qName)
Terminates an element.
|
void |
endPrefixMapping(String prefix)
Terminates use of a namespace prefix.
|
Locator |
getDocumentLocator()
Returns the locator
|
String |
getEncoding()
Returns the writers encoding.
|
String |
getIndentString()
Returns the string being used to indent an XML element
by one level.
|
String |
getLineFeed()
Returns the line terminator.
|
Writer |
getWriter()
Returns the JaxbXMLSerializers Writer.
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Calls the character method with the same arguments.
|
boolean |
isDeclarating()
Returns, whether an XML declaration is being generated.
|
boolean |
isFlushing()
Returns, whether the method
ContentHandler.endDocument()
should do a flush on the target stream. |
boolean |
isIndenting()
Returns, whether the
XMLWriter is indenting
(pretty printing). |
void |
processingInstruction(String target,
String data)
Inserts a processing instruction.
|
void |
setDeclarating(boolean pDeclarating)
Sets, whether an XML declaration is being generated.
|
void |
setDocumentLocator(Locator pLocator)
Sets the locator.
|
void |
setEncoding(String pEncoding)
Sets the writers encoding.
|
void |
setFlushing(boolean pFlushing)
Sets, whether the method
ContentHandler.endDocument()
should do a flush on the target stream. |
void |
setIndenting(boolean pIndenting)
Returns, whether the
XMLWriter is indenting
(pretty printing). |
void |
setIndentString(String pIndentString)
Sets the string being used to indent an XML element
by one level.
|
void |
setLineFeed(String pLineFeed)
Sets the line terminator.
|
void |
setWriter(Writer pWriter)
Sets the JaxbXMLSerializers Writer.
|
void |
skippedEntity(String ent)
Not actually implemented, because I don't know how to skip entities.
|
void |
startDocument()
Starts a document.
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes attr)
Starts a new element.
|
void |
startPrefixMapping(String prefix,
String namespaceURI)
Starts use of a namespace prefix.
|
public void setEncoding(String pEncoding)
XMLWriter
setEncoding
in interface XMLWriter
pEncoding
- Writers encoding, by default null, in
which case UTF-8 is being used.public String getEncoding()
XMLWriter
getEncoding
in interface XMLWriter
public void setDeclarating(boolean pDeclarating)
XMLWriter
setDeclarating
in interface XMLWriter
pDeclarating
- Whether an XML declaration is generated. Defaults
to false.public boolean isDeclarating()
XMLWriter
isDeclarating
in interface XMLWriter
public void setIndenting(boolean pIndenting)
XMLWriter
XMLWriter
is indenting
(pretty printing). If you want indenting,
you should consider to invoke the methods
XMLWriter.setIndentString(java.lang.String)
and
XMLWriter.setLineFeed(java.lang.String)
as well.setIndenting
in interface XMLWriter
pIndenting
- Whether indentation is enabled. Defaults to false.public boolean isIndenting()
XMLWriter
XMLWriter
is indenting
(pretty printing). If you want indenting,
you should consider to invoke the methods
XMLWriter.setIndentString(java.lang.String)
and
XMLWriter.setLineFeed(java.lang.String)
as well.isIndenting
in interface XMLWriter
public void setIndentString(String pIndentString)
XMLWriter
setIndentString
in interface XMLWriter
pIndentString
- The indentation string, by default " " (two blanks).public String getIndentString()
XMLWriter
getIndentString
in interface XMLWriter
public void setLineFeed(String pLineFeed)
XMLWriter
setLineFeed
in interface XMLWriter
pLineFeed
- The line terminator, by default "\n"
(Line Feed). You might prefer "\r\n" (Carriage Return,
Line Feed), which is the default on Windows and related
operating systems.public String getLineFeed()
XMLWriter
getLineFeed
in interface XMLWriter
public void setFlushing(boolean pFlushing)
XMLWriter
ContentHandler.endDocument()
should do a flush on the target stream.setFlushing
in interface XMLWriter
pFlushing
- True, if a flush should be done. Defaults to
false.public boolean isFlushing()
XMLWriter
ContentHandler.endDocument()
should do a flush on the target stream.isFlushing
in interface XMLWriter
public void setWriter(Writer pWriter)
Sets the JaxbXMLSerializers Writer.
public Writer getWriter()
Returns the JaxbXMLSerializers Writer.
public void setDocumentLocator(Locator pLocator)
setDocumentLocator
in interface ContentHandler
pLocator
- A locator for use in case of errorsgetDocumentLocator()
public Locator getDocumentLocator()
setDocumentLocator(org.xml.sax.Locator)
public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException
Starts use of a namespace prefix.
startPrefixMapping
in interface ContentHandler
namespaceURI
- The namespace URIprefix
- The prefixSAXException
- Not actually thrown, just for compliance to the interface specification.public void endPrefixMapping(String prefix) throws SAXException
Terminates use of a namespace prefix.
endPrefixMapping
in interface ContentHandler
prefix
- The prefix being abandoned.SAXException
- Not actually thrown, just for compliance to the interface specification.public void startDocument() throws SAXException
Starts a document.
startDocument
in interface ContentHandler
SAXException
- Not actually thrown, just for compliance to the interface specification.public void endDocument() throws SAXException
This method finishs the handlers action. After calling endDocument you may start a new action by calling startDocument again.
endDocument
in interface ContentHandler
SAXException
- Not actually thrown, just for compliance to the
interface specification.public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ignorableWhitespace
in interface ContentHandler
ch
- A string of whitespace characters being inserted into the document.start
- The index of the first character.length
- The number of characters.SAXException
- Thrown in case of an IOException.public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
ch
- The characters being inserted. A substring, to be precise.start
- Index of the first characterlength
- Number of characters being insertedSAXException
- Thrown in case of an IOExceptionpublic boolean canEncode(char c)
XMLWriter
Returns whether the XMLWriter can encode the character
c
without an escape sequence like &#ddd;.
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
Terminates an element.
endElement
in interface ContentHandler
namespaceURI
- The namespace URI, if any, or nulllocalName
- The local name, without prefix, or nullqName
- The qualified name, including a prefix, or nullSAXException
- Thrown in case of an IOException.public void startElement(String namespaceURI, String localName, String qName, Attributes attr) throws SAXException
startElement
in interface ContentHandler
namespaceURI
- The namespace URI, if any, or nulllocalName
- The local name, without prefix, or nullqName
- The qualified name, including a prefix, or nullattr
- The element attributesSAXException
- Thrown in case of an IOException.public void skippedEntity(String ent) throws SAXException
skippedEntity
in interface ContentHandler
ent
- The entity being skipped.SAXException
- Not actually thrown, just for compliance to the interface specification.public void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface ContentHandler
target
- The PI targetdata
- The PI dataSAXException
- Thrown in case of an IOExceptionCopyright © 2005-2016 Apache Software Foundation. All Rights Reserved.