|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.brains2b.saxo.SAXWriter
A SAX method like XML writer To be sure there is no such thing as a SAXWriter for SAX 2, in as much as it isn't defined in the API.
This class is provided because I needed it and because I think it would be handy to have a Writer that takes at least part of the DocumentHandler interface not to read but to write a document preventing me to have to spell out all the tags every time I need to write XML data to file.
Public Members throw SAXException, instead of IOException to keep in line with the SAX specification. Possible next versions will throw subtypes of SAXException, containing writing information and position.
Note: The Writer writes to files only if you supply it by String no URL connections will be openend. If you want to write to another target use the SAXWriter(Writer) constructor instead.
Constructor Summary | |
SAXWriter()
Default empty constructor. |
|
SAXWriter(java.lang.String location)
Constructor Sets the file to open a StreamWriter on. |
|
SAXWriter(java.io.Writer writer)
Constructor Sets the Writer where the output will go. |
Method Summary | |
void |
endComment()
end a comment in an XML document any content or element written after calling start en before calling end will be written inside the comment |
void |
endDocument()
ends the Document. |
void |
endElement(java.lang.String name)
end Element. |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localname,
java.lang.String qname)
end Element. |
void |
endPrefixMapping(java.lang.String prefix)
|
boolean |
getFeature(java.lang.String name)
|
java.io.Writer |
getWriter()
gets the Writer used for output |
void |
insertDescriptor()
insert Descriptor. |
void |
insertElement(java.lang.String name,
org.xml.sax.Attributes attr)
inserts an EMPTY Element Although I would not see a purpose for this method if you do, you can leave the AttributeList empty. |
void |
insertElement(java.lang.String namespaceURI,
java.lang.String localname,
java.lang.String qname,
org.xml.sax.Attributes attr)
inserts an EMPTY Element For non-EMPTY Elements use startElement. |
void |
setContent(java.lang.String content)
sets the Character Content of an Element. |
void |
setFeature(java.lang.String name,
boolean value)
|
void |
setWriter(java.io.Writer writer)
sets the Writer used for output |
void |
startComment()
start a comment in an XML document any content or element written after calling start en before calling end will be written inside the comment |
void |
startDocument()
start Document. |
void |
startElement(java.lang.String name,
org.xml.sax.Attributes attr)
start Element. |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localname,
java.lang.String qname,
org.xml.sax.Attributes attr)
start Element. |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SAXWriter()
public SAXWriter(java.io.Writer writer)
writer
- java.io.Writerpublic SAXWriter(java.lang.String location)
location
- StringMethod Detail |
public void startDocument() throws org.xml.sax.SAXException
Does not insert the default processing Instruction for XML. You have to call insertDescriptor() yourself.
org.xml.sax.SAXException
insertDescriptor()
public void endDocument() throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void insertDescriptor() throws org.xml.sax.SAXException
Inserts a descriptor of the type: <xml version="1.0" encoding="UTF-8" > into the document. If you need it. If you need it call it after startDocument to end up with a valid xml document.
org.xml.sax.SAXException
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.startPrefixMapping(String, String)
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.endPrefixMapping(String)
public void startComment() throws org.xml.sax.SAXException
any content or element written after calling start en before calling end will be written inside the comment
org.xml.sax.SAXException
- if start cannot be writtenpublic void endComment() throws org.xml.sax.SAXException
any content or element written after calling start en before calling end will be written inside the comment
org.xml.sax.SAXException
- if end cannot be writtenpublic void startElement(java.lang.String name, org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
For EMPTY elements use insertElement.
You can insert null for the AttributeList if you don't need it. Parsers however will always return an AttributeList Object even it contains no attributes.
name
- attr
-
java.io.IOException
org.xml.sax.SAXException
insertElement(String, Attributes)
public void startElement(java.lang.String namespaceURI, java.lang.String localname, java.lang.String qname, org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
For EMPTY elements use insertElement.
You can insert null for the AttributeList if you don't need it. Parsers however will always return an AttributeList Object even it contains no attributes.
namespaceURI
- String, the namespace to declarelocalname
- Stringqname
- Stringattr
- Attributes
org.xml.sax.SAXException
insertElement(String, Attributes)
public void endElement(java.lang.String name) throws org.xml.sax.SAXException
For EMPTY elements use insertElement.
Do not call this after insertElement.
name
- String, the local or qname of the element
org.xml.sax.SAXException
insertElement(String, Attributes)
public void endElement(java.lang.String namespaceURI, java.lang.String localname, java.lang.String qname) throws org.xml.sax.SAXException
For EMPTY elements use insertElement.
Do not call this after insertElement.
namespaceURI
- Stringlocalname
- String, the localname the elementqname
- String, the qname of the element
org.xml.sax.SAXException
insertElement(String, Attributes)
public void insertElement(java.lang.String name, org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
Although I would not see a purpose for this method if you do, you can leave the AttributeList empty. For non-EMPTY Elements use startElement.
name
- String, can be either a localname or qnameattr
- Attributes
org.xml.sax.SAXException
startElement(String, Attributes)
public void insertElement(java.lang.String namespaceURI, java.lang.String localname, java.lang.String qname, org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
For non-EMPTY Elements use startElement.
namespaceURI
- String, the namespace to declarelocalname
- String, can be either a localname or qnameqname
- String, null if setting the default namespaceattr
- Attributes, null if no attributes need to be defined
org.xml.sax.SAXException
startElement(String, Attributes)
public void setContent(java.lang.String content) throws org.xml.sax.SAXException
content
-
org.xml.sax.SAXException
public boolean getFeature(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public void setFeature(java.lang.String name, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public java.io.Writer getWriter()
public void setWriter(java.io.Writer writer)
writer
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |