Skip to content

Package: FormatVersionState

FormatVersionState

nameinstructionbranchcomplexitylinemethod
FormatVersionState(PackageDescriptionFileParser)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
action(RouterSoftware, PackageDescriptionFileSymbol)
M: 0 C: 61
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 15
100%
M: 0 C: 1
100%

Coverage

1: package parser.states.packagestates;
2:
3: import model.RouterSoftware;
4: import parser.PackageDescriptionFileParser;
5: import parser.ParserConstants;
6: import parser.ParserException;
7: import symbols.PackageDescriptionFileSymbol;
8: import basic.PrinterConstants;
9:
10: /**
11: * The class represents the FormatVersionState.
12: *
13: * @author HFW410
14: *
15: */
16: public class FormatVersionState extends AbstractPackageParserState {
17:         /**
18:          * constructor.
19:          *
20:          * @param parser
21:          * for the PackageDescriptionFile.
22:          */
23:         public FormatVersionState(final PackageDescriptionFileParser parser) {
24:                 super(parser);
25:         }
26:
27:         @Override
28:         public AbstractPackageParserState action(final RouterSoftware rs,
29:                         final PackageDescriptionFileSymbol symbol) throws ParserException,
30:                         InterruptedException {
31:•                if (symbol.isValueSymbol()) {
32:                         try {
33:                                 this.getMyParser().setFormatVersion(
34:                                                 Integer.parseInt(symbol.toValueSymbol().getContent()));
35:                         } catch (final NumberFormatException e) {
36:                                 throw new ParserException(ParserConstants.FORMAT_VERSION_EXCEPTION, e);
37:                         }
38:                         this.getMyParser().skip();
39:                         final PackageDescriptionFileSymbol next = this.getMyParser().peekSymbol();
40:•                        if (next.isPathSymbol()) {
41:•                                if (next.toPathSymbol().getContent().equals(PrinterConstants.MINUS)) {
42:                                         this.getMyParser().skip();
43:                                         return new PackageDescriptionInitialState(this.getMyParser());
44:                                 } else {
45:                                         throw new ParserException(ParserConstants.FORMAT_VERSION_EXCEPTION);
46:                                 }
47:                         } else {
48:                                 throw new ParserException(ParserConstants.PATH_EXCEPTION);
49:                         }
50:
51:                 } else {
52:                         throw new ParserException(ParserConstants.VALUE_FEHLER);
53:                 }
54:
55:         }
56: }