comparison src/goodjava/xml/XmlElement.java @ 1467:509d49c493c0

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 13 Apr 2020 22:16:59 -0600
parents 670b7d089699
children 35f3bfd4f51d
comparison
equal deleted inserted replaced
1466:670b7d089699 1467:509d49c493c0
39 } 39 }
40 sb.append( '>' ); 40 sb.append( '>' );
41 if( content instanceof String ) { 41 if( content instanceof String ) {
42 String s = (String)content; 42 String s = (String)content;
43 sb.append(s); 43 sb.append(s);
44 } else if( content instanceof XmlElement[] ) { 44 } else {
45 XmlElement[] elements = (XmlElement[])content; 45 XmlElement[] elements = (XmlElement[])content;
46 sb.append( '\n' ); 46 sb.append( '\n' );
47 for( XmlElement element : elements ) { 47 for( XmlElement element : elements ) {
48 element.toString(sb,indented+1); 48 element.toString(sb,indented+1);
49 } 49 }
50 indent(sb,indented); 50 indent(sb,indented);
51 } else 51 }
52 throw new RuntimeException();
53 sb.append( "</" ); 52 sb.append( "</" );
54 sb.append( name ); 53 sb.append( name );
55 sb.append( ">\n" ); 54 sb.append( ">\n" );
56 } 55 }
57 56
58 private void indent(StringBuilder sb,int indented) { 57 private static void indent(StringBuilder sb,int indented) {
59 for( int i=0; i<indented; i++ ) { 58 for( int i=0; i<indented; i++ ) {
60 sb.append('\t'); 59 sb.append('\t');
61 } 60 }
62 } 61 }
63 62