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 |
import java.util.*;
|
24 |
|
25 |
/**
|
26 |
* Contains {@linkplain TagType tag types} recognised exclusively by Microsoft® Internet Explorer.
|
27 |
* <p>
|
28 |
* The tag type defined in this class is not {@linkplain TagType#register() registered} by default.
|
29 |
*
|
30 |
* @deprecated Use the tag types defined in {@link MicrosoftConditionalCommentTagTypes} instead.
|
31 |
*/
|
32 |
@Deprecated
|
33 |
public final class MicrosoftTagTypes {
|
34 |
|
35 |
/**
|
36 |
* The tag type given to a Microsoft® <a target="_blank" href="http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment">downlevel-revealed conditional comment</a>
|
37 |
* (<code><![if<var> ... </var>]></code> | <code><![endif]></code>).
|
38 |
* <p>
|
39 |
* The only valid {@linkplain Tag#getName() names} for tags of this type are "<code>![if</code>" and "<code>![endif</code>".
|
40 |
* <p>
|
41 |
* This start tag type is used to represent both the "if" and "endif" tags.
|
42 |
* Because the "endif" tag can not be represented by an {@linkplain EndTagType end tag type} (it doesn't start with "<code></</code>"),
|
43 |
* the parser makes no attempt to match if-endif tag pairs to form {@linkplain Element elements}.
|
44 |
* <p>
|
45 |
* The {@link #isConditionalCommentIfTag(Tag)} and {@link #isConditionalCommentEndifTag(Tag)} methods provide an efficient means of determining whether
|
46 |
* a given tag is of the "if" or "endif" variety.
|
47 |
* <p>
|
48 |
* The expression consituting the condition of an "if" tag can be extracted using the {@link StartTag#getTagContent()} method.
|
49 |
* For example, if the variable <code>conditionalCommentIfTag</code> represents the tag <code><![if !IE]></code>, then the expression
|
50 |
* <code>conditionalCommentIfTag.getTagContent().toString().trim()</code> yields the string "<code>!IE</code>".
|
51 |
* <p>
|
52 |
* <dl>
|
53 |
* <dt>Properties:</dt>
|
54 |
* <dd>
|
55 |
* <table class="bordered" style="margin: 15px" cellspacing="0">
|
56 |
* <tr><th>Property<th>Value
|
57 |
* <tr><td>{@link StartTagType#getDescription() Description}<td>Microsoft downlevel-revealed conditional comment
|
58 |
* <tr><td>{@link StartTagType#getStartDelimiter() StartDelimiter}<td><code><![</code>
|
59 |
* <tr><td>{@link StartTagType#getClosingDelimiter() ClosingDelimiter}<td><code>]></code>
|
60 |
* <tr><td>{@link StartTagType#isServerTag() IsServerTag}<td><code>false</code>
|
61 |
* <tr><td>{@link StartTagType#getNamePrefix() NamePrefix}<td><code>![</code>
|
62 |
* <tr><td>{@link StartTagType#getCorrespondingEndTagType() CorrespondingEndTagType}<td><code>null</code>
|
63 |
* <tr><td>{@link StartTagType#hasAttributes() HasAttributes}<td><code>false</code>
|
64 |
* <tr><td>{@link StartTagType#isNameAfterPrefixRequired() IsNameAfterPrefixRequired}<td><code>true</code>
|
65 |
* </table>
|
66 |
* <dt>Example:</dt>
|
67 |
* <dd><code><![if !IE]></code></dd>
|
68 |
* </dl>
|
69 |
* @deprecated Use {@link MicrosoftConditionalCommentTagTypes#DOWNLEVEL_REVEALED_IF} and {@link MicrosoftConditionalCommentTagTypes#DOWNLEVEL_REVEALED_ENDIF} instead.
|
70 |
*/
|
71 |
public static final StartTagType DOWNLEVEL_REVEALED_CONDITIONAL_COMMENT=StartTagTypeMicrosoftDownlevelRevealedConditionalComment.INSTANCE;
|
72 |
|
73 |
private static final TagType[] TAG_TYPES={
|
74 |
DOWNLEVEL_REVEALED_CONDITIONAL_COMMENT
|
75 |
};
|
76 |
|
77 |
private MicrosoftTagTypes() {}
|
78 |
|
79 |
/**
|
80 |
* Indicates whether the specified tag is a {@linkplain #DOWNLEVEL_REVEALED_CONDITIONAL_COMMENT downlevel-revealed conditional comment} "if" tag
|
81 |
* (<code><![if<var> ... </var>]></code>).
|
82 |
*
|
83 |
* @param tag the {@link Tag} to test.
|
84 |
* @return <code>true</code> if the specified tag is a <a target="_blank" href="http://en.wikipedia.org/wiki/Conditional_comment">conditional comment</a> "if" tag, otherwise <code>false</code>.
|
85 |
*/
|
86 |
public static boolean isConditionalCommentIfTag(final Tag tag) {
|
87 |
return tag.getName()==StartTagTypeMicrosoftDownlevelRevealedConditionalComment.IF;
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
* Indicates whether the specified tag is a {@linkplain #DOWNLEVEL_REVEALED_CONDITIONAL_COMMENT downlevel-revealed conditional comment} "endif" tag
|
92 |
* (<code><![endif]></code>).
|
93 |
*
|
94 |
* @param tag the {@link Tag} to test.
|
95 |
* @return <code>true</code> if the specified tag is a <a target="_blank" href="http://en.wikipedia.org/wiki/Conditional_comment">conditional comment</a> "endif" tag, otherwise <code>false</code>.
|
96 |
*/
|
97 |
public static boolean isConditionalCommentEndifTag(final Tag tag) {
|
98 |
return tag.getName()==StartTagTypeMicrosoftDownlevelRevealedConditionalComment.ENDIF;
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
* {@linkplain TagType#register() Registers} all of the tag types defined in this class at once.
|
103 |
* <p>
|
104 |
* The tag types must be registered before the parser will recognise them.
|
105 |
*/
|
106 |
public static void register() {
|
107 |
for (TagType tagType : TAG_TYPES) tagType.register();
|
108 |
}
|
109 |
|
110 |
/**
|
111 |
* {@linkplain TagType#deregister() Deregisters} all of the tag types defined in this class at once.
|
112 |
*/
|
113 |
public static void deregister() {
|
114 |
for (TagType tagType : TAG_TYPES) tagType.deregister();
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
* Indicates whether the specified tag type is defined in this class.
|
119 |
*
|
120 |
* @param tagType the {@link TagType} to test.
|
121 |
* @return <code>true</code> if the specified tag type is defined in this class, otherwise <code>false</code>.
|
122 |
*/
|
123 |
public static boolean defines(final TagType tagType) {
|
124 |
for (TagType definedTagType : TAG_TYPES) if (tagType==definedTagType) return true;
|
125 |
return false;
|
126 |
}
|
127 |
|
128 |
}
|
129 |
|