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.rom.Data;
08: import com.sun.portal.rewriter.rom.Rule;
09: import com.sun.portal.rewriter.rom.TypedData;
10: import com.sun.portal.rewriter.util.Constants;
11: import com.sun.portal.rewriter.util.StringHelper;
12:
13: public abstract class JSData extends Data implements TypedData {
14: public static final int TRANSLATE_NONE = 0;
15: public static final int TRANSLATE_URL = 1;
16:
17: public static final int TRANSLATE_EXPRESSION = 2;
18: public static final int TRANSLATE_EXPRESSION_LP = TRANSLATE_EXPRESSION;
19: public static final int TRANSLATE_EXPRESSION_RP = 3;
20:
21: public static final int TRANSLATE_DHTML = 4;
22:
23: public static final int TRANSLATE_DJS = 5;
24: public static final int TRANSLATE_DJS_LP = TRANSLATE_DJS;
25: public static final int TRANSLATE_DJS_RP = 6;
26:
27: public static final int TRANSLATE_SYSTEM = 7;
28: public static final int TRANSLATE_SYSTEM_LP = TRANSLATE_SYSTEM;
29: public static final int TRANSLATE_SYSTEM_RP = 8;
30:
31: private String name;
32: private String type;
33: private int typeCode;
34:
35: protected JSData(final String aCollectionID, final String aName,
36: final String aType, final String aSource) {
37: super (aCollectionID, aSource);
38: name = StringHelper.normalize(aName);
39: type = StringHelper.normalize(aType, Rule.EXPRESSION);
40: assignTypeCode();
41: }//constructor
42:
43: public final String getName() {
44: return name;
45: }//getName()
46:
47: protected final void setName(String aName) {
48: name = aName;
49: }//setName()
50:
51: public final String getType() {
52: return type;
53: }//getType()
54:
55: public final int getTypeCode() {
56: return typeCode;
57: }//getTypeCode()
58:
59: protected final void setTypeCode(int aTypeCode) {
60: typeCode = aTypeCode;
61: }//getTypeCode()
62:
63: protected final void setType(final String aType) {
64: type = aType;
65: }//setTypeCode()
66:
67: private void assignTypeCode() {
68: if (getType().equals(Rule.URL)) {
69: typeCode = TRANSLATE_URL;
70: } else if (getType().equals(Rule.EXPRESSION)) {
71: typeCode = TRANSLATE_EXPRESSION;
72: } else if (getType().equals(Rule.DHTML)) {
73: typeCode = TRANSLATE_DHTML;
74: } else if (getType().equals(Rule.DJS)) {
75: typeCode = TRANSLATE_DJS;
76: } else if (getType().equals(Rule.SYSTEM)) {
77: typeCode = TRANSLATE_SYSTEM;
78: } else {
79: typeCode = TRANSLATE_NONE;
80: }
81: }//setTypeCode()
82:
83: public void writeCustomAttributes(final StringBuffer aBuffer) {
84: if (!getType().equals(Rule.EXPRESSION)) {
85: aBuffer.append(Rule.TYPE).append(Constants.EQUALS).append(
86: Constants.DOUBLE_QUOTES).append(getType()).append(
87: Constants.DOUBLE_QUOTES).append(
88: Constants.SINGLE_SPACE);
89: }
90:
91: aBuffer.append(Rule.NAME).append(Constants.EQUALS).append(
92: Constants.DOUBLE_QUOTES).append(getName()).append(
93: Constants.DOUBLE_QUOTES);
94: }
95:
96: }//class JSDataRule
|