Package: PathState
PathState
| name | instruction | branch | complexity | line | method | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PathState(PackageDescriptionFileParser, TempPackageRule) | 
  | 
  | 
  | 
  | 
  | 
||||||||||||||||||||
| action(RouterSoftware, PackageDescriptionFileSymbol) | 
  | 
  | 
  | 
  | 
  | 
||||||||||||||||||||
Coverage
1: package parser.states.packagestates;
2: 
3: import model.RouterSoftware;
4: import model.packages.Path;
5: import parser.PackageDescriptionFileParser;
6: import parser.ParserConstants;
7: import parser.ParserException;
8: import parser.TempPackageRule;
9: import symbols.PackageDescriptionFileSymbol;
10: 
11: /**
12:  * This class represents the Path State of the PackageDescriptionfileparser.
13:  * 
14:  * @author HFW410
15:  * 
16:  */
17: public class PathState extends AbstractPackageParserState {
18:         /**
19:          * The temp PackageRule.
20:          */
21:         private final transient TempPackageRule tempPackageRule;
22: 
23:         /**
24:          * The constructor for the PathState.
25:          * 
26:          * @param parser
27:          *            for the DescriptionFileParser.
28:          * @param tempPackageRule
29:          *            the temp PackageRule.
30:          */
31:         public PathState(final PackageDescriptionFileParser parser,
32:                         final TempPackageRule tempPackageRule) {
33:                 super(parser);
34:                 this.tempPackageRule = tempPackageRule;
35:         }
36: 
37:         @Override
38:         public AbstractPackageParserState action(final RouterSoftware rs,
39:                         final PackageDescriptionFileSymbol symbol) throws InterruptedException,
40:                         ParserException {
41:•                if (symbol.isPathSymbol()) {
42:                         String content = symbol.toPathSymbol().getContent();
43:                         Boolean rootfs = true;
44:•                        if (content.startsWith(ParserConstants.ROOTFS_PRAEFIX_2)) {
45:                                 content = content.substring(ParserConstants.ROOTFS_PRAEFIX_2.length());
46:•                        } else if (content.startsWith(ParserConstants.ROOTFS_PRAEFIX_1)) {
47:                                 content = content.substring(ParserConstants.ROOTFS_PRAEFIX_1.length());
48:                         } else {
49:                                 rootfs = false;
50:                         }
51:                         this.tempPackageRule.setPath(new Path(rootfs, content));
52:                         this.getMyParser().skip();
53:                         return this
54:                                         .getMyParser()
55:                                         .peekSymbol()
56:                                         .accept(new PathStateSymbolVisitor(), this.getMyParser(),
57:                                                         this.tempPackageRule);
58:                 } else {
59:                         throw new ParserException(ParserConstants.PATH_FEHLER);
60:                 }
61: 
62:         }
63: }