Changeset 6458


Ignore:
Timestamp:
May 19, 2014, 9:08:39 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1807: FlatFileParser? should check section header regexp before ignore regexp in hasMoreData method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/parser/FlatFileParser.java

    r6127 r6458  
    10931093    lines from the stream. Each line is checked in the following order:
    10941094    <ol>
    1095     <li>Does it match the {@link #setIgnoreRegexp(Pattern) ignore} regular
    1096       expression?</li>
    10971095    <li>Does it match the {@link #setDataFooterRegexp(Pattern) data footer}
    10981096      regular expression?</li>
    10991097    <li>Does it match the {@link #setSectionRegexp(Pattern) section}
    11001098      regular expression?</li>
     1099    <li>Does it match the {@link #setIgnoreRegexp(Pattern) ignore} regular
     1100      expression?</li>
    11011101    <li>Can it be split by the {@link #setDataSplitterRegexp(Pattern) data}
    11021102      regular expression into the appropriate number of columns?</li>
    11031103    </ol>
    1104     If the first check is true, TRUE is returned and the data may be
    1105     retrieved with the {@link #nextData() nextData} method. If the
    1106     second check is true, FALSE is returned and no more data may be
    1107     retrieved. If the third check is true, FALSE is returnd and no
    1108     more data may be retrived but the section may be retrived with
    1109     the {@link #nextSection() nextSection} method. If neither one is
    1110     true, the processing continues with the next line until the end
    1111     of file is reached.
     1104    If the first or second check is true, FALSE is returned no more data may be
     1105    retrieved, but a section may be retrived with the {@link #nextSection() nextSection}
     1106    method. If the third check is true, the line is ignored and the processing
     1107    continues with the next line. If the fourth check is true, TRUE is
     1108    returned and the data may be retrieved with the {@link #nextData() nextData} method.
    11121109
    11131110    @return TRUE if there is more data, FALSE otherwise
     
    11411138          parsedDataLines++;
    11421139          parsedCharacters += line.length();
    1143          
    1144           // Check if it is a comment line
    1145           if (!done && ignore != null)
    1146           {
    1147             Matcher m = ignore.matcher(line);
    1148             if (m.matches())
    1149             {
    1150               ignoredLines++;
    1151               if (keepSkippedLines) skippedLines.add(new Line(parsedLines, line, LineType.IGNORED));
    1152              
    1153               // Skip to next line
    1154               /* #### CONTINUE-STATEMENT #### */
    1155               continue;
    1156             }
    1157           }
    11581140
    11591141          // Check if it matches the data footer regexp
     
    11761158            }
    11771159          }
    1178          
     1160       
     1161          // Check if it is a comment line
     1162          if (!done && ignore != null)
     1163          {
     1164            Matcher m = ignore.matcher(line);
     1165            if (m.matches())
     1166            {
     1167              ignoredLines++;
     1168              if (keepSkippedLines) skippedLines.add(new Line(parsedLines, line, LineType.IGNORED));
     1169             
     1170              // Skip to next line
     1171              /* #### CONTINUE-STATEMENT #### */
     1172              continue;
     1173            }
     1174          }
     1175
    11791176          if (!done)
    11801177          {
Note: See TracChangeset for help on using the changeset viewer.