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.engines;
06:
07: public class PageContent {
08: private final String origContent;
09: private final int length;
10:
11: private boolean exceptionFlag = false;
12: private String lowerOrigContent;
13: private StringBuffer resultBuffer;
14:
15: public PageContent(final String aOrigContent) {
16: origContent = aOrigContent;
17: length = origContent.length();
18: }//constructor
19:
20: public StringBuffer getResultBuffer() {
21: if (resultBuffer == null) {
22: resultBuffer = new StringBuffer(Math.round(origContent
23: .length() * 1.3f));
24: }
25:
26: return resultBuffer;
27: }//getResultBuffer()
28:
29: public String toLowerCase() {
30: if (lowerOrigContent == null) {
31: lowerOrigContent = origContent.toLowerCase();
32: }
33: return lowerOrigContent;
34: }//toLowerCase()
35:
36: public void enableExceptionFlag() {
37: exceptionFlag = true;
38: }//enableExceptionFlag()
39:
40: public String getOriginalContent() {
41: return origContent;
42: }//getOriginalContent()
43:
44: public String getResult() {
45: if (exceptionFlag || resultBuffer == null) {
46: return origContent;
47: }
48:
49: final String result = resultBuffer.toString();
50:
51: if (result.length() == 0) {
52: return origContent;
53: } else {
54: return result;
55: }
56: }//getResult()
57:
58: public final int length() {
59: return length;
60: }//length()
61:
62: public final char charAt(final int index) {
63: return origContent.charAt(index);
64: }//charAt()
65:
66: public final String substring(int beginIndex) {
67: return substring(beginIndex, length);
68: }//substring()
69:
70: public final String substring(int beginIndex, int endIndex) {
71: return origContent.substring(beginIndex, endIndex);
72: }//substring()
73:
74: public final String toString() {
75: return origContent;
76: }//toString()
77:
78: }//class PageContent
|