From: <zep...@us...> - 2006-11-27 16:06:57
|
Revision: 209 http://svn.sourceforge.net/pzfilereader/?rev=209&view=rev Author: zepernick Date: 2006-11-27 08:06:49 -0800 (Mon, 27 Nov 2006) Log Message: ----------- more efficient check for unescaped qualifier contained within a qualified element. This new change avoids substring and left trim per Benoit's suggestion. Modified Paths: -------------- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/util/ParserUtils.java Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/util/ParserUtils.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/util/ParserUtils.java 2006-11-27 13:47:01 UTC (rev 208) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/util/ParserUtils.java 2006-11-27 16:06:49 UTC (rev 209) @@ -164,20 +164,29 @@ } else { endBlock = i + 1; } - } - //try to first look ahead 1 char. If we have a match on the delimiter it will drop to the else - //otherwise do one last check to make sure there is no space between the delimiter and - //the qualifer. This looks a little sloppy, but I am trying to avoid the left trim, and substring if - //possible. - // "a","b","c" should not call the lTrimKeepTabs - // "a", "b", "c" will use the lTrimKeepTabs to remove the space between the delimiter and qualifer - else if (i + 1 < size && delimiter != ' ' && - ((trimmedLine.charAt(i + 1) != ' ' && trimmedLine.charAt(i + 1) != delimiter) || - lTrimKeepTabs(trimmedLine.substring(i + 1)).charAt(0) != delimiter)) { - previousChar = currentChar; - endBlock = i + 1; - continue; } else { + if (i + 1 < size && delimiter != ' ') { + //this is used to allow unescaped qualifiers to be contained within the element + //do not run this check is a space is being used as a delimiter + //we don't want to trim the delimiter off + //loop until we find a char that is not a space, or we reach the end of the line. + int start = i + 1; + char charToCheck = trimmedLine.charAt(start); + while (charToCheck == ' ') { + start ++; + if (start == size) { + break; + } + charToCheck = trimmedLine.charAt(start); + } + + if (charToCheck != delimiter) { + previousChar = currentChar; + endBlock = i + 1; + continue; + } + + } insideQualifier = false; blockWasInQualifier = true; endBlock = i; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |