|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
com.pelzer.util.XMLPrettyPrintOutputStream
public class XMLPrettyPrintOutputStream
As you pass in non-pretty xml, this will write out 'pretty' xml as best it can, but without validating the underlying XML in any way (as using the xerces code would require). This class may result in munged XML if whitespace was significant to it in some way. In general, this class reads an entire line of the incoming text, then parses it when a newline or stream close command comes in. If the line is empty (only whitespace) then the line is dropped. If the line starts with a '<' (after removing whitespace) then the system indents that line based on its perceived current depth.
| Constructor Summary | |
|---|---|
XMLPrettyPrintOutputStream(OutputStream target)
|
|
| Method Summary | |
|---|---|
void |
close()
Closes the underlying target stream. |
void |
flush()
Flushes the target |
static String |
getPrettyPrinted(String xml)
Takes a given XML as a string and does a pretty print. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLPrettyPrintOutputStream(OutputStream target)
| Method Detail |
|---|
public void write(int b)
throws IOException
write in class OutputStreamIOException
public void write(byte[] b)
throws IOException
write in class OutputStreamIOException
public void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOException
public void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOException
public void close()
throws IOException
close in interface Closeableclose in class OutputStreamIOExceptionpublic static String getPrettyPrinted(String xml)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||