001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.rewriter.engines.markup;
006:
007: import com.sun.portal.rewriter.engines.LanguageConstants;
008: import com.sun.portal.rewriter.rom.Rule;
009: import com.sun.portal.rewriter.rom.common.Attribute;
010: import com.sun.portal.rewriter.rom.html.Applet;
011: import com.sun.portal.rewriter.rom.html.Form;
012: import com.sun.portal.rewriter.util.Constants;
013:
014: final class PageContext implements LanguageConstants {
015: private final StringBuffer pageBuffer;
016:
017: String formName = Constants.EMPTY_STRING;
018: String appletName = Constants.EMPTY_STRING;
019: String selectName = Constants.EMPTY_STRING;
020: String skip2Tag = Constants.EMPTY_STRING;
021:
022: PageContext(final StringBuffer aResultBuffer) {
023: pageBuffer = aResultBuffer;
024: }//constuctor
025:
026: StringBuffer getPageBuffer() {
027: return pageBuffer;
028: }//getBuffer()
029:
030: /**
031: * aTagName should always be in lowercase- set the value of Rewriter MIME and end tag name
032: */
033: void currentTag(final String aTagName) {
034: if (aTagName.equals(SCRIPT)) {
035: skip2Tag = SLASH_SCRIPT;
036: } else if (aTagName.equals(XML)) {
037: skip2Tag = SLASH_XML;
038: } else if (aTagName.equals(TEXTAREA)) {
039: skip2Tag = SLASH_TEXTAREA;
040: } else if (aTagName.equals(SPAN)) {
041: skip2Tag = SLASH_SPAN;
042: } else if (aTagName.equals(STYLE)) {
043: skip2Tag = SLASH_STYLE;
044: } else {
045: skip2Tag = Constants.EMPTY_STRING;
046: }
047:
048: if (aTagName.equals(FORM) || aTagName.equals(SLASH_FORM)) {
049: formName = Constants.EMPTY_STRING;
050: }
051:
052: if (aTagName.equals(APPLET) || aTagName.equals(SLASH_APPLET)
053: || aTagName.equals(OBJECT)
054: || aTagName.equals(SLASH_OBJECT)) {
055: appletName = Constants.EMPTY_STRING;
056: }
057:
058: if (aTagName.equals(SELECT) || aTagName.equals(SLASH_SELECT)) {
059: selectName = Constants.EMPTY_STRING;
060: }
061: }//currentTag()
062:
063: private Attribute attribute;
064:
065: Attribute getAttributeInstance() {
066: if (attribute == null) {
067: attribute = new Attribute("");
068: }
069:
070: return attribute;
071: }//getAttributeInstance()
072:
073: private Attribute jstoken;
074:
075: Attribute getJSTokenInstance() {
076: if (jstoken == null) {
077: jstoken = new Attribute(null, null, null, Rule.DJS, null);
078: }
079:
080: return jstoken;
081: }//getJSTokenInstance()
082:
083: private Applet applet;
084:
085: Applet getAppletInstance() {
086: if (applet == null) {
087: applet = new Applet("", "");
088: }
089:
090: return applet;
091: }//getAppletInstance()
092:
093: private Form form;
094:
095: Form getFormInstance() {
096: if (form == null) {
097: form = new Form("", "");
098: }
099:
100: return form;
101: }//getFormInstance()
102:
103: }//class PageContext
|