Skip to content

Package: RegExpState

RegExpState

nameinstructionbranchcomplexitylinemethod
RegExpState(Scanner, Integer, Integer)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
action(Character, Buffer, String)
M: 0 C: 28
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
finish(Buffer, String)
M: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: package scanner;
2:
3: import model.Position;
4: import symbols.AbstractSymbol;
5: import symbols.RegExpSymbol;
6: import basic.Buffer;
7:
8: /**
9: * This class represents the regular Expression.
10: *
11: * @author HFW410
12: *
13: */
14: public class RegExpState extends AbstractState {
15:         /**
16:          * This attribute represents the collected Chars as String in the RegExpState.
17:          */
18:         private String collectedChars;
19:
20:         /**
21:          * The constructor to initialize the RegExState.
22:          *
23:          * @param myScanner
24:          * the used Scanner
25:          * @param beginningColumn
26:          * is the Begin Column of the Symbol
27:          * @param beginningRow
28:          * is the beginning row of the symbol
29:          *
30:          */
31:         public RegExpState(final Scanner myScanner, final Integer beginningColumn,
32:                         final Integer beginningRow) {
33:                 super(myScanner, beginningColumn, beginningRow);
34:                 this.collectedChars = ScannerConstants.EMPTYSTRING;
35:         }
36:
37:         @SuppressWarnings("deprecation")
38:         @Override
39:         public AbstractState action(final Character character,
40:                         final Buffer<AbstractSymbol> currentResult, final String dataPath)
41:                         throws InterruptedException {
42:•                if (Character.isSpace(character)) {
43:                         this.finish(currentResult, dataPath);
44:                         return this.getMyScanner().getSelectionState();
45:                 } else {
46:                         this.collectedChars = this.collectedChars + character;
47:                         this.getMyScanner().skip();
48:                         return this;
49:                 }
50:         }
51:
52:         @Override
53:         protected void finish(final Buffer<AbstractSymbol> currentResult, final String dataPath)
54:                         throws InterruptedException {
55:                 currentResult.put(new RegExpSymbol(this.collectedChars, new Position(this
56:                                 .getBeginningRow(), this.getBeginningColumn(), dataPath)));
57:         }
58: }