/** * Writes the given text into the stream using a streaming xml-normalization method. * * @param s the string to be written. * @param transformNewLine whether to encode newlines using character-entities. * @throws IOException if an IO error occured. */ public void writeTextNormalized( final String s, final boolean transformNewLine ) throws IOException { support.writeTextNormalized( writer, s, transformNewLine ); }
/** * Normalizes the given string and writes the result directly to the stream. * * @param writer the writer that should receive the normalized content. * @param s the string that should be XML-Encoded. * @param transformNewLine a flag controling whether to transform newlines into character-entities. * @throws IOException if writing to the stream failed. */ public void writeTextNormalized( final Writer writer, final String s, final boolean transformNewLine ) throws IOException { writeTextNormalized( writer, s, charsetEncoder, transformNewLine ); }
/** * Normalises a string, replacing certain characters with their escape sequences so that the XML text is not * corrupted. * * @param s the string. * @param transformNewLine true, if a newline in the string should be converted into a character entity. * @return the normalised string. */ public static String normalize( final String s, final boolean transformNewLine ) { if ( s == null ) { return ""; } final StringWriter writer = new StringWriter( s.length() ); try { writeTextNormalized( writer, s, null, transformNewLine ); } catch ( final IOException e ) { LOGGER.error( e ); return s; } return writer.toString(); }
writeTextNormalized( w, entry.getValue(), true ); w.write( "\"" );
/** * 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 ); }