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.xml;
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.RuleCollection;
12: import com.sun.portal.rewriter.rom.common.AttributeRule;
13: import com.sun.portal.rewriter.rom.common.TagTextRule;
14: import com.sun.portal.rewriter.util.Debug;
15: import com.sun.portal.rewriter.util.xml.Node;
16:
17: /**
18: * Java Object respresentation of XMLRules tag of RuleSet XML
19: *
20: * @version 1.0 12/15/2001
21: * @author Raja Nagendra Kumar, Nagendra.Raja@sun.com
22: */
23: public final class XMLRules extends RecursiveRuleCollection {
24: public XMLRules(final RuleCollection[] aCollection)
25: throws InvalidXMLException {
26: super (XMLRULES, aCollection);
27: setMIMEType(LanguageConstants.XML_MIME);
28: }//constructor
29:
30: public XMLRules(final Node aNode) throws InvalidXMLException {
31: this ((RuleCollection[]) null);
32: DataRuleCollection tempCollection = new DataRuleCollection(
33: ATTRIBUTE, AttributeRule.createAttributeRules(aNode
34: .getChildren(ATTRIBUTE), false));
35: addRuleCollection(tempCollection);
36:
37: tempCollection = new DataRuleCollection(TAGTEXT, TagTextRule
38: .createTagTextRules(aNode.getChildren(TAGTEXT), false));
39: addRuleCollection(tempCollection);
40: }//constructor
41:
42: public DataRuleCollection getTagTexts() {
43: return (DataRuleCollection) getRuleCollection(TAGTEXT);
44: }//getTagTexts()
45:
46: public DataRuleCollection getAttributes() {
47: return (DataRuleCollection) getRuleCollection(ATTRIBUTE);
48: }//getAttributes()
49:
50: public static void main(String[] args) {
51: String xmlString = com.sun.portal.rewriter.test.util.SampleRuleObjects.defaultXMLRules
52: .toXML();
53: Debug.println(xmlString);
54: }//main()
55: }//class XMLRules
|