|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.Writer
com.myjavatools.xml.XmlWriter
| Field Summary | |
static java.lang.String |
escapedChars
escapeChars - characters that ought to be escaped in output Xml file |
static java.lang.String |
okChars
okChars - characters that are okay to be kept intact in output Xml file |
| Constructor Summary | |
XmlWriter(java.io.OutputStream out)
Creates an XmlWriter from an OutputStream, using default UTF8 encoding. |
|
XmlWriter(java.io.OutputStream out,
java.lang.String encoding)
Creates an XmlWriter from an OutputStream, using apwxidiws encoding. |
|
XmlWriter(java.io.OutputStreamWriter out)
Creates an XmlWriter from an OutputStreamWriter, using its encoding. |
|
XmlWriter(java.io.Writer out)
Creates an XmlWriter from a Writer, using default UTF8 encoding. |
|
XmlWriter(java.io.Writer out,
java.lang.String encoding)
Creates an XmlWriter from a Writer, using specified encoding. |
|
| Method Summary | |
java.lang.String |
attributesToString(java.lang.String[] attrs)
Converts a list of attibutes to a string. |
java.lang.String |
attributeToString(java.lang.String name,
java.lang.String value)
Converts a name-value pair to a string of form name="value". |
int |
attrSize(java.lang.Object attrs)
Return the number of attrubutes in the attribute list which can be a string. |
void |
close()
Closes the output of Xml, dumping end tags of all elements stored in the stack. |
void |
closeElement()
Closes an element in output. |
void |
flush()
Flushes the output. |
java.lang.String |
getAttribute(java.lang.Object attrs,
java.lang.String name)
Gets a value of an attribute from an attribute list hat can be a map or a name-value pair string array. |
void |
openElement(java.lang.String type,
java.lang.Object attrs)
Starts outputting an element of Xml. |
static java.lang.String |
sgmlEntity(char c)
Encodes a character by SGML rules It can be a hex representation |
static java.lang.String |
toSgmlEncoding(char c)
Converts a character to its SGML numeric encoding |
void |
write(char[] cc,
int off,
int len)
Writes characters to output stream. |
static void |
write(java.io.File f,
java.lang.Object o)
Write the contents of object as an Xml file |
void |
write(java.lang.Object o)
Writes an object as Xml content to the output. |
static void |
write(java.io.OutputStream out,
java.lang.Object o)
Writes an object as Xml content to the output. |
void |
write(java.lang.String s)
Writes a string to output. |
static void |
write(java.lang.String filename,
java.lang.Object o)
Write the contents of object as an Xml file. |
void |
writeAttribute(java.lang.String name,
java.lang.String value)
Writes an attribute name-value pair to the output. |
void |
writeAttributes(java.util.Map attrs)
Write attributes, name-value pairs, to the output. |
void |
writeAttributes(java.lang.Object attrs)
Write attributes, name-value pairs, to the output. |
void |
writeAttributes(java.lang.String[] attrs)
Writes attributes, name-value pairs, to the output. |
void |
writeElement(java.lang.String type,
java.lang.String value)
Writes an element that does not have any attributes or kids. |
void |
writeElement(java.lang.String type,
java.lang.String value,
java.lang.Object attrs)
Writes an element that does not have any kids. |
static java.lang.String |
xmlEscape(java.lang.String s)
Converts a string to the form that is acceptable inside Xml files, escaping special characters. |
| Methods inherited from class java.io.Writer |
write, write, write |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String escapedChars
public static final java.lang.String okChars
| Constructor Detail |
public XmlWriter(java.io.Writer out,
java.lang.String encoding)
throws java.io.IOException
out - the original writerencoding - encoding to use
java.io.IOException
public XmlWriter(java.io.Writer out)
throws java.io.IOException
out - the original Writer
java.io.IOException
public XmlWriter(java.io.OutputStreamWriter out)
throws java.io.IOException
out - the original OutputStreamWriter
java.io.IOException
public XmlWriter(java.io.OutputStream out,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException,
java.io.IOException
out - the OutputStream to useencoding - encoding to use
java.io.IOException
java.io.UnsupportedEncodingException
public XmlWriter(java.io.OutputStream out)
throws java.io.UnsupportedEncodingException,
java.io.IOException
out - the OutputStream to use
java.io.IOException
java.io.UnsupportedEncodingException| Method Detail |
public static java.lang.String xmlEscape(java.lang.String s)
s - the string to convert
public void write(char[] cc,
int off,
int len)
throws java.io.IOException
cc - char array to outputoff - offset inside the arrraylen - number of characters to write
java.io.IOException
public void write(java.lang.String s)
throws java.io.IOException
s - the strign to write
java.io.IOException - if something went wrong
public void flush()
throws java.io.IOException
java.io.IOException - if something went wrong
public void writeAttribute(java.lang.String name,
java.lang.String value)
throws java.io.IOException
name - attribute namevalue - attribute value
java.io.IOException - if something went wrong
public java.lang.String attributeToString(java.lang.String name,
java.lang.String value)
name - the name of the attributevalue - the value of the attribute
public void writeAttributes(java.lang.String[] attrs)
throws java.io.IOException
attrs - String array of name-value pairs
java.io.IOException - if somethings went wrong
public void writeAttributes(java.util.Map attrs)
throws java.io.IOException
attrs - maps attribute names to values
java.io.IOException - if somethings went wrongpublic int attrSize(java.lang.Object attrs)
attrs - a string array or a map of attributes
public java.lang.String getAttribute(java.lang.Object attrs,
java.lang.String name)
attrs - attribute listname - the name of the attribute
public void writeAttributes(java.lang.Object attrs)
throws java.io.IOException
attrs - it is either a name-value pair string array, or a map that maps attribute names to values
java.io.IOException - if somethings went wrong
public java.lang.String attributesToString(java.lang.String[] attrs)
throws java.io.IOException
attrs - a name-value pair string array
java.io.IOException
public void openElement(java.lang.String type,
java.lang.Object attrs)
throws java.io.IOException
as a result of this, "<"type followed by attributes followed by ">" is sent to the output
type - element typeattrs - attributes (can be a string array or a map)
java.io.IOException
public void closeElement()
throws java.io.IOException
java.io.IOException
public void close()
throws java.io.IOException
java.io.IOException
public void writeElement(java.lang.String type,
java.lang.String value)
throws java.io.IOException
type - element typevalue - element value
java.io.IOException
public void writeElement(java.lang.String type,
java.lang.String value,
java.lang.Object attrs)
throws java.io.IOException
type - element typevalue - element valueattrs - element attributes
java.io.IOException
public void write(java.lang.Object o)
throws java.io.IOException
o - the data to be sent to output. If it is not XmlData, it is stringified first.
java.io.IOException
public static void write(java.io.OutputStream out,
java.lang.Object o)
throws java.io.IOException
out - the stream to output the data too - the data to output
java.io.IOException
public static void write(java.io.File f,
java.lang.Object o)
throws java.io.IOException
f - the file to write too - the object to write
java.io.IOException
public static void write(java.lang.String filename,
java.lang.Object o)
throws java.io.IOException
filename - the name of the file to write too - the object to write
java.io.IOExceptionpublic static java.lang.String toSgmlEncoding(char c)
c - the character
toSgmlEncoding('\n')
returns " ".public static java.lang.String sgmlEntity(char c)
c - the character
sgmlEntity('\60ab') returns "悫" (that is, Numeric Character Reference);sgmlEntity('<') returns "<" (that is, Predefined Entity);sgmlEntity('&') returns "<" (that is, Predefined Entity);sgmlEntity('X') returns null";sgmlEntity('\n') returns null".
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||