public class XmlBeautificator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
bEof |
(package private) char[] |
buffer |
(package private) java.lang.CharSequence |
csBuffer |
(package private) int |
end |
(package private) java.io.File |
fin |
(package private) java.io.File |
fout |
(package private) int |
indent
Indent for the next newline
|
(package private) int |
len |
(package private) int |
pos |
(package private) java.io.Reader |
rin |
(package private) java.lang.String |
sEncoding |
(package private) char[] |
sNewline
Newline chars, starts with '\n' then spaces.
|
(package private) java.lang.String |
sPathInZip
If not null fin is a zip file, read this content.
|
(package private) java.lang.String |
sWhitespaces |
(package private) java.util.Stack<java.lang.String> |
tags |
(package private) java.io.Writer |
wout |
(package private) java.util.zip.ZipEntry |
zipEntry |
(package private) java.util.zip.ZipFile |
zipfin
If not null the zip file is opened and should be closed.
|
Constructor and Description |
---|
XmlBeautificator() |
Modifier and Type | Method and Description |
---|---|
private boolean |
evaluateContent()
Looks for textual content between tag elements and writes the close if found.
|
private void |
evaluateElement(int recursion)
Evaluate one element and recursively all nested ones.
|
(package private) void |
evaluateStartTag()
Reads first the content with
len character. |
static void |
main(java.lang.String[] args)
Calls the beautification from command line.
|
(package private) void |
openInput() |
private void |
read()
|
private void |
rw(java.lang.String[] args)
This is the main routine.
|
private void |
writeCloseTag()
Writes the closing tag "
|
private void |
writeNewline() |
int len
char[] buffer
int pos
int end
boolean bEof
java.io.File fin
java.io.File fout
java.util.zip.ZipFile zipfin
java.util.zip.ZipEntry zipEntry
java.lang.String sPathInZip
java.io.Reader rin
java.io.Writer wout
java.lang.String sEncoding
final java.lang.String sWhitespaces
int indent
char[] sNewline
final java.lang.CharSequence csBuffer
java.util.Stack<java.lang.String> tags
private void rw(java.lang.String[] args)
evaluateStartTag()
.
If the encoding (contained in first element ) is not UTF-8 the input will be closed
and opened again, done in evaluateStartTag()
.
evaluateElement(int)
for the whole only one element of the top level.
All other is recursively.args
- see main(String[])
void openInput() throws java.io.IOException
java.io.IOException
void evaluateStartTag() throws java.io.IOException
len
character.
It looks for "encoding=\"". It his is not identically with the initial sEncoding
("UTF-8")
then it closes the input file and reopens it with the given encoding.
java.io.IOException
private void read() throws java.io.IOException
rin
input file if the buffer pos
is in the second half.
Then also it shifts to content in buffer, pos
= 0.
pos
is in the first half, nothing is done.
As effect at least the half buffer is filled and evaluatable from pos
to end
java.io.IOException
private void evaluateElement(int recursion) throws java.io.IOException
recursion
- java.io.IOException
private void writeCloseTag() throws java.io.IOException
java.io.IOException
private boolean evaluateContent() throws java.io.IOException
bNestedBefore
- true if an element java.io.IOException
private void writeNewline() throws java.io.IOException
java.io.IOException
public static void main(java.lang.String[] args)
args
- First argument is path/to/input.xml
Second argument is path/to/output.xml