com.jaxfront.core.util.io
Class XMLWriter

java.lang.Object
  extended by com.jaxfront.core.util.io.XMLWriter

public class XMLWriter
extends java.lang.Object


Constructor Summary
XMLWriter(java.io.Writer writer)
          Create an XMLWriter on top of an existing java.io.Writer.
 
Method Summary
 void close()
          Close this writer.
 XMLWriter endEntity()
          End the current entity.
static java.lang.String escapeXml(java.lang.String str)
           
static void main(java.lang.String[] args)
           
static java.lang.String replaceString(java.lang.String text, java.lang.String repl, java.lang.String with)
           
static java.lang.String replaceString(java.lang.String text, java.lang.String repl, java.lang.String with, int max)
          Replace a string with another string inside a larger string, for the first n values of the search string.
static void test1()
           
static void test2()
           
 XMLWriter writeAttribute(java.lang.String attr, java.lang.String value)
          Write an attribute out for the current entity.
 XMLWriter writeEntity(java.lang.String name)
          Begin to output an entity.
 XMLWriter writeText(java.lang.String text)
          Output body text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLWriter

public XMLWriter(java.io.Writer writer)
Create an XMLWriter on top of an existing java.io.Writer.

Method Detail

writeEntity

public XMLWriter writeEntity(java.lang.String name)
                      throws java.io.IOException
Begin to output an entity.

Parameters:
String - name of entity.
Throws:
java.io.IOException

writeAttribute

public XMLWriter writeAttribute(java.lang.String attr,
                                java.lang.String value)
Write an attribute out for the current entity. Any xml characters in the value are escaped. Currently it does not actually throw the exception, but the api is set that way for future changes.

Parameters:
String - name of attribute.
String - value of attribute.

endEntity

public XMLWriter endEntity()
                    throws java.io.IOException
End the current entity. This will throw an exception if it is called when there is not a currently open entity.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Close this writer. It does not close the underlying writer, but does throw an exception if there are as yet unclosed tags.

Throws:
java.io.IOException

writeText

public XMLWriter writeText(java.lang.String text)
                    throws java.io.IOException
Output body text. Any xml characters are escaped.

Throws:
java.io.IOException

escapeXml

public static java.lang.String escapeXml(java.lang.String str)

replaceString

public static java.lang.String replaceString(java.lang.String text,
                                             java.lang.String repl,
                                             java.lang.String with)

replaceString

public static java.lang.String replaceString(java.lang.String text,
                                             java.lang.String repl,
                                             java.lang.String with,
                                             int max)
Replace a string with another string inside a larger string, for the first n values of the search string.

Parameters:
text - String to do search and replace in
repl - String to search for
with - String to replace with
n - int values to replace
Returns:
String with n values replacEd

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException

test1

public static void test1()
                  throws java.io.IOException
Throws:
java.io.IOException

test2

public static void test2()
                  throws java.io.IOException
Throws:
java.io.IOException