Skip to content

Package: OptionState

OptionState

nameinstructionbranchcomplexitylinemethod
OptionState(PackageDescriptionFileParser, TempPackageRule)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
action(RouterSoftware, PackageDescriptionFileSymbol)
M: 0 C: 65
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 13
100%
M: 0 C: 1
100%

Coverage

1: package parser.states.packagestates;
2:
3: import model.RouterSoftware;
4: import model.packages.Option;
5: import parser.PackageDescriptionFileParser;
6: import parser.ParserConstants;
7: import parser.ParserException;
8: import parser.TempPackageRule;
9: import scanner.ScannerConstants;
10: import symbols.PackageDescriptionFileSymbol;
11:
12: /**
13: * This class represents the OptionState for the PackageDescriptionfileParser.
14: *
15: * @author HFW410
16: *
17: */
18: public class OptionState extends AbstractPackageParserState {
19:         /**
20:          * The temp PackageRule.
21:          */
22:         private final transient TempPackageRule tempPackageRule;
23:
24:         /**
25:          * The constructor.
26:          *
27:          * @param parser
28:          * the DescriptionfileParser.
29:          * @param tempPackageRule
30:          * The temp package rule.
31:          */
32:         public OptionState(final PackageDescriptionFileParser parser,
33:                         final TempPackageRule tempPackageRule) {
34:                 super(parser);
35:                 this.tempPackageRule = tempPackageRule;
36:         }
37:
38:         @Override
39:         public AbstractPackageParserState action(final RouterSoftware rs,
40:                         final PackageDescriptionFileSymbol symbol) throws InterruptedException,
41:                         ParserException {
42:                 final String content = symbol.toOptionSymbol().getContent();
43:                 final Integer position = content.indexOf(ScannerConstants.EQUALSIGN);
44:•                if (position > 0) {
45:                         final String name = content.substring(0, position);
46:                         final String value = content.substring(position + 1, content.length());
47:                         this.tempPackageRule.addOptions(new Option(name, value));
48:                         this.getMyParser().skip();
49:                         return this
50:                                         .getMyParser()
51:                                         .peekSymbol()
52:                                         .accept(new OptionStateSymbolVisitor(), this.getMyParser(),
53:                                                         this.tempPackageRule);
54:                 } else {
55:                         throw new ParserException(ParserConstants.NO_EQUALSIGN
56:                                         + symbol.getPosition().toString());
57:                 }
58:         }
59: }