01: package org.drools.decisiontable;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.util.List;
20:
21: import org.drools.decisiontable.parser.DecisionTableParser;
22: import org.drools.decisiontable.parser.SheetListener;
23: import org.drools.decisiontable.parser.csv.CsvLineParser;
24: import org.drools.decisiontable.parser.csv.CsvParser;
25: import org.drools.decisiontable.parser.xls.ExcelParser;
26:
27: /**
28: * Provides valid input types for decision tables.
29: * (which also serve as parser factories).
30: *
31: * @author Michael Neale
32: */
33: public abstract class InputType {
34: public static final InputType XLS = new XlsInput();
35: public static final InputType CSV = new CsvInput();
36:
37: protected InputType() {
38:
39: }
40:
41: /**
42: * @param listener
43: * @return The appropriate Parser.
44: */
45: public abstract DecisionTableParser createParser(
46: SheetListener listener);
47:
48: public abstract DecisionTableParser createParser(List listeners);
49:
50: }
51:
52: class XlsInput extends InputType {
53:
54: public DecisionTableParser createParser(final SheetListener listener) {
55: return new ExcelParser(listener);
56: }
57:
58: public DecisionTableParser createParser(final List listeners) {
59: return new ExcelParser(listeners);
60: }
61:
62: }
63:
64: class CsvInput extends InputType {
65:
66: public DecisionTableParser createParser(final SheetListener listener) {
67: return new CsvParser(listener, new CsvLineParser());
68: }
69:
70: public DecisionTableParser createParser(final List listeners) {
71: return new CsvParser(listeners, new CsvLineParser());
72: }
73:
74: }
|