001: /*
002: * Copyright (C) 2004 TiongHiang Lee
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: * Email: thlee@onemindsoft.org
019: */
020:
021: package org.onemind.jxp;
022:
023: import org.onemind.jxp.parser.AstJxpDocument;
024:
025: /**
026: * Represent an JXPPage. It has a name and hold reference to the AST structure
027: * @author TiongHiang Lee (thlee@onemindsoft.org)
028: *
029: */
030: public abstract class JxpPage {
031:
032: /** the source * */
033: private JxpPageSource _source;
034:
035: /** the name * */
036: private String _name;
037:
038: /** the document * */
039: private AstJxpDocument _doc;
040:
041: /** the error message * */
042: private JxpPageParseException _pageParseException;
043:
044: /** the encoding **/
045: private String _encoding;
046:
047: /**
048: * Constructor
049: * @param source the source
050: * @param name the name
051: */
052: public JxpPage(JxpPageSource source, String name, String encoding) {
053: _source = source;
054: _name = name;
055: _encoding = encoding;
056: }
057:
058: /**
059: * Get the name
060: * @return the name
061: */
062: public final String getName() {
063: return _name;
064: }
065:
066: /**
067: * Get the JxpDocument tree structure
068: * @return the document tree structure
069: * @throws JxpPageSourceException if there's problem creating the document tree
070: */
071: public final AstJxpDocument getJxpDocument()
072: throws JxpPageSourceException {
073: return _source.getJxpDocument(this );
074: }
075:
076: /**
077: * Get the source
078: * @return the source
079: */
080: public final JxpPageSource getSource() {
081: return _source;
082: }
083:
084: /**
085: * Return the doc
086: * @return the doc.
087: */
088: public final AstJxpDocument getDocument() {
089: return _doc;
090: }
091:
092: /**
093: * Set the doc
094: * @param doc The doc to set.
095: */
096: public final void setDocument(AstJxpDocument doc) {
097: _doc = doc;
098: }
099:
100: /**
101: * @param s
102: * @return
103: */
104: public abstract Object declareStaticVariable(String s, Object value);
105:
106: /**
107: * @param s
108: * @return
109: */
110: public abstract boolean hasStaticVariable(String s);
111:
112: /**
113: * @param s
114: * @return
115: */
116: public abstract Object getStaticVariable(String s);
117:
118: /**
119: * @param name
120: * @param value
121: */
122: public abstract Object assignStaticVariable(String name,
123: Object value);
124:
125: /**
126: * Return the hasParseError
127: * @return the hasParseError.
128: */
129: public final boolean hasParseError() {
130: return _pageParseException != null;
131: }
132:
133: /**
134: * Set the pageParseException
135: * @param pageParseException The pageParseException to set.
136: */
137: public final void setParseException(
138: JxpPageParseException pageParseException) {
139: _pageParseException = pageParseException;
140: }
141:
142: /**
143: * Return the pageParseException
144: * @return the pageParseException.
145: */
146: public final JxpPageParseException getParseException() {
147: return _pageParseException;
148: }
149:
150: /**
151: * Return the encoding
152: * @return the encoding.
153: */
154: public final String getEncoding() {
155: return _encoding;
156: }
157:
158: /**
159: * Set the encoding
160: * @param encoding The encoding to set.
161: */
162: public final void setEncoding(String encoding) {
163: _encoding = encoding;
164: }
165:
166: }
|