/** * Convenience method to write XML comment line break with <code>columnSize</code> as length. * * @param writer not null * @param columnSize positive number * @throws IOException if writing fails. */ public static void writeCommentLineBreak( XMLWriter writer, int columnSize ) throws IOException { if ( columnSize < 10 ) { columnSize = DEFAULT_COLUMN_LINE; } writer.writeMarkup( "<!-- " + StringUtils.repeat( "=", columnSize - 10 ) + " -->" + LS ); }
/** * Left pad a String with a specified string. Pad to a size of n. * * @param str String to pad out * @param size size to pad to * @param delim String to pad with * @return left padded String * @throws NullPointerException if str or delim is null * @throws ArithmeticException if delim is the empty string */ @Nonnull public static String leftPad( @Nonnull String str, int size, @Nonnull String delim ) { size = ( size - str.length() ) / delim.length(); if ( size > 0 ) { str = repeat( delim, size ) + str; } return str; }
/** * <p>Right pad a String with a specified string.</p> * <p/> * <p>The String is padded to the size of <code>n</code>.</p> * * @param str String to pad out * @param size size to pad to * @param delim String to pad with * @return right padded String * @throws NullPointerException if str or delim is <code>null</code> * @throws ArithmeticException if delim is the empty String */ @Nonnull public static String rightPad( @Nonnull String str, int size, @Nonnull String delim ) { size = ( size - str.length() ) / delim.length(); if ( size > 0 ) { str += repeat( delim, size ); } return str; }
private void writeBoxedWarning( String message ) { String line = StringUtils.repeat( "*", message.length() + 4 ); getLog().warn( line ); getLog().warn( "* " + MessageUtils.buffer().strong( message ) + " *" ); getLog().warn( line ); } }
private void writeBoxedWarning( String message ) { String line = StringUtils.repeat( "*", message.length() + 4 ); getLog().warn( line ); getLog().warn( "* " + MessageUtils.buffer().strong( message ) + " *" ); getLog().warn( line ); } }
/** * Convenience method to repeat <code>CRLF</code> and to indent the writer by <code>indentSize</code>. * * @param writer not null * @param repeat The number of repetitions of the indent * @param indent positive number * @param indentSize positive number * @throws IOException if writing fails. */ public static void writeLineBreak( XMLWriter writer, int repeat, int indent, int indentSize ) throws IOException { writeLineBreak( writer, repeat ); if ( indent < 0 ) { indent = 0; } if ( indentSize < 0 ) { indentSize = 0; } writer.writeText( StringUtils.repeat( " ", indent * indentSize ) ); }
String indentation = StringUtils.repeat( " ", indent * indentSize ); int magicNumber = indentation.length() + columnSize - "-->".length() - 1; String[] sentences = StringUtils.split( comment, LS ); line.append( StringUtils.repeat( " ", magicNumber - line.length() ) ); line.append( StringUtils.repeat( " ", magicNumber - line.length() ) ); line.append( StringUtils.repeat( " ", magicNumber - line.length() ) );