View Javadoc
1   /* 
2    * Licensed under the Apache License, Version 2.0 (the "License");
3    * you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at
5    *
6    * http://www.apache.org/licenses/LICENSE-2.0
7    *
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS,
10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   * See the License for the specific language governing permissions and
12   * limitations under the License.
13   *
14   */
15  package org.esigate.parser;
16  
17  /**
18   * An element type. There must be one Element type for each type of tags the parser has to look for in the pages
19   * 
20   * @author Francois-Xavier Bonnet
21   * 
22   */
23  public interface ElementType {
24      /**
25       * Detects an opening tag for this element type.
26       * 
27       * @param tag
28       *            The String to check
29       * @return Returns true if the String is an opening tag
30       */
31      boolean isStartTag(String tag);
32  
33      /**
34       * Detects if a tag is self closed or does not require a matching end tag. Ex: <br />
35       * 
36       * @param tag
37       *            The String to check
38       * @return Returns true if the String is a self closing tag
39       */
40      boolean isSelfClosing(String tag);
41  
42      /**
43       * Detects a closing tag for this element type.
44       * 
45       * @param tag
46       *            The String to check
47       * @return Returns true if the String is a closing tag
48       */
49      boolean isEndTag(String tag);
50  
51      /**
52       * @return A new instance of the corresponding element class
53       */
54      Element newInstance();
55  }