001    package echopoint.template;
002    
003    /* 
004     * This file is part of the Echo Point Project.  This project is a collection
005     * of Components that have extended the Echo Web Application Framework.
006     *
007     * Version: MPL 1.1/GPL 2.0/LGPL 2.1
008     *
009     * The contents of this file are subject to the Mozilla Public License Version
010     * 1.1 (the "License"); you may not use this file except in compliance with
011     * the License. You may obtain a copy of the License at
012     * http://www.mozilla.org/MPL/
013     *
014     * Software distributed under the License is distributed on an "AS IS" basis,
015     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
016     * for the specific language governing rights and limitations under the
017     * License.
018     *
019     * Alternatively, the contents of this file may be used under the terms of
020     * either the GNU General Public License Version 2 or later (the "GPL"), or
021     * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
022     * in which case the provisions of the GPL or the LGPL are applicable instead
023     * of those above. If you wish to allow use of your version of this file only
024     * under the terms of either the GPL or the LGPL, and not to allow others to
025     * use your version of this file under the terms of the MPL, indicate your
026     * decision by deleting the provisions above and replace them with the notice
027     * and other provisions required by the GPL or the LGPL. If you do not delete
028     * the provisions above, a recipient may use your version of this file under
029     * the terms of any one of the MPL, the GPL or the LGPL.
030     */
031    
032    import java.io.Serializable;
033    
034    /**
035     * A base class for <code>TemplateDataSource</code> implementations.
036     * <p>
037     * Its uses a SimpleTemplateCachingHints object as its TemplateCachingHints
038     * implementation.
039     */
040    public abstract class AbstractTemplateDataSource implements TemplateDataSource, Serializable {
041            /** the default encoding is iso-8859-1 */
042            public static String DEFAULT_ENCODING = "ISO-8859-1";
043    
044            /** the default encoding is text/xhtml */
045            public static String DEFAULT_CONTENT_TYPE = "text/xhtml";
046    
047            private String encoding = DEFAULT_ENCODING;
048    
049            private TemplateCachingHints cachingHints;
050    
051            private String contentType = DEFAULT_CONTENT_TYPE;
052    
053            private TemplateCompilerHints compilerHints = null;
054    
055            /**
056             * AbstractTemplateDataSource constructor with default encoding.
057             */
058            public AbstractTemplateDataSource() {
059                    this(DEFAULT_ENCODING);
060            }
061    
062            /**
063             * AbstractTemplateDataSource constructor with encoding.
064             */
065            public AbstractTemplateDataSource(String encoding) {
066                    super();
067                    this.cachingHints = new SimpleTemplateCachingHints();
068                    this.encoding = encoding;
069            }
070    
071            /**
072             * @see echopoint.template.TemplateDataSource#getCharacterEncoding()
073             */
074            public java.lang.String getCharacterEncoding() {
075                    return encoding;
076            }
077    
078            /**
079             * Sets the character encoding to be used with this TemplateDataSource
080             * 
081             * @param newEncoding -
082             *            the new encoding to use
083             * 
084             * @see TemplateDataSource#getCharacterEncoding()
085             */
086            public void setCharacterEncoding(String newEncoding) {
087                    encoding = newEncoding;
088            }
089    
090            /**
091             * @see echopoint.template.TemplateDataSource#getCachingHints()
092             */
093            public TemplateCachingHints getCachingHints() {
094                    return cachingHints;
095            }
096    
097            /**
098             * Sets the caching hints to use for this template data source
099             * 
100             * @param newValue -
101             *            the new hints
102             */
103            public void setCachingHints(TemplateCachingHints newValue) {
104                    this.cachingHints = newValue;
105            }
106    
107            /**
108             * @see echopoint.template.TemplateDataSource#getContentType()
109             */
110            public String getContentType() {
111                    return contentType;
112            }
113    
114            /**
115             * Sets the content type of the template data
116             * 
117             * @param contentType
118             *            The contentType to set.
119             */
120            public void setContentType(String contentType) {
121                    this.contentType = contentType;
122            }
123    
124            /**
125             * @see echopoint.template.TemplateDataSource#getCompilerHints()
126             */
127            public TemplateCompilerHints getCompilerHints() {
128                    return compilerHints;
129            }
130    
131            /**
132             * Sets the <code>TemplateCompilerHints</code> to use for this
133             * <code>TemplateDataSource</code>.
134             * 
135             * @param compilerHints -
136             *            the <code>TemplateCompilerHints</code> to use
137             */
138            public void setCompilerHints(TemplateCompilerHints compilerHints) {
139                    this.compilerHints = compilerHints;
140            }
141    }