Skip to content

Package: IdentifierTypeVariableState2

IdentifierTypeVariableState2

nameinstructionbranchcomplexitylinemethod
IdentifierTypeVariableState2(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: 23 C: 90
80%
M: 3 C: 9
75%
M: 3 C: 4
57%
M: 4 C: 19
83%
M: 0 C: 1
100%
finish(Buffer, String)
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: /**
2: *
3: */
4: package scanner;
5:
6: import basic.Buffer;
7: import model.Position;
8: import symbols.AbstractSymbol;
9: import symbols.BracketCloseSymbol;
10: import symbols.IdentifierSymbol;
11: import symbols.UnknownSymbol;
12:
13: /**
14: * @author Hendrik
15: *
16: */
17: public class IdentifierTypeVariableState2 extends AbstractState {
18:         /**
19:          *
20:          * represents the collected Identifier Character as String.
21:          */
22:         private String collectedIdentifier;
23:
24:         /**
25:          * This constructor initialize the new IdentifierTypeVariableState2.
26:          *
27:          * @param myScanner
28:          * is the used scanner.
29:          * @param beginningColumn
30:          * is the Begin Column of the Symbol
31:          * @param beginningRow
32:          * is the beginning row of the symbol
33:          */
34:         public IdentifierTypeVariableState2(final Scanner myScanner, final Integer beginningColumn,
35:                         final Integer beginningRow) {
36:                 super(myScanner, beginningColumn, beginningRow);
37:                 this.collectedIdentifier = "";
38:         }
39:
40:         /*
41:          * (non-Javadoc)
42:          *
43:          * @see scanner.AbstractState#action(java.lang.Character, basic.Buffer, java.lang.String)
44:          */
45:         @Override
46:         public AbstractState action(final Character character,
47:                         final Buffer<AbstractSymbol> currentResult, final String dataPath)
48:                         throws InterruptedException {
49:                 final AbstractState state;
50:•                if (Character.isLetter(character.charValue()) || Character.isDigit(character)
51:•                                || character.equals(ScannerConstants.PERCENTAGE)
52:•                                || character.equals(ScannerConstants.UNDERSCORE)) {
53:                         this.collectedIdentifier = this.collectedIdentifier + character.toString();
54:                         this.getMyScanner().skip();
55:                         state = this;
56:•                } else if (character.equals(ScannerConstants.EQUALSIGN)) {
57:
58:                         this.finish(currentResult, dataPath);
59:                         state = new ConditionBeginState(this.getMyScanner(),
60:                                         this.getMyScanner().getColumnCounter(), this.getBeginningRow());
61:                         this.getMyScanner().skip();
62:•                } else if (character.equals(ScannerConstants.BRACKETCLOSESIGN)) {
63:
64:                         this.finish(currentResult, dataPath);
65:                         currentResult
66:                                         .put(new BracketCloseSymbol(new Position(this.getMyScanner().getRowCounter(),
67:                                                         this.getMyScanner().getColumnCounter(), dataPath)));
68:                         state = this.getMyScanner().getSelectionState();
69:                         this.getMyScanner().skip();
70:                 } else {
71:
72:                         currentResult.put(new UnknownSymbol(this.collectedIdentifier, new Position(
73:                                         this.getBeginningRow(), this.getMyScanner().getColumnCounter(), dataPath)));
74:                         state = this.getMyScanner().getSelectionState();
75:                         this.getMyScanner().skip();
76:                 }
77:                 return state;
78:         }
79:
80:         /*
81:          * (non-Javadoc)
82:          *
83:          * @see scanner.AbstractState#finish(basic.Buffer, java.lang.String)
84:          */
85:         @Override
86:         protected void finish(final Buffer<AbstractSymbol> currentResult, final String dataPath)
87:                         throws InterruptedException {
88:                 currentResult.put(new IdentifierSymbol(this.collectedIdentifier, new Position(
89:                                 this.getMyScanner().getRowCounter(), this.getBeginningColumn(), dataPath)));
90:
91:         }
92: }