001 // Copyright 2004, 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.parse;
016
017 import org.apache.hivemind.Resource;
018
019 /**
020 * Service interface for the <code>tapestry.TemplateParser</code> service.
021 * Note that this requires a threaded service model.
022 *
023 * <p>
024 * Note: had to use the 'I' prefix, so that {@link org.apache.tapestry.parse.TemplateParser}
025 * could keep its name. Otherwise, it makes Spindle support really, really ugly.
026 *
027 * @author Howard Lewis Ship
028 * @since 4.0
029 */
030 public interface ITemplateParser
031 {
032 /**
033 * Parses the template data into an array of {@link TemplateToken}s.
034 *
035 * <p>The parser is <i>decidedly</i> not threadsafe, so care should be taken
036 * that only a single thread accesses it.
037 *
038 * @param templateData the HTML template to parse. Some tokens will hold
039 * a reference to this array.
040 * @param delegate object that "knows" about defined components
041 * @param resourceLocation a description of where the template originated from,
042 * used with error messages.
043 *
044 **/
045 public abstract TemplateToken[] parse(
046 char[] templateData,
047 ITemplateParserDelegate delegate,
048 Resource resourceLocation)
049 throws TemplateParseException;
050 }