Package: StringState
StringState
| name | instruction | branch | complexity | line | method | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| StringState(Scanner, Integer, Integer, Character) | 
  | 
  | 
  | 
  | 
  | 
||||||||||||||||||||
| action(Character, Buffer, String) | 
  | 
  | 
  | 
  | 
  | 
||||||||||||||||||||
| finish(Buffer, String) | 
  | 
  | 
  | 
  | 
  | 
||||||||||||||||||||
Coverage
1: package scanner;
2: 
3: import model.Position;
4: import symbols.AbstractSymbol;
5: import symbols.StringSymbol;
6: import symbols.UnknownSymbol;
7: import basic.Buffer;
8: 
9: /**
10:  * This class represents the StringState.
11:  * 
12:  * @author HFW410
13:  * 
14:  */
15: public class StringState extends AbstractState {
16:         /**
17:          * represents the collected Chars.
18:          */
19:         private String collectedChars;
20:         /**
21:          * the sign, which initiated the string.
22:          */
23:         private final Character quote;
24: 
25:         /**
26:          * initialize the StringState.
27:          * 
28:          * @param myScanner
29:          *            is the used scanner.
30:          * @param beginningColumn
31:          *            is the Begin Column of the Symbol
32:          * @param beginningRow
33:          *            is the beginning row of the symbol
34:          * @param quote
35:          *            is the sign, which initated the string
36:          */
37:         public StringState(final Scanner myScanner, final Integer beginningColumn,
38:                         final Integer beginningRow, final Character quote) {
39:                 super(myScanner, beginningColumn, beginningRow);
40:                 this.collectedChars = ScannerConstants.EMPTYSTRING;
41:                 this.quote = quote;
42:         }
43: 
44:         @Override
45:         public AbstractState action(final Character character,
46:                         final Buffer<AbstractSymbol> currentResult, final String dataPath)
47:                         throws InterruptedException {
48:•                if (character.equals(this.quote)) {
49:                         currentResult.put(new StringSymbol(this.collectedChars, new Position(this
50:                                         .getBeginningRow(), this.getBeginningColumn(), dataPath)));
51:                         this.getMyScanner().skip();
52:                         return this.getMyScanner().getSelectionState();
53:                 } else {
54:                         this.collectedChars = this.collectedChars + character;
55:                         this.getMyScanner().skip();
56:                         return this;
57:                 }
58:         }
59: 
60:         @Override
61:         protected void finish(final Buffer<AbstractSymbol> currentResult, final String dataPath)
62:                         throws InterruptedException {
63:                 currentResult.put(new UnknownSymbol(this.quote
64:                                 + this.collectedChars.substring(0, this.collectedChars.length() - 1),
65:                                 new Position(this.getBeginningRow(), this.getBeginningColumn(), dataPath)));
66:         }
67: 
68: }