View Javadoc
1   package org.csveed.token;
2   
3   public enum ParseState {
4       SKIP_LINE                      (false, false, false, false, true),
5       SKIP_LINE_FINISHED             (false, true,  false, false, true),
6       COMMENT_LINE                   (false, false, false, false, true),
7       COMMENT_LINE_FINISHED          (false, true,  false, false, true),
8       START_OF_LINE                  (false, false, false, false, false),
9       OUTSIDE_BEFORE_FIELD           (false, false, false, false, false),
10      OUTSIDE_AFTER_FIELD            (false, false, false, false, false),
11      INSIDE_FIELD                   (true,  false, false, false, false),
12      FIRST_CHAR_INSIDE_QUOTED_FIELD (false, false, false, true,  false),
13      INSIDE_QUOTED_FIELD            (true,  false, false, true,  false),
14      ESCAPING                       (false, false, false, false, false),
15      SEPARATOR                      (false, false, true,  false, false),
16      LINE_FINISHED                  (false, true,  true,  false, false),
17      FINISHED                       (false, true,  true,  false, false);
18  
19      /**
20      * When in this state, encountered symbols must be made part of the token
21      */
22      private boolean tokenize;
23  
24      /**
25      * When in this state, reading of the line is done
26      */
27      private boolean lineFinished;
28  
29      /**
30      * When in this state, the token may be popped
31      */
32      private boolean popToken;
33  
34      /**
35      * When a quote character is encountered here, this state MAY trigger an upgrade of the encountered symbol
36      */
37      private boolean upgradeQuoteToEscape;
38  
39      /**
40      * When in this state, ignore the entire line
41      */
42      private boolean ignore;
43  
44      private ParseState(final boolean tokenize, final boolean lineFinished, final boolean popToken,
45                         final boolean upgradeQuoteToEscape, final boolean ignore) {
46          this.tokenize = tokenize;
47          this.lineFinished = lineFinished;
48          this.popToken = popToken;
49          this.upgradeQuoteToEscape = upgradeQuoteToEscape;
50          this.ignore = ignore;
51      }
52  
53      public boolean isTokenize() {
54          return this.tokenize;
55      }
56  
57      public boolean isLineFinished() {
58          return this.lineFinished;
59      }
60  
61      public boolean isPopToken() {
62          return this.popToken;
63      }
64  
65      public boolean isUpgradeQuoteToEscape() {
66          return this.upgradeQuoteToEscape;
67      }
68  
69      public boolean isIgnore() {
70          return this.ignore;
71      }
72  
73      public boolean trim() {
74          return this == INSIDE_FIELD;
75      }
76  }