01: package org.drools.decisiontable.parser;
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.io.IOException;
20: import java.io.InputStream;
21: import java.util.ArrayList;
22: import java.util.HashMap;
23: import java.util.List;
24: import java.util.Map;
25:
26: import org.drools.decisiontable.parser.xls.ExcelParser;
27:
28: /**
29: * @author <a href="mailto:michael.neale@gmail.com"> Michael Neale</a>
30: *
31: */
32: public class RulesheetUtil {
33:
34: /**
35: * Utility method showing how to get a rule sheet listener from a stream.
36: */
37: public static RuleSheetListener getRuleSheetListener(
38: final InputStream stream) throws IOException {
39: final Map sheetListeners = new HashMap();
40: final List listeners = new ArrayList();
41: final RuleSheetListener listener = new DefaultRuleSheetListener();
42: listeners.add(listener);
43: sheetListeners.put(ExcelParser.DEFAULT_RULESHEET_NAME,
44: listeners);
45: final ExcelParser parser = new ExcelParser(sheetListeners);
46: parser.parseFile(stream);
47: stream.close();
48: return listener;
49: }
50: }
|