From: <den...@us...> - 2010-10-29 20:28:33
|
Revision: 4836 http://jaffa.svn.sourceforge.net/jaffa/?rev=4836&view=rev Author: dennisl-jaffa Date: 2010-10-29 20:28:27 +0000 (Fri, 29 Oct 2010) Log Message: ----------- Added overloaded block() method that takes an int param, gets the String.valueOf the int, then does the normal block() logic which substrings and right pads to the specified length. This method is needed by a velocity template when it is calculating the line item line number as an int and then needs to print it as a string within a given block of space on a form. Modified Paths: -------------- trunk/JaffaComponentsPrinting/source/java/org/jaffa/modules/printing/services/FormFormatHelper.java Modified: trunk/JaffaComponentsPrinting/source/java/org/jaffa/modules/printing/services/FormFormatHelper.java =================================================================== --- trunk/JaffaComponentsPrinting/source/java/org/jaffa/modules/printing/services/FormFormatHelper.java 2010-10-29 18:18:01 UTC (rev 4835) +++ trunk/JaffaComponentsPrinting/source/java/org/jaffa/modules/printing/services/FormFormatHelper.java 2010-10-29 20:28:27 UTC (rev 4836) @@ -178,6 +178,22 @@ } /** + * First, the input int value is converted to a String. Then a substring of + * the String starting at Index 0 for the specified length, is returned. + * If the specified length is greater than the length of the String, the + * String is right-padded with spaces to the specified length. + * @param iStr The input int value to be acted upon. + * @param length The length of the output String. + * @return a substring of the String value of the input int value, + * right padded with spaces. + */ + public String block(int iStr, int length) { + String str = String.valueOf(iStr); + str = StringHelper.rpad(str, length); + return str.substring(0, length); + } + + /** * Returns a substring of the input String starting at Index 0 for the specified length. * The output String is always of the specified length, * right-justified, left padded with spaces. @@ -224,11 +240,11 @@ *@return the length of the input String array. */ public int length(String[] array) { - if (array != null) { + if (array != null) { return array.length; - } else { - return 0; - } + } else { + return 0; + } } /** @@ -236,11 +252,11 @@ *@return the size of the input List. */ public int length(List list) { - if (list != null) { + if (list != null) { return list.size(); - } else { - return 0; - } + } else { + return 0; + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |