01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.rewriter.rom.js;
06:
07: import com.sun.portal.rewriter.engines.LanguageConstants;
08: import com.sun.portal.rewriter.rom.DataRuleCollection;
09: import com.sun.portal.rewriter.rom.InvalidXMLException;
10: import com.sun.portal.rewriter.rom.RecursiveRuleCollection;
11: import com.sun.portal.rewriter.rom.Rule;
12: import com.sun.portal.rewriter.rom.RuleCollection;
13: import com.sun.portal.rewriter.rom.RuleSetHelper;
14: import com.sun.portal.rewriter.util.Debug;
15: import com.sun.portal.rewriter.util.xml.Node;
16:
17: /**
18: * Represents JSRules tag of RuleSet
19: *
20: * @version 1.0 12/15/2001
21: * @author Raja Nagendra Kumar, Nagendra.Raja@sun.com
22: */
23: public final class JSRules extends RecursiveRuleCollection {
24: public JSRules(final RuleCollection[] aCollection)
25: throws InvalidXMLException {
26: super (JSRULES, aCollection);
27: setMIMEType(LanguageConstants.JS_MIME);
28: }//constructor
29:
30: public JSRules(final Node aNode) throws InvalidXMLException {
31: this ((RuleCollection[]) null);
32:
33: DataRuleCollection tempCollection = DataRuleCollection.create(
34: VariableRule.class, aNode.getChildren(VARIABLE));
35: addRuleCollection(tempCollection);
36:
37: tempCollection = DataRuleCollection.create(FunctionRule.class,
38: aNode.getChildren(FUNCTION));
39: addRuleCollection(tempCollection);
40: }//constructor
41:
42: public DataRuleCollection getVariables() {
43: return (DataRuleCollection) getRuleCollection(VARIABLE);
44: }//getVariables()
45:
46: public DataRuleCollection getFunctions() {
47: return (DataRuleCollection) getRuleCollection(FUNCTION);
48: }//getFunctions()
49:
50: public DataRuleCollection getVariables(final String aType) {
51: return RuleSetHelper.getByType(getVariables(), aType);
52: }//getVariables()
53:
54: private DataRuleCollection systemVariables;
55:
56: public DataRuleCollection getSystemVariables() {
57: if (systemVariables == null) {
58: systemVariables = getVariables(Rule.SYSTEM);
59: }
60:
61: return systemVariables;
62: }//getSystemVariables()
63:
64: private DataRuleCollection nonSystemVariables;
65:
66: public DataRuleCollection getNonSystemVariables() {
67: if (nonSystemVariables == null) {
68: nonSystemVariables = RuleSetHelper.getByType(
69: getVariables(), Rule.SYSTEM, true);
70: }
71:
72: return nonSystemVariables;
73: }//getNonSystemVariables()
74:
75: public DataRuleCollection getFunctions(final String aType) {
76: return RuleSetHelper.getByType(getFunctions(), aType);
77: }//getFunctions()
78:
79: public static void main(String[] args) {
80: String xmlString = com.sun.portal.rewriter.test.util.SampleRuleObjects.defaultJSRules
81: .toXML();
82: Debug.println(xmlString);
83: }//main()
84: }//class JSRules
|