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.html;
06:
07: import com.sun.portal.rewriter.rom.Data;
08: import com.sun.portal.rewriter.rom.DataRule;
09: import com.sun.portal.rewriter.util.Debug;
10: import com.sun.portal.rewriter.util.re.Pattern;
11: import com.sun.portal.rewriter.util.xml.Node;
12:
13: /**
14: * Representation of Applet tag of HTMLRules
15: *
16: * @version 1.0 12/15/2001
17: * @author Raja Nagendra Kumar, Nagendra.Raja@sun.com
18: */
19: public final class AppletRule extends DataRule {
20: private final Applet applet;
21: private final Pattern[] codeSpec;
22: private final Pattern[] paramSpec;
23: private final Pattern[] valuePatternSpec;
24:
25: public AppletRule(final Applet aApplet) {
26: super (aApplet);
27: applet = aApplet;
28: codeSpec = createAttributeSpec(applet.getCode());
29: paramSpec = createAttributeSpec(applet.getParam(), true);
30: valuePatternSpec = createValuePatternSpec(applet
31: .getValuePatterns());
32: }//constructor
33:
34: public AppletRule(final Node aNode) {
35: this (new Applet(aNode.getAttributeValue(CODE), aNode
36: .getAttributeValue(PARAM), aNode
37: .getAttributeValue(VALUE_PATTERNS), aNode
38: .getAttributeValue(SOURCE)));
39: }//constructor
40:
41: public Pattern[] getParsedPatterns() {
42: return valuePatternSpec;
43: }//getParsedValuePatterns()
44:
45: public boolean plugableMatch(final Data aMache) {
46: if (!(aMache instanceof Applet)) {
47: return false;
48: }
49:
50: Applet valueObject = (Applet) aMache;
51: if (match(codeSpec, valueObject.getCode())) {
52: if (match(paramSpec, valueObject.getParam())) {
53: return true;
54: }
55: }
56:
57: return false;
58: }//matchs()
59:
60: public boolean isValid() {
61: return doBasicValidation(new String[] { applet.getSource(),
62: applet.getCode(), applet.getParam() });
63: }//isValid()
64:
65: public static void main(String[] args) {
66: AppletRule[] applets = com.sun.portal.rewriter.test.util.SampleRuleObjects.defaultHTMLApplets;
67: for (int i = 0; i < applets.length; i++) {
68: Debug.println(applets[i].toXML());
69: }//for loop
70: }//main()
71: }//class Applet
|