Package: VariableState
VariableState
| name | instruction | branch | complexity | line | method | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| VariableState(AbstractSymbol, TempTypeExtensionWithCondition) | 
  | 
  | 
  | 
  | 
  | 
||||||||||||||||||||
| getVariable() | 
  | 
  | 
  | 
  | 
  | 
||||||||||||||||||||
| parse(RouterSoftware, TempVariableType, Buffer, TypeFileParser) | 
  | 
  | 
  | 
  | 
  | 
||||||||||||||||||||
Coverage
1: /**
2:  * 
3:  */
4: package parser.states.typestates;
5: 
6: import model.RouterSoftware;
7: import parser.ParserException;
8: import parser.TypeFileParser;
9: import parser.tempparserobjects.TempTypeExtensionWithCondition;
10: import parser.tempparserobjects.TempVariableType;
11: import symbols.AbstractSymbol;
12: import symbols.BracketCloseSymbol;
13: import symbols.EqualsTildeSymbol;
14: import symbols.IdentifierSymbol;
15: import basic.Buffer;
16: 
17: /**
18:  * @author Hendrik
19:  * 
20:  */
21: public class VariableState extends AbstractTypeState {
22:         /**
23:          * The Variable.
24:          */
25:         private final AbstractSymbol variable;
26:         /**
27:          * the identifierSymbol.
28:          */
29:         private final TempTypeExtensionWithCondition tempExt;
30: 
31:         /**
32:          * The constructor.
33:          * 
34:          * @param variable
35:          *            the variable of the last state.
36:          * @param tempExt
37:          *            the identifierSymbol of the line;
38:          */
39: 
40:         public VariableState(final AbstractSymbol variable, final TempTypeExtensionWithCondition tempExt) {
41:                 super();
42:                 this.variable = variable;
43:                 this.tempExt = tempExt;
44: 
45:         }
46: 
47:         /*
48:          * (non-Javadoc)
49:          * 
50:          * @see
51:          * parser.states.typestates.AbstractTypeState#parse(parser.tempparserobjects.TempVariableType,
52:          * basic.Buffer, parser.TypeFileParser)
53:          */
54:         @Override
55:         public void parse(final RouterSoftware rs, final TempVariableType tVT,
56:                         final Buffer<AbstractSymbol> buffer, final TypeFileParser tFP)
57:                         throws InterruptedException, ParserException {
58:                 AbstractSymbol nextSymbol = buffer.remove();
59:                 this.tempExt.setVariable(((IdentifierSymbol) nextSymbol).getText());
60:                 nextSymbol = buffer.peek();
61:•                if (nextSymbol instanceof EqualsTildeSymbol) {
62:                         tFP.setState(new ConditionState1(this.tempExt));
63:                         buffer.remove();
64:•                } else if (nextSymbol instanceof BracketCloseSymbol) {
65:                         this.tempExt.setReady(true);
66:                         tFP.setState(new AdditionalTypeExpressionState(this.tempExt));
67:                         buffer.remove();
68:                 } else {
69:                         throw new ParserException("no valid symbol: "
70:                                         + buffer.peek().getClass().getCanonicalName()
71:                                         + " expected AdditionalIdentifierSymbol");
72:                 }
73: 
74:         }
75: 
76:         /**
77:          * @return the variable
78:          */
79:         public AbstractSymbol getVariable() {
80:                 return this.variable;
81:         }
82: 
83: }