|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.znerd.xmlenc.XMLEncoder
Encodes character streams for an XML document.
Constructor Summary | |
protected |
XMLEncoder()
Constructs a new XMLEncoder . |
Method Summary | |
void |
attribute(Writer out,
String name,
String value,
char quotationMark,
boolean escapeAmpersands)
Writes an attribute assignment. |
abstract void |
declaration(Writer out)
Writes an XML declaration. |
static XMLEncoder |
getEncoder(String encoding)
Retrieves an XMLEncoder for the specified encoding. |
abstract String |
getEncoding()
Returns the encoding of this outputter. |
abstract void |
text(Writer out,
char c)
Writes the specified character to the output stream. |
void |
text(Writer out,
char[] ch,
int start,
int length,
boolean escapeAmpersands)
Writes the text in the specified character array to the output stream. |
void |
text(Writer out,
String text,
boolean escapeAmpersands)
Writes the specified text to the output stream. |
void |
whitespace(Writer out,
char[] ch,
int start,
int length)
Writes the whitespace in the specified character array to the output stream. |
void |
whitespace(Writer out,
String s)
Writes the whitespace in the specified character string to the output stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected XMLEncoder()
XMLEncoder
.Method Detail |
public static final XMLEncoder getEncoder(String encoding) throws IllegalArgumentException, UnsupportedEncodingException
XMLEncoder
for the specified encoding. If no
suitable encoder can be found, then an exception is thrown.encoding
- the name of the encoding, not null
.null
.IllegalArgumentException
- if encoding == null
.UnsupportedEncodingException
- if the specified encoding is not supported.public abstract String getEncoding()
null
.public void text(Writer out, String text, boolean escapeAmpersands) throws NullPointerException, InvalidXMLException, IOException
out
- the output stream to print to, not null
.text
- the text to be printed.escapeAmpersands
- flag that indicates whether ampersands should be escaped.NullPointerException
- if out == null || text == null
.InvalidXMLException
- if the specified text contains an invalid character.IOException
- if an I/O error occurs.public void text(Writer out, char[] ch, int start, int length, boolean escapeAmpersands) throws NullPointerException, IndexOutOfBoundsException, InvalidXMLException, IOException
out
- the output stream to print to, not null
.ch
- the array from which to retrieve the text to be printed.start
- the start index into ch
, must be >= 0.length
- the number of characters to take from ch
, starting at
the start
index.escapeAmpersands
- flag that indicates if ampersands should be escaped.NullPointerException
- if out == null || ch == null
.IndexOutOfBoundsException
- if start < 0
|| start + length > ch.length
.InvalidXMLException
- if the specified text contains an invalid character.IOException
- if an I/O error occurs.public abstract void text(Writer out, char c) throws IOException
out
- the output stream to print to, not null
.c
- the character to be printed.IOException
- if an I/O error occurs.public abstract void declaration(Writer out) throws NullPointerException, IOException
out
- the Writer
to write the declaration to, not
null
.NullPointerException
- if out == null
.IOException
- if an I/O error occurs.public void whitespace(Writer out, String s) throws NullPointerException, InvalidXMLException, IOException
out
- the output stream to print to, not null
.s
- the character string to print.NullPointerException
- if out == null || s == null
.InvalidXMLException
- if the specified character string contains a character that is
invalid as whitespace.IOException
- if an I/O error occurs.public void whitespace(Writer out, char[] ch, int start, int length) throws NullPointerException, IndexOutOfBoundsException, InvalidXMLException, IOException
out
- the output stream to print to, not null
.ch
- the array from which to retrieve the text to be printed.start
- the start index into ch
, must be >= 0.length
- the number of characters to take from ch
, starting at
the start
index.NullPointerException
- if out == null || ch == null
.IndexOutOfBoundsException
- if start < 0
|| start + length > ch.length
.InvalidXMLException
- if the specified character array contains a character that is invalid
as whitespace.IOException
- if an I/O error occurs.public void attribute(Writer out, String name, String value, char quotationMark, boolean escapeAmpersands) throws NullPointerException, IOException
out
- the Writer
to write the declaration to, should not be
null
.name
- the name of the attribute, should not be null
.value
- the value of the attribute, should not be null
.quotationMark
- the quotation mark, must be either the apostrophe ('\''
)
or the quote character ('"'
).NullPointerException
- if out == null || value == null
.IllegalArgumentException
- if quotationMark != '\'' && quotationMark != '"'
.IOException
- if an I/O error occurs.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |