001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.rewriter.test.util;
006:
007: import com.sun.portal.rewriter.rom.InvalidXMLException;
008: import com.sun.portal.rewriter.rom.RuleSet;
009: import com.sun.portal.rewriter.rom.RuleSetManager;
010:
011: public class OldCreateRuleSet {
012: public static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
013: + "<!DOCTYPE RuleSet SYSTEM \"jar://rewriter.jar/resources/RuleSet.dtd\">\n";
014:
015: private static final String end = "</RuleSet>";
016:
017: private static String getStart() {
018: return XML_HEADER + "<RuleSet id=\"test_ruleset"
019: + Math.round(Math.random() * 100000) + "\">";
020: }//getStart()
021:
022: public static RuleSet withJSVariableRules(String aXMLString)
023: throws InvalidXMLException {
024: String xml = getStart() + " <JSRules>" + aXMLString
025: + "</JSRules>" + end;
026: return RuleSetManager.create(xml);
027: }//withJSVariableRules()
028:
029: public static RuleSet withJSFunctionRules(String aXMLString)
030: throws InvalidXMLException {
031: String xml = getStart() + "<JSRules>" + aXMLString
032: + "</JSRules>" + end;
033: return RuleSetManager.create(xml);
034: }//withJSFunctionRules()
035:
036: public static RuleSet withHTMLAttributeRules(String aXMLString)
037: throws InvalidXMLException {
038: String xml = getStart() + "<HTMLRules>" + aXMLString
039: + "</HTMLRules>" + end;
040: return RuleSetManager.create(xml);
041: }//withHTMLAttributeRules()
042:
043: public static RuleSet withXMLAttributeRules(String aXMLString)
044: throws InvalidXMLException {
045: String xml = getStart() + "<XMLRules>" + aXMLString
046: + "</XMLRules>" + end;
047: return RuleSetManager.create(xml);
048: }//withXMLAttributeRules()
049:
050: public static RuleSet withXMLTagTextRules(String aXMLString)
051: throws InvalidXMLException {
052: String xml = getStart() + "<XMLRules>" + aXMLString
053: + "</XMLRules>" + end;
054: return RuleSetManager.create(xml);
055: }//withHTMLAttributeRules()
056:
057: public static RuleSet withXMLAttTagTextRules(String aAttRules,
058: String aTagTextRules) throws InvalidXMLException {
059: String xml = getStart() + "<XMLRules>" + aAttRules
060: + aTagTextRules + "</XMLRules>" + end;
061: return RuleSetManager.create(xml);
062: }//withHTMLAttributeRules()
063:
064: public static RuleSet emptyRuleSet() throws InvalidXMLException {
065: String xml = getStart() + end;
066: return RuleSetManager.create(xml);
067: }//emptyRuleSet()
068:
069: public static RuleSet withHTMLAttJSFunRules(String htmlAtt,
070: String jsFun) throws InvalidXMLException {
071: String xml = getStart() + "<HTMLRules>" + htmlAtt
072: + "</HTMLRules>" + "<JSRules>" + jsFun + "</JSRules>"
073: + end;
074: return RuleSetManager.create(xml);
075: }//withHTMLAttJSFunRules()
076:
077: public static RuleSet withHTMLJSTokenJSVarJSFunRules(
078: String htmlJSToken, String jsVar, String jsFun)
079: throws InvalidXMLException {
080: String xml = getStart() + "<HTMLRules>" + htmlJSToken
081: + "</HTMLRules>" + "<JSRules>" + jsVar + jsFun
082: + "</JSRules>" + end;
083: return RuleSetManager.create(xml);
084: }//withHTMLJSTokenJSVarJSFunRules()
085:
086: public static RuleSet withHTMLAttJSTokenJSVarJSFunRules(
087: String htmlAtt, String htmlJSToken, String jsVar,
088: String jsFun) throws InvalidXMLException {
089: String xml = getStart() + "<HTMLRules>" + htmlJSToken + htmlAtt
090: + "</HTMLRules>" + "<JSRules>" + jsVar + jsFun
091: + "</JSRules>" + end;
092: return RuleSetManager.create(xml);
093: }//withHTMLJSTokenJSVarJSFunRules()
094:
095: public static RuleSet withHTMLAttJSVarJSFunRules(String htmlAtt,
096: String jsVar, String jsFun) throws InvalidXMLException {
097: String xml = getStart() + "<HTMLRules>" + htmlAtt
098: + "</HTMLRules>" + "<JSRules>" + jsVar + jsFun
099: + "</JSRules>" + end;
100: return RuleSetManager.create(xml);
101: }//withHTMLAttJSVarJSFunRules()
102:
103: public static RuleSet withHTMLAttHTMLJSTokenJSVar(String htmlAtt,
104: String htmlJSToken, String jsVar)
105: throws InvalidXMLException {
106: String xml = getStart() + "<HTMLRules>" + htmlAtt + htmlJSToken
107: + "</HTMLRules>" + "<JSRules>" + jsVar + "</JSRules>"
108: + end;
109: return RuleSetManager.create(xml);
110: }//withHTMLAttJSVarJSFunRules()
111:
112: public static RuleSet withHTMLAppletAttRules(
113: String htmlAppletRules, String htmlAttRules)
114: throws InvalidXMLException {
115: String xml = getStart() + "<HTMLRules>" + htmlAppletRules
116: + htmlAttRules + "</HTMLRules>" + end;
117: return RuleSetManager.create(xml);
118: }//withHTMLAppletAttRules()
119:
120: public static RuleSet withHTMLAppletAttJSFunRules(
121: String htmlAppletRules, String htmlAttRules, String jsFun)
122: throws InvalidXMLException {
123: String xml = getStart() + "<HTMLRules>" + htmlAppletRules
124: + htmlAttRules + "</HTMLRules>" + "<JSRules>" + jsFun
125: + "</JSRules>" + end;
126: return RuleSetManager.create(xml);
127: }//withHTMLAppletAttRules()
128:
129: public static RuleSet withHTMLAppletAttJSVarJSFunRules(
130: String htmlAppletRules, String htmlAttRules, String jsVar,
131: String jsFun) throws InvalidXMLException {
132: String xml = getStart() + "<HTMLRules>" + htmlAppletRules
133: + htmlAttRules + "</HTMLRules>" + "<JSRules>" + jsVar
134: + jsFun + "</JSRules>" + end;
135: return RuleSetManager.create(xml);
136: }//withHTMLAppletAttJSVarJSFunRules()
137:
138: public static RuleSet withHTMLFormAttRules(String htmlFormRules,
139: String htmlAttRules) throws InvalidXMLException {
140: String xml = getStart() + "<HTMLRules>" + htmlFormRules
141: + htmlAttRules + "</HTMLRules>" + end;
142: return RuleSetManager.create(xml);
143: }//withHTMLFormAttRules()
144:
145: public static RuleSet withHTMLFormJSRules(String htmlFormRules,
146: String jsRules) throws InvalidXMLException {
147: String xml = getStart() + "<HTMLRules>" + htmlFormRules
148: + "</HTMLRules>" + "<JSRules>" + jsRules + "</JSRules>"
149: + end;
150: return RuleSetManager.create(xml);
151: }//withHTMLFormAttRules()
152: }
|