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