/** * Indent the line. Called for proper indenting in various places. * * @param writer the writer which should receive the indentention. * @throws java.io.IOException if writing the stream failed. */ public void indentForClose( final Writer writer ) throws IOException { if ( openTags.isEmpty() ) { for ( int i = 0; i < additionalIndent; i++ ) { writer.write( indentString ); } return; } final ElementLevel level = (ElementLevel) openTags.peek(); if ( getTagDescription().hasCData( level.getNamespace(), level.getTagName() ) == false ) { doEndOfLine( writer ); for ( int i = 1; i < openTags.size(); i++ ) { writer.write( indentString ); } for ( int i = 0; i < additionalIndent; i++ ) { writer.write( indentString ); } } }
/** * Indent the line. Called for proper indenting in various places. * * @param writer the writer which should receive the indentention. * @throws java.io.IOException if writing the stream failed. */ public void indent( final Writer writer ) throws IOException { if ( openTags.isEmpty() ) { for ( int i = 0; i < additionalIndent; i++ ) { writer.write( indentString ); } return; } final ElementLevel level = (ElementLevel) openTags.peek(); if ( getTagDescription().hasCData( level.getNamespace(), level.getTagName() ) == false ) { doEndOfLine( writer ); for ( int i = 0; i < openTags.size(); i++ ) { writer.write( indentString ); } for ( int i = 0; i < additionalIndent; i++ ) { writer.write( indentString ); } } }
/** * Writes a comment into the generated xml file. * * @param writer the writer. * @param comment the comment text * @throws IOException if there is a problem writing to the character stream. */ public void writeComment( final Writer writer, final String comment ) throws IOException { if ( openTags.isEmpty() == false ) { final ElementLevel level = (ElementLevel) openTags.peek(); if ( getTagDescription().hasCData( level.getNamespace(), level.getTagName() ) == false ) { indent( writer ); } } setLineEmpty( false ); writer.write( "<!-- " ); writeTextNormalized( writer, comment, false ); writer.write( " -->" ); doEndOfLine( writer ); }
/** * Conditionally writes an end-of-line character. The End-Of-Line is only written, if the tag description indicates * that the currently open element does not expect any CDATA inside. Writing a newline for CDATA-elements may have * sideeffects. * * @param w the writer. * @throws java.io.IOException if there is an I/O problem. */ private void doEndOfLine( final Writer w ) throws IOException { if ( openTags.isEmpty() ) { if ( isWriteFinalLinebreak() ) { writeNewLine( w ); } } else { final ElementLevel level = (ElementLevel) openTags.peek(); if ( getTagDescription().hasCData( level.getNamespace(), level.getTagName() ) == false ) { writeNewLine( w ); } } }