Improve code design.

This commit is contained in:
Christian P. MOMON 2013-09-30 16:34:35 +02:00
parent 438bf2e618
commit 433e0b4078

View file

@ -92,12 +92,12 @@ public class XMLWriter
*/
public void writeComment(final String comment)
{
out.print("<!-- ");
this.out.print("<!-- ");
if (comment != null)
{
writeTagContent(comment);
}
out.print(" -->");
this.out.print(" -->");
}
/**
@ -105,10 +105,10 @@ public class XMLWriter
*/
public void writeEmptyTag(final String label, final String... attributes)
{
out.print("<");
out.print(label);
this.out.print("<");
this.out.print(label);
writeTagAttributes(attributes);
out.print("/>");
this.out.print("/>");
}
/**
@ -116,9 +116,9 @@ public class XMLWriter
*/
public void writeEndTag(final String label)
{
out.print("</");
out.print(label);
out.print(">");
this.out.print("</");
this.out.print(label);
this.out.print(">");
}
/**
@ -126,10 +126,21 @@ public class XMLWriter
*/
public void writeStartTag(final String label, final String... attributes)
{
out.print("<");
out.print(label);
this.out.print("<");
this.out.print(label);
writeTagAttributes(attributes);
out.print(">");
this.out.print(">");
}
/**
*
*/
public void writeTag(final String label, final boolean content, final String... attributes)
{
writeStartTag(label, attributes);
writeTagContent(String.valueOf(content));
writeEndTag(label);
}
/**
@ -171,11 +182,11 @@ public class XMLWriter
{
for (int count = 0; count < attributes.length; count += 2)
{
out.print(" ");
out.print(attributes[count]);
out.print("=\"");
out.print(attributes[count + 1]);
out.print("\"");
this.out.print(" ");
this.out.print(attributes[count]);
this.out.print("=\"");
this.out.print(attributes[count + 1]);
this.out.print("\"");
}
}
}
@ -194,22 +205,22 @@ public class XMLWriter
switch (car)
{
case '<':
out.print("&lt;");
this.out.print("&lt;");
break;
case '>':
out.print("&gt;");
this.out.print("&gt;");
break;
case '&':
out.print("&amp;");
this.out.print("&amp;");
break;
case '"':
out.print("&quot;");
this.out.print("&quot;");
break;
case '\'':
out.print("&apos;");
this.out.print("&apos;");
break;
default:
out.print(car);
this.out.print(car);
}
}
}
@ -221,24 +232,24 @@ public class XMLWriter
{
//
out.print("<?xml");
this.out.print("<?xml");
//
if (!ArrayUtils.contains(attributes, "version"))
{
out.print(" version=\"1.0\"");
this.out.print(" version=\"1.0\"");
}
//
if (!ArrayUtils.contains(attributes, "encoding"))
{
out.print(" encoding=\"UTF-8\"");
this.out.print(" encoding=\"UTF-8\"");
}
//
if (!ArrayUtils.contains(attributes, "encoding"))
{
out.print(" standalone=\"no\"");
this.out.print(" standalone=\"no\"");
}
//
@ -247,15 +258,15 @@ public class XMLWriter
//
for (int count = 0; count < attributes.length; count += 2)
{
out.print(" ");
out.print(attributes[count]);
out.print("=\"");
out.print(attributes[count + 1]);
out.print("\"");
this.out.print(" ");
this.out.print(attributes[count]);
this.out.print("=\"");
this.out.print(attributes[count + 1]);
this.out.print("\"");
}
}
//
out.print(" ?>");
this.out.print(" ?>");
}
}