annotate src/goodjava/xml/Xml.java @ 1832:d55c3eaf21d7

add jar
author clarkton <ibraclarkton@gmail.com>
date Wed, 11 Dec 2024 17:17:56 +0000
parents a8c685a894b4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1790
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 package goodjava.xml;
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 public final class Xml {
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 public String declaration;
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 private XmlElement element;
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 public XmlElement getElement() {
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 return element;
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 }
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 public void setElement(XmlElement element) {
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 if( element == null )
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 throw new IllegalArgumentException("element can't be null");
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 this.element = element;
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 }
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 @Override public String toString() {
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 StringBuilder sb = new StringBuilder();
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 if( declaration != null ) {
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 sb.append( declaration );
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 sb.append( '\n' );
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 }
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 element.toString(sb,0);
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 return sb.toString();
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 }
a8c685a894b4 start xml work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 }