com.generationjava.io.xml
Class XmlWriter

java.lang.Object
  extended by com.generationjava.io.xml.XmlWriter

public class XmlWriter
extends java.lang.Object

Makes writing XML much much easier.

Version:
0.1
Author:
Henri Yandell

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 void main(java.lang.String[] args)
          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 WritingException
Begin to output an entity.

Parameters:
String - name of entity.
Throws:
WritingException

writeAttribute

public XmlWriter writeAttribute(java.lang.String attr,
                                java.lang.String value)
                         throws WritingException
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.
Throws:
WritingException

endEntity

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

Throws:
WritingException

close

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

Throws:
WritingException

writeText

public XmlWriter writeText(java.lang.String text)
                    throws WritingException
Output body text. Any xml characters are escaped.

Throws:
WritingException

main

public static void main(java.lang.String[] args)
                 throws WritingException
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
Throws:
WritingException

test1

public static void test1()
                  throws WritingException
Throws:
WritingException

test2

public static void test2()
                  throws WritingException
Throws:
WritingException