From: <be...@us...> - 2006-10-16 23:27:31
|
Revision: 64 http://svn.sourceforge.net/pzfilereader/?rev=64&view=rev Author: benoitx Date: 2006-10-16 16:27:19 -0700 (Mon, 16 Oct 2006) Log Message: ----------- A few Checkstyle and FindBugs resolutions. Modified Paths: -------------- trunk/PZFileReader/src/main/java/com/pz/reader/DataError.java trunk/PZFileReader/src/main/java/com/pz/reader/DataSet.java trunk/PZFileReader/src/main/java/com/pz/reader/LargeDataSet.java trunk/PZFileReader/src/main/java/com/pz/reader/ordering/OrderBy.java trunk/PZFileReader/src/main/java/com/pz/reader/util/ParserUtils.java trunk/PZFileReader/src/main/java/com/pz/reader/xml/PZMapParser.java Modified: trunk/PZFileReader/src/main/java/com/pz/reader/DataError.java =================================================================== --- trunk/PZFileReader/src/main/java/com/pz/reader/DataError.java 2006-10-16 21:19:38 UTC (rev 63) +++ trunk/PZFileReader/src/main/java/com/pz/reader/DataError.java 2006-10-16 23:27:19 UTC (rev 64) @@ -22,20 +22,19 @@ */ public class DataError { - /** Description of error */ + /** Description of error. */ private String errorDesc = null; - /** line number in file error occured on */ + /** line number in file error occured on. */ private int lineNo = 0; /** - * Severity of the error 1 = Warning 2 = Moderate 3 = Severe + * Severity of the error 1 = Warning 2 = Moderate 3 = Severe. */ private int errorLevel = 0; /** default constructor */ public DataError() { - super(); } /** Modified: trunk/PZFileReader/src/main/java/com/pz/reader/DataSet.java =================================================================== --- trunk/PZFileReader/src/main/java/com/pz/reader/DataSet.java 2006-10-16 21:19:38 UTC (rev 63) +++ trunk/PZFileReader/src/main/java/com/pz/reader/DataSet.java 2006-10-16 23:27:19 UTC (rev 64) @@ -823,7 +823,7 @@ * @exception NoSuchElementException * @return String */ - public String getString(final String column) throws NoSuchElementException { + public String getString(final String column) { final Row row = (Row) rows.get(pointer); final List cmds = ParserUtils.getColumnMetaData(row.getMdkey(), columnMD); @@ -850,7 +850,7 @@ * @exception NumberFormatException * @return double */ - public double getDouble(final String column) throws NoSuchElementException, NumberFormatException { + public double getDouble(final String column) { String s = null; final StringBuffer newString = new StringBuffer(); final String[] allowedChars = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "-" }; @@ -891,7 +891,7 @@ * @exception NumberFormatException * @return double */ - public int getInt(final String column) throws NoSuchElementException, NumberFormatException { + public int getInt(final String column) { String s = null; final StringBuffer newString = new StringBuffer(); final String[] allowedChars = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "-" }; @@ -1076,7 +1076,7 @@ * int * @exception IndexOutOfBoundsException */ - public void absolute(final int localPointer) throws IndexOutOfBoundsException { + public void absolute(final int localPointer) { if (localPointer < 0 || localPointer > rows.size() - 1) { throw new IndexOutOfBoundsException("INVALID POINTER LOCATION: " + localPointer); } Modified: trunk/PZFileReader/src/main/java/com/pz/reader/LargeDataSet.java =================================================================== --- trunk/PZFileReader/src/main/java/com/pz/reader/LargeDataSet.java 2006-10-16 21:19:38 UTC (rev 63) +++ trunk/PZFileReader/src/main/java/com/pz/reader/LargeDataSet.java 2006-10-16 23:27:19 UTC (rev 64) @@ -261,7 +261,7 @@ * int * @exception IndexOutOfBoundsException */ - public void absolute(final int localPointer) throws IndexOutOfBoundsException { + public void absolute(final int localPointer) { throw new RuntimeException("absolute() is Not Implemented For LargeDataSet"); } @@ -524,7 +524,7 @@ if (isHandleShortLines()) { // We can pad this line out while (line.length() < recordLength) { - line = line + " "; + line += ParserUtils.padding(recordLength-line.length(), ' '); } // log a warning Modified: trunk/PZFileReader/src/main/java/com/pz/reader/ordering/OrderBy.java =================================================================== --- trunk/PZFileReader/src/main/java/com/pz/reader/ordering/OrderBy.java 2006-10-16 21:19:38 UTC (rev 63) +++ trunk/PZFileReader/src/main/java/com/pz/reader/ordering/OrderBy.java 2006-10-16 23:27:19 UTC (rev 64) @@ -72,12 +72,13 @@ comp0 = row0.getValue(ParserUtils.findColumn(oc.getColumnName(), columnMD)).toLowerCase(); comp1 = row1.getValue(ParserUtils.findColumn(oc.getColumnName(), columnMD)).toLowerCase(); - if (comp0 == null) { - comp0 = new String(""); - } - if (comp1 == null) { - comp1 = new String(""); - } +//+ BX will never be equal to null. +// if (comp0 == null) { +// comp0 = new String(""); +// } +// if (comp1 == null) { +// comp1 = new String(""); +// } // multiply by the sort indicator to get a ASC or DESC result result = comp0.compareTo(comp1) * oc.getSortIndicator(); Modified: trunk/PZFileReader/src/main/java/com/pz/reader/util/ParserUtils.java =================================================================== --- trunk/PZFileReader/src/main/java/com/pz/reader/util/ParserUtils.java 2006-10-16 21:19:38 UTC (rev 63) +++ trunk/PZFileReader/src/main/java/com/pz/reader/util/ParserUtils.java 2006-10-16 23:27:19 UTC (rev 64) @@ -400,7 +400,7 @@ * @return int - position of the column in the file * @throws NoSuchElementException */ - public static int findColumn(final String columnName, final List columnMD) throws NoSuchElementException { + public static int findColumn(final String columnName, final List columnMD) { for (int i = 0; i < columnMD.size(); i++) { final ColumnMetaData cmd = (ColumnMetaData) columnMD.get(i); if (cmd.getColName().equalsIgnoreCase(columnName)) { @@ -679,4 +679,38 @@ } } + + /** + * <p>Returns padding using the specified delimiter repeated + * to a given length.</p> + * + * <pre> + * StringUtils.padding(0, 'e') = "" + * StringUtils.padding(3, 'e') = "eee" + * StringUtils.padding(-2, 'e') = IndexOutOfBoundsException + * </pre> + * + * <p>Note: this method doesn't not support padding with + * <a href="http://www.unicode.org/glossary/#supplementary_character">Unicode Supplementary Characters</a> + * as they require a pair of <code>char</code>s to be represented. + * If you are needing to support full I18N of your applications + * consider using {@link #repeat(String, int)} instead. + * </p> + * + * @param repeat number of times to repeat delim + * @param padChar character to repeat + * @return String with repeated character + * @throws IndexOutOfBoundsException if <code>repeat < 0</code> + * @see #repeat(String, int) + */ + public static String padding(int repeat, char padChar) { + if (repeat < 0) { + throw new IndexOutOfBoundsException("Cannot pad a negative amount: " + repeat); + } + final char[] buf = new char[repeat]; + for (int i = 0; i < buf.length; i++) { + buf[i] = padChar; + } + return new String(buf); + } } Modified: trunk/PZFileReader/src/main/java/com/pz/reader/xml/PZMapParser.java =================================================================== --- trunk/PZFileReader/src/main/java/com/pz/reader/xml/PZMapParser.java 2006-10-16 21:19:38 UTC (rev 63) +++ trunk/PZFileReader/src/main/java/com/pz/reader/xml/PZMapParser.java 2006-10-16 23:27:19 UTC (rev 64) @@ -37,7 +37,7 @@ */ public final class PZMapParser { - private static boolean SHOW_DEBUG = false; + private static boolean showDebug = false; /** * Constructor @@ -123,7 +123,7 @@ mdIndex.put(xmlElement.getAttributeValue("id"), xmlre); } - if (SHOW_DEBUG) { + if (showDebug) { showDebug(mdIndex); } @@ -189,7 +189,7 @@ * @param b */ public static void setDebug(final boolean b) { - SHOW_DEBUG = b; + showDebug = b; } private static void showDebug(final Map xmlResults) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zep...@us...> - 2006-10-17 14:21:37
|
Revision: 65 http://svn.sourceforge.net/pzfilereader/?rev=65&view=rev Author: zepernick Date: 2006-10-17 07:21:32 -0700 (Tue, 17 Oct 2006) Log Message: ----------- removed exception for DataSets containing <record> mappings when an orderBy was called Added logic to push all non-detail records to the bottom of the DataSet on a sort Modified Paths: -------------- trunk/PZFileReader/src/main/java/com/pz/reader/DataSet.java trunk/PZFileReader/src/main/java/com/pz/reader/ordering/OrderBy.java Modified: trunk/PZFileReader/src/main/java/com/pz/reader/DataSet.java =================================================================== --- trunk/PZFileReader/src/main/java/com/pz/reader/DataSet.java 2006-10-16 23:27:19 UTC (rev 64) +++ trunk/PZFileReader/src/main/java/com/pz/reader/DataSet.java 2006-10-17 14:21:32 UTC (rev 65) @@ -1154,9 +1154,11 @@ * @see com.pz.reader.ordering.OrderColumn */ public void orderRows(final OrderBy ob) throws Exception { - if (columnMD.size() > 1) { - throw new Exception("orderRows does not currently support ordering with <RECORD> mappings"); - } + //PZ try to handle other <records> by sending them to + //the bottom of the sort + // if (columnMD.size() > 1) { + // throw new Exception("orderRows does not currently support ordering with <RECORD> mappings"); + // } final List cmds = ParserUtils.getColumnMetaData("detail", columnMD); if (ob != null && rows != null) { ob.setColumnMD(cmds); Modified: trunk/PZFileReader/src/main/java/com/pz/reader/ordering/OrderBy.java =================================================================== --- trunk/PZFileReader/src/main/java/com/pz/reader/ordering/OrderBy.java 2006-10-16 23:27:19 UTC (rev 64) +++ trunk/PZFileReader/src/main/java/com/pz/reader/ordering/OrderBy.java 2006-10-17 14:21:32 UTC (rev 65) @@ -66,9 +66,17 @@ for (int i = 0; i < orderbys.size(); i++) { oc = (OrderColumn) orderbys.get(i); + + //null indicates "detail" record which is what the parser assigns to <column> 's setup outside of <record> elements + //shift all non detail records to the bottom of the DataSet + if (row0.getMdkey() != null && !row0.getMdkey().equals("detail")){ + return 1; + }else if (row1.getMdkey() != null && !row1.getMdkey().equals("detail")){ + return 0; + } + // convert to one type of case so the comparator does not take case // into account when sorting - comp0 = row0.getValue(ParserUtils.findColumn(oc.getColumnName(), columnMD)).toLowerCase(); comp1 = row1.getValue(ParserUtils.findColumn(oc.getColumnName(), columnMD)).toLowerCase(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |