Skip to contentMethod: setDescriptionBlock(DescriptionBlock)
      1: package scanner;
2: 
3: import java.io.IOException;
4: import java.io.InputStream;
5: 
6: import symbols.AbstractSymbol;
7: import basic.Buffer;
8: 
9: /**
10:  * scanner for package description files.
11:  * 
12:  * @author Lisa Leitloff
13:  * 
14:  */
15: public final class PackageDescriptionFileScanner extends Scanner {
16:         /**
17:          * represents the Blocks in the Descriptionfile.
18:          */
19:         private DescriptionBlock descriptionBlock;
20: 
21:         /**
22:          * create a PackageDescriptionFileScanner and sets the PackageDescriptionSelectionState as
23:          * initial state.
24:          * 
25:          * @param buffer
26:          *            a buffer for the created Symbols
27:          * 
28:          */
29:         private PackageDescriptionFileScanner(final Buffer<AbstractSymbol> buffer) {
30:                 super(buffer);
31:                 this.descriptionBlock = new VariableBlock();
32:         }
33: 
34:         /**
35:          * creates a scanner and starts him.
36:          * 
37:          * @param input
38:          *            is the input stream.
39:          * @param dataPath
40:          *            is the path of the file.
41:          * @param buffer
42:          *            if the buffer for the symbols.
43:          * @throws IOException
44:          *             from the Input Stream.
45:          * @throws InterruptedException
46:          *             from the buffer.
47:          * @throws ScannerException
48:          *             if there is any problem during the scan.
49:          */
50:         public static void toSymbolSequence(final InputStream input, final String dataPath,
51:                         final Buffer<AbstractSymbol> buffer) throws ScannerException, InterruptedException,
52:                         IOException {
53:                 final PackageDescriptionFileScanner scanner = new PackageDescriptionFileScanner(buffer);
54:                 toSymbolSequence(input, dataPath, scanner);
55:         }
56: 
57:         @Override
58:         protected AbstractState getSelectionState() {
59:                 return new PackageDescriptionInitialState(this, this.getColumnCounter(),
60:                                 this.getRowCounter());
61:         }
62: 
63:         @Override
64:         protected AbstractState
65:                         getRestState(final Integer beginningRow, final Integer beginningColumn) {
66:                 return null;
67:         }
68: 
69:         /**
70:          * @return the descriptionBlock
71:          */
72:         protected DescriptionBlock getDescriptionBlock() {
73:                 return this.descriptionBlock;
74:         }
75: 
76:         /**
77:          * @param descriptionBlock
78:          *            the descriptionBlock to set
79:          */
80:         protected void setDescriptionBlock(final DescriptionBlock descriptionBlock) {
81:                 this.descriptionBlock = descriptionBlock;
82:         }
83: 
84:         /**
85:          * @return the PackageDescriptionFileScanner.
86:          */
87:         @Override
88:         protected PackageDescriptionFileScanner toPackageDescriptionFileScanner() {
89:                 return this;
90:         }
91: 
92:         @Override
93:         protected void handleRowEnd() {
94:                 super.handleRowEnd();
95:                 this.setDescriptionBlock(new VariableBlock());
96:         }
97: 
98:         @Override
99:         protected Boolean isPackageDescriptionFileScanner() {
100:                 return Boolean.TRUE;
101:         }
102: }