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;
06:
07: import com.sun.portal.rewriter.engines.LanguageConstants;
08: import com.sun.portal.rewriter.util.Constants;
09: import com.sun.portal.rewriter.util.StringHelper;
10:
11: public abstract class Data {
12: private static final String[] messages = { "Collection Type can't be ", //0
13: };
14:
15: private final String collectionID;
16: private String source;
17:
18: protected Data(final String aCollectionID, final String aSource) {
19: if (aCollectionID == null || aCollectionID.trim().length() == 0) {
20: throw new InvalidCollectionIDException(messages[0]
21: + aCollectionID);
22: }
23:
24: collectionID = aCollectionID;
25: source = StringHelper.normalize(aSource,
26: Constants.DEFAULT_REGULAR_EXPRESSION);
27: }//Constructor
28:
29: public final String getCollectionID() {
30: return collectionID;
31: }//getCollectionID()
32:
33: public String getSource() {
34: return source;
35: }//getSource()
36:
37: protected void setSource(String aSource) {
38: source = StringHelper.normalize(aSource);
39: }//setSource()
40:
41: public abstract void writeCustomAttributes(
42: final StringBuffer aStringBuff);
43:
44: public final String toXML() {
45: final StringBuffer sb = new StringBuffer();
46: sb.append(LanguageConstants.TAG_BEGIN).append(collectionID)
47: .append(Constants.SINGLE_SPACE);
48: writeCustomAttributes(sb);
49:
50: if (!getSource().equals(Constants.DEFAULT_REGULAR_EXPRESSION)) {
51: sb.append(Constants.SINGLE_SPACE).append(Rule.SOURCE)
52: .append(Constants.EQUALS).append(
53: Constants.DOUBLE_QUOTES)
54: .append(getSource())
55: .append(Constants.DOUBLE_QUOTES);
56: }
57:
58: sb.append(Constants.SINGLE_SPACE).append(
59: LanguageConstants.TAG_END).append(Constants.NEW_LINE);
60: return sb.toString();
61: }//toXML()
62:
63: public final String toString() {
64: return toXML();
65: }//toString()
66: }//class Data
|