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 * <p>
023 * Note: had to use the 'I' prefix, so that
024 * {@link org.apache.tapestry.parse.TemplateParser} could keep its name.
025 * 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 /**
034 * Parses the template data into an array of {@link TemplateToken}s.
035 * <p>
036 * The parser is <i>decidedly</i> not threadsafe, so care should be taken
037 * that only a single thread accesses it.
038 *
039 * @param templateData
040 * the HTML template to parse. Some tokens will hold a reference
041 * to this array.
042 * @param delegate
043 * object that "knows" about defined components
044 * @param resourceLocation
045 * a description of where the template originated from, used with
046 * error messages.
047 */
048 TemplateToken[] parse(char[] templateData,
049 ITemplateParserDelegate delegate, Resource resourceLocation)
050 throws TemplateParseException;
051 }