protected String format()

in src/java/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderImpl.java [997:1034]


    protected String format( String source )
    {
        boolean isTruncated = false;

        // test for null or empty string
        if ( StringUtils.isEmpty(source) )
        	return "";

        // remove the line breaks and tabs for logging output and replace
        StringUtils.replace(source,  "\r",  " ");
        StringUtils.replace(source,  "\n",  " ");
        StringUtils.replace(source,  "\t",  " ");
        StringUtils.replace(source,  SEPERATOR,  " ");

        // Build the output
        StringBuilder stringBuilder = new StringBuilder(source);

        // trim the string to avoid dumping tons of data
        if( stringBuilder.length() > this.getMaxArgLength() )
        {
            stringBuilder.delete(this.getMaxArgLength()-1, stringBuilder.length());
            isTruncated = true;
        }
        
        // show the user that we truncated the ouptut
        if( isTruncated )
        {
            if (source.endsWith("]"))
            {
                stringBuilder.append(" ...]");
            }
            else
            {
                stringBuilder.append(" ...");
            }
        }
        return stringBuilder.toString();
    }