/[aagtl_public1]/src/net/htmlparser/jericho/MasonTagTypes.java
aagtl

Contents of /src/net/htmlparser/jericho/MasonTagTypes.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Sun Aug 5 13:48:36 2012 UTC (11 years, 8 months ago) by zoffadmin
File size: 11669 byte(s)
initial import of aagtl source code
1 // Jericho HTML Parser - Java based library for analysing and manipulating HTML
2 // Version 3.2
3 // Copyright (C) 2004-2009 Martin Jericho
4 // http://jericho.htmlparser.net/
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of either one of the following licences:
8 //
9 // 1. The Eclipse Public License (EPL) version 1.0,
10 // included in this distribution in the file licence-epl-1.0.html
11 // or available at http://www.eclipse.org/legal/epl-v10.html
12 //
13 // 2. The GNU Lesser General Public License (LGPL) version 2.1 or later,
14 // included in this distribution in the file licence-lgpl-2.1.txt
15 // or available at http://www.gnu.org/licenses/lgpl.txt
16 //
17 // This library is distributed on an "AS IS" basis,
18 // WITHOUT WARRANTY OF ANY KIND, either express or implied.
19 // See the individual licence texts for more details.
20
21 package net.htmlparser.jericho;
22
23 /**
24 * Contains {@linkplain TagType tag types} related to the <a target="_blank" href="http://www.masonhq.com/">Mason</a> server platform.
25 * <p>
26 * There is no specific tag type defined for the
27 * <a target="_blank" href="http://www.masonbook.com/book/chapter-2.mhtml#CHP-2-SECT-3.1">Mason substitution tag</a>
28 * as it is recognised using the {@linkplain StartTagType#SERVER_COMMON common server tag type}.
29 * <p>
30 * The tag types defined in this class are not {@linkplain TagType#register() registered} by default.
31 * The {@link #register()} method is provided as a convenient way to register them all at once.
32 */
33 public final class MasonTagTypes {
34
35 /**
36 * The tag type given to a
37 * <a target="_blank" href="http://www.masonbook.com/book/chapter-2.mhtml#CHP-2-SECT-3.3">Mason component call</a>
38 * (<code>&lt;&amp;<var> &#46;&#46;&#46; </var>&amp;&gt;</code>).
39 * <p>
40 * <dl>
41 * <dt>Properties:</dt>
42 * <dd>
43 * <table class="bordered" style="margin: 15px" cellspacing="0">
44 * <tr><th>Property<th>Value
45 * <tr><td>{@link StartTagType#getDescription() Description}<td>mason component call
46 * <tr><td>{@link StartTagType#getStartDelimiter() StartDelimiter}<td><code>&lt;&amp;</code>
47 * <tr><td>{@link StartTagType#getClosingDelimiter() ClosingDelimiter}<td><code>&amp;&gt;</code>
48 * <tr><td>{@link StartTagType#isServerTag() IsServerTag}<td><code>true</code>
49 * <tr><td>{@link StartTagType#getNamePrefix() NamePrefix}<td><code>&amp;</code>
50 * <tr><td>{@link StartTagType#getCorrespondingEndTagType() CorrespondingEndTagType}<td><code>null</code>
51 * <tr><td>{@link StartTagType#hasAttributes() HasAttributes}<td><code>false</code>
52 * <tr><td>{@link StartTagType#isNameAfterPrefixRequired() IsNameAfterPrefixRequired}<td><code>false</code>
53 * </table>
54 * <dt>Example:</dt>
55 * <dd><code>&lt;&amp; menu &amp;&gt;</code></dd>
56 * </dl>
57 */
58 public static final StartTagType MASON_COMPONENT_CALL=StartTagTypeMasonComponentCall.INSTANCE;
59
60 /**
61 * The tag type given to the start tag of a
62 * <a target="_blank" href="http://www.masonbook.com/book/chapter-2.mhtml#CHP-2-SECT-3.3.1">Mason component called with content</a>
63 * (<code>&lt;&amp;|<var> &#46;&#46;&#46; </var>&amp;&gt;<var> &#46;&#46;&#46; </var>&lt;/&amp;&gt;</code>).
64 * <p>
65 * <dl>
66 * <dt>Properties:</dt>
67 * <dd>
68 * <table class="bordered" style="margin: 15px" cellspacing="0">
69 * <tr><th>Property<th>Value
70 * <tr><td>{@link StartTagType#getDescription() Description}<td>mason component called with content
71 * <tr><td>{@link StartTagType#getStartDelimiter() StartDelimiter}<td><code>&lt;&amp;|</code>
72 * <tr><td>{@link StartTagType#getClosingDelimiter() ClosingDelimiter}<td><code>&amp;&gt;</code>
73 * <tr><td>{@link StartTagType#isServerTag() IsServerTag}<td><code>true</code>
74 * <tr><td>{@link StartTagType#getNamePrefix() NamePrefix}<td><code>&amp;|</code>
75 * <tr><td>{@link StartTagType#getCorrespondingEndTagType() CorrespondingEndTagType}<td>{@link #MASON_COMPONENT_CALLED_WITH_CONTENT_END}
76 * <tr><td>{@link StartTagType#hasAttributes() HasAttributes}<td><code>false</code>
77 * <tr><td>{@link StartTagType#isNameAfterPrefixRequired() IsNameAfterPrefixRequired}<td><code>false</code>
78 * </table>
79 * <dt>Example:</dt>
80 * <dd><pre> &lt;&amp;| /sql/select, query =&gt; 'SELECT name, age FROM User' &amp;&gt;
81 * &lt;tr&gt;&lt;td&gt;%name&lt;/td&gt;&lt;td&gt;%age&lt;/td&gt;&lt;/tr&gt;
82 * &lt;/&amp;&gt;</pre></dd>
83 * </dl>
84 */
85 public static final StartTagType MASON_COMPONENT_CALLED_WITH_CONTENT=StartTagTypeMasonComponentCalledWithContent.INSTANCE;
86 // THIS ELEMENT TYPICALLY CONTAINS MARKUP
87
88 /**
89 * The tag type given to the end tag of a
90 * <a target="_blank" href="http://www.masonbook.com/book/chapter-2.mhtml#CHP-2-SECT-3.3.1">Mason component called with content</a>.
91 * <p>
92 * See the {@linkplain EndTagType#getCorrespondingStartTagType() corresponding start tag type}
93 * {@link #MASON_COMPONENT_CALLED_WITH_CONTENT} for more details.
94 * <p>
95 * <dl>
96 * <dt>Properties:</dt>
97 * <dd>
98 * <table class="bordered" style="margin: 15px" cellspacing="0">
99 * <tr><th>Property/Method<th>Value
100 * <tr><td>{@link EndTagType#getDescription() Description}<td>/mason component called with content
101 * <tr><td>{@link EndTagType#getStartDelimiter() StartDelimiter}<td><code>&lt;/&amp;</code>
102 * <tr><td>{@link EndTagType#getClosingDelimiter() ClosingDelimiter}<td><code>&gt;</code>
103 * <tr><td>{@link EndTagType#isServerTag() IsServerTag}<td><code>true</code>
104 * <tr><td>{@link EndTagType#getNamePrefix() NamePrefix}<td><code>/&amp;</code>
105 * <tr><td>{@link EndTagType#getCorrespondingStartTagType() CorrespondingStartTagType}<td>{@link #MASON_COMPONENT_CALLED_WITH_CONTENT}
106 * <tr><td>{@link EndTagType#generateHTML(String) generateHTML}<code>("<var>StartTagName</var>")</code><td><code>&lt;/&amp;&gt;</code>
107 * </table>
108 * <dt>Example:</dt>
109 * <dd><code>&lt;/&amp;&gt;</code></dd>
110 * </dl>
111 * @see #MASON_COMPONENT_CALLED_WITH_CONTENT
112 */
113 public static final EndTagType MASON_COMPONENT_CALLED_WITH_CONTENT_END=EndTagTypeMasonComponentCalledWithContent.INSTANCE;
114
115 /**
116 * The tag type given to the start tag of a
117 * <a target="_blank" href="http://www.masonbook.com/book/chapter-2.mhtml#CHP-2-SECT-3.4">Mason named block</a>
118 * (<code>&lt;%<i>name</i><var> &#46;&#46;&#46; </var>&gt;<var> &#46;&#46;&#46; </var>&lt;/%<i>name</i>&gt;</code>).
119 * <p>
120 * A tag of this type <b>must not</b> have a '<code>%</code>' character before its
121 * {@linkplain StartTagType#getClosingDelimiter() closing delimiter}, otherwise it is most likely a
122 * {@linkplain StartTagType#SERVER_COMMON common server tag}.
123 * <p>
124 * For the start tag to be recognised, a {@linkplain StartTagType#getCorrespondingEndTagType() corresponding} end tag of the
125 * {@linkplain #MASON_NAMED_BLOCK_END correct type} <b>must</b> exist somewhere in the source document following the start tag.
126 * <p>
127 * <dl>
128 * <dt>Properties:</dt>
129 * <dd>
130 * <table class="bordered" style="margin: 15px" cellspacing="0">
131 * <tr><th>Property<th>Value
132 * <tr><td>{@link StartTagType#getDescription() Description}<td>mason named block
133 * <tr><td>{@link StartTagType#getStartDelimiter() StartDelimiter}<td><code>&lt;%</code>
134 * <tr><td>{@link StartTagType#getClosingDelimiter() ClosingDelimiter}<td><code>&gt;</code>
135 * <tr><td>{@link StartTagType#isServerTag() IsServerTag}<td><code>true</code>
136 * <tr><td>{@link StartTagType#getNamePrefix() NamePrefix}<td><code>%</code>
137 * <tr><td>{@link StartTagType#getCorrespondingEndTagType() CorrespondingEndTagType}<td>{@link #MASON_NAMED_BLOCK_END}
138 * <tr><td>{@link StartTagType#hasAttributes() HasAttributes}<td><code>false</code>
139 * <tr><td>{@link StartTagType#isNameAfterPrefixRequired() IsNameAfterPrefixRequired}<td><code>true</code>
140 * </table>
141 * <dt>Example:</dt>
142 * <dd><code>&lt;%perl&gt; print "hello world"; &lt;/%perl&gt;</code></dd>
143 * </dl>
144 */
145 public static final StartTagType MASON_NAMED_BLOCK=StartTagTypeMasonNamedBlock.INSTANCE;
146 // THIS ELEMENT TYPICALLY CONTAINS CODE, EXCEPT FOR THE <%def> VARIETY WHICH CONTAINS SOME MARKUP AND SOME OTHER SERVER ELEMENTS
147
148 /**
149 * The tag type given to the end tag of a
150 * <a target="_blank" href="http://www.masonbook.com/book/chapter-2.mhtml#CHP-2-SECT-3.4">Mason named block</a>.
151 * <p>
152 * See the {@linkplain EndTagType#getCorrespondingStartTagType() corresponding start tag type}
153 * {@link #MASON_NAMED_BLOCK} for more details.
154 * <p>
155 * <dl>
156 * <dt>Properties:</dt>
157 * <dd>
158 * <table class="bordered" style="margin: 15px" cellspacing="0">
159 * <tr><th>Property/Method<th>Value
160 * <tr><td>{@link EndTagType#getDescription() Description}<td>/mason named block
161 * <tr><td>{@link EndTagType#getStartDelimiter() StartDelimiter}<td><code>&lt;/%</code>
162 * <tr><td>{@link EndTagType#getClosingDelimiter() ClosingDelimiter}<td><code>&gt;</code>
163 * <tr><td>{@link EndTagType#isServerTag() IsServerTag}<td><code>true</code>
164 * <tr><td>{@link EndTagType#getNamePrefix() NamePrefix}<td><code>/%</code>
165 * <tr><td>{@link EndTagType#getCorrespondingStartTagType() CorrespondingStartTagType}<td>{@link #MASON_NAMED_BLOCK}
166 * <tr><td>{@link EndTagType#generateHTML(String) generateHTML}<code>("%<var>StartTagName</var>")</code><td><code>&lt;/%<var>StartTagName</var>&gt;</code>
167 * </table>
168 * <dt>Example:</dt>
169 * <dd><code>&lt;/%perl&gt;</code></dd>
170 * </dl>
171 * @see #MASON_NAMED_BLOCK
172 */
173 public static final EndTagType MASON_NAMED_BLOCK_END=EndTagTypeMasonNamedBlock.INSTANCE;
174
175 private static final TagType[] TAG_TYPES={
176 MASON_COMPONENT_CALL,
177 MASON_COMPONENT_CALLED_WITH_CONTENT,
178 MASON_COMPONENT_CALLED_WITH_CONTENT_END,
179 MASON_NAMED_BLOCK,
180 MASON_NAMED_BLOCK_END
181 };
182
183 private MasonTagTypes() {}
184
185 /**
186 * {@linkplain TagType#register() Registers} all of the tag types defined in this class at once.
187 * <p>
188 * The tag types must be registered before the parser will recognise them.
189 */
190 public static void register() {
191 for (TagType tagType : TAG_TYPES) tagType.register();
192 }
193
194 /**
195 * {@linkplain TagType#deregister() Deregisters} all of the tag types defined in this class at once.
196 */
197 public static void deregister() {
198 for (TagType tagType : TAG_TYPES) tagType.deregister();
199 }
200
201 /**
202 * Indicates whether the specified tag type is defined in this class.
203 *
204 * @param tagType the {@link TagType} to test.
205 * @return <code>true</code> if the specified tag type is defined in this class, otherwise <code>false</code>.
206 */
207 public static boolean defines(final TagType tagType) {
208 for (TagType definedTagType : TAG_TYPES) if (tagType==definedTagType) return true;
209 return false;
210 }
211
212 /**
213 * Indicates whether the specified tag type is recognised by a <a target="_blank" href="http://www.masonhq.com/">Mason</a> parser.
214 * <p>
215 * This is true if the specified tag type is {@linkplain #defines(TagType) defined in this class} or if it is the
216 * {@linkplain StartTagType#SERVER_COMMON common server tag type}.
217 *
218 * @param tagType the {@link TagType} to test.
219 * @return <code>true</code> if the specified tag type is recognised by a <a target="_blank" href="http://www.masonhq.com/">Mason</a> parser, otherwise <code>false</code>.
220 */
221 public static boolean isParsedByMason(final TagType tagType) {
222 return tagType==StartTagType.SERVER_COMMON || defines(tagType);
223 }
224 }

   
Visit the aagtl Website