Skip to content

Package: ContentState

ContentState

nameinstructionbranchcomplexitylinemethod
ContentState(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: 0 C: 32
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 6
100%
M: 0 C: 1
100%
finish(Buffer, String)
M: 0 C: 38
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 14
100%
M: 0 C: 1
100%

Coverage

1: package scanner;
2:
3: import model.Position;
4: import symbols.AbstractSymbol;
5: import basic.Buffer;
6:
7: /**
8: * State for the Content in the PackageDescriptionFile.
9: *
10: * @author Lisa Leitloff
11: *
12: */
13: public class ContentState extends AbstractState {
14:         /**
15:          * represents the collected Signs.
16:          */
17:         private String collectedContent;
18:
19:         /**
20:          * creates the Pathstate for the PackageDesriptionFileScanner.
21:          *
22:          * @param myScanner
23:          * is the scanner, which owns the state.
24:          * @param beginningColumn
25:          * is the first column of the symbol.
26:          * @param beginningRow
27:          * is the first row of the symbol.
28:          */
29:         public ContentState(final Scanner myScanner, final Integer beginningColumn,
30:                         final Integer beginningRow) {
31:                 super(myScanner, beginningColumn, beginningRow);
32:                 this.collectedContent = ScannerConstants.EMPTYSTRING;
33:
34:         }
35:
36:         @SuppressWarnings("deprecation")
37:         @Override
38:         public AbstractState action(final Character character,
39:                         final Buffer<AbstractSymbol> currentResult, final String dataPath)
40:                         throws InterruptedException {
41:•                if (Character.isSpace(character) || character.equals(ScannerConstants.COMMENTSYMBOL)) {
42:                         this.finish(currentResult, dataPath);
43:
44:                         // // TODO Do something to start with an variable state again!!!
45:                         // if(this.collectedContent.equalsIgnoreCase("weak")){
46:                         // return this.getMyScanner().get
47:                         // }
48:
49:                         return this.getMyScanner().getSelectionState();
50:                 } else {
51:                         this.collectedContent = this.collectedContent + character;
52:                         this.getMyScanner().skip();
53:                         return this;
54:                 }
55:         }
56:
57:         @Override
58:         protected void finish(final Buffer<AbstractSymbol> currentResult, final String dataPath)
59:                         throws InterruptedException {
60:
61:                 currentResult
62:                                 .put(this
63:                                                 .getMyScanner()
64:                                                 .toPackageDescriptionFileScanner()
65:                                                 .getDescriptionBlock()
66:                                                 .createSymbol(
67:                                                                 this.collectedContent,
68:                                                                 new Position(this.getBeginningRow(), this.getBeginningColumn(),
69:                                                                                 dataPath)));
70:
71:                 DescriptionBlock nextBlock =
72:                                 this.getMyScanner().toPackageDescriptionFileScanner().getDescriptionBlock()
73:                                                 .next();
74:•                if (this.collectedContent.equalsIgnoreCase("weak")) {
75:                         nextBlock = new VariableBlock();
76:                 }
77:
78:                 this.getMyScanner().toPackageDescriptionFileScanner().setDescriptionBlock(nextBlock);
79:         }
80: }