01: package com.sun.portal.rewriter.services.ids;
02:
03: import com.sun.portal.rewriter.rom.DataRuleCollection;
04: import com.sun.portal.rewriter.rom.InvalidXMLException;
05: import com.sun.portal.rewriter.rom.RuleCollection;
06: import com.sun.portal.rewriter.rom.RuleSet;
07: import com.sun.portal.rewriter.rom.html.HTMLRules;
08: import com.sun.portal.rewriter.rom.js.JSRules;
09: import com.sun.portal.rewriter.rom.xml.XMLRules;
10: import com.sun.portal.rewriter.services.ids.test.MockIDSDataSource;
11: import com.sun.portal.rewriter.util.Debug;
12:
13: public final class IDSRuleSetBuilder {
14: public static RuleSet createRuleSet(final DataSource aDataSource)
15: throws InvalidXMLException {
16: final RuleCollection[] ruleCollections = new RuleCollection[3];
17: ruleCollections[0] = createHTMLRules(aDataSource);
18: ruleCollections[1] = createJSRules(aDataSource);
19: ruleCollections[2] = createXMLRules(aDataSource);
20:
21: return new RuleSet("ids_ruleset", ruleCollections);
22: }//createRuleSet()
23:
24: private static HTMLRules createHTMLRules(
25: final DataSource aDataSource) throws InvalidXMLException {
26: final DataRuleCollection[] htmlRuleCollections = new DataRuleCollection[3];
27: htmlRuleCollections[0] = IDSRuleCollectionBuilder
28: .getHTMLAppletRuleCollection(aDataSource);
29: htmlRuleCollections[1] = IDSRuleCollectionBuilder
30: .getHTMLFormRuleCollection(aDataSource);
31: htmlRuleCollections[2] = IDSRuleCollectionBuilder
32: .getHTMLAttributeRuleCollection(aDataSource);
33:
34: return new HTMLRules(htmlRuleCollections);
35: }//createHTMLRules()
36:
37: private static JSRules createJSRules(final DataSource aDataSource)
38: throws InvalidXMLException {
39: final DataRuleCollection[] jsRuleCollections = new DataRuleCollection[2];
40: jsRuleCollections[0] = IDSRuleCollectionBuilder
41: .getJSVariableRuleCollection(aDataSource);
42: jsRuleCollections[1] = IDSRuleCollectionBuilder
43: .getJSFunctionRuleCollection(aDataSource);
44: return new JSRules(jsRuleCollections);
45: }//createJSRules()
46:
47: private static XMLRules createXMLRules(final DataSource aDataSource)
48: throws InvalidXMLException {
49: final DataRuleCollection[] xmlRuleCollections = new DataRuleCollection[2];
50: xmlRuleCollections[0] = IDSRuleCollectionBuilder
51: .getXMLAttributeRuleCollection(aDataSource);
52: xmlRuleCollections[1] = IDSRuleCollectionBuilder
53: .getXMLTagTextRuleCollection(aDataSource);
54: return new XMLRules(xmlRuleCollections);
55: }//createJSRules()
56:
57: public static void main(final String[] args)
58: throws InvalidXMLException {
59: Debug.println(createRuleSet(new MockIDSDataSource()).toXML());
60: }//main()
61:
62: }//class IDSRuleSetBuilder
|