KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > au > id > jericho > lib > html > Config


1 // Jericho HTML Parser - Java based library for analysing and manipulating HTML
2
// Version 2.2
3
// Copyright (C) 2006 Martin Jericho
4
// http://sourceforge.net/projects/jerichohtml/
5
//
6
// This library is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU Lesser General Public
8
// License as published by the Free Software Foundation; either
9
// version 2.1 of the License, or (at your option) any later version.
10
// http://www.gnu.org/copyleft/lesser.html
11
//
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// Lesser General Public License for more details.
16
//
17
// You should have received a copy of the GNU Lesser General Public
18
// License along with this library; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20

21 package au.id.jericho.lib.html;
22
23 import java.util.*;
24
25 /**
26  * Encapsulates global configuration properties which determine the behaviour of various functions.
27  * <p>
28  * All of the properties in this class are static, affecting all objects and threads.
29  * Multiple concurrent configurations are not possible.
30  * <p>
31  * Properties that relate to <a target="_blank" HREF="http://www.w3.org/TR/html401/conform.html#didx-user_agent">user agent</a>
32  * compatibility issues are stored in instances of the {@link Config.CompatibilityMode} class.
33  * This allows all of the properties in the compatibility mode to be set as a block by setting the static
34  * {@link #CurrentCompatibilityMode} property to a different instance.
35  *
36  * @see Config.CompatibilityMode
37  */

38 public final class Config {
39     private Config() {}
40
41     /**
42      * Determines the string used to separate a single column's multiple values in the output of the {@link FormFields#getColumnValues(Map)} method.
43      * <p>
44      * The situation where a single column has multiple values only arises if {@link FormField#getUserValueCount()}<code>&gt;1</code>
45      * on the relevant form field, which usually indicates a poorly designed form.
46      * <p>
47      * The default value is "<code>,</code>" (a comma, not including the quotes).
48      * <p>
49      * Must not be <code>null</code>.
50      */

51     public static String JavaDoc ColumnMultipleValueSeparator=",";
52
53     /**
54      * Determines the string that represents the value <code>true</code> in the output of the {@link FormFields#getColumnValues(Map)} method.
55      * <p>
56      * The default value is "<code>true</code>" (without the quotes).
57      * <p>
58      * Must not be <code>null</code>.
59      */

60     public static String JavaDoc ColumnValueTrue=Boolean.toString(true);
61
62     /**
63      * Determines the string that represents the value <code>false</code> in the output of the {@link FormFields#getColumnValues(Map)} method.
64      * <p>
65      * The default value is <code>null</code>, which represents no output at all.
66      */

67     public static String JavaDoc ColumnValueFalse=null;
68
69     /**
70      * Determines the currently active {@linkplain Config.CompatibilityMode compatibility mode}.
71      * <p>
72      * The default setting is {@link Config.CompatibilityMode#IE} (MS Internet Explorer 6.0).
73      * <p>
74      * Must not be <code>null</code>.
75      */

76     public static CompatibilityMode CurrentCompatibilityMode=CompatibilityMode.IE;
77
78     /**
79      * Determines whether apostrophes are encoded when calling the {@link CharacterReference#encode(CharSequence)} method.
80      * <p>
81      * A value of <code>false</code> means {@linkplain CharacterEntityReference#_apos apostrophe}
82      * (U+0027) characters are not encoded.
83      * The only time apostrophes need to be encoded is within an attribute value delimited by
84      * single quotes (apostrophes), so in most cases ignoring apostrophes is perfectly safe and
85      * enhances the readability of the source document.
86      * <p>
87      * Note that apostrophes are always encoded as a {@linkplain NumericCharacterReference numeric character reference}, never as the
88      * character entity reference {@link CharacterEntityReference#_apos &amp;apos;}.
89      * <p>
90      * The default value is <code>false</code>.
91      */

92     public static boolean IsApostropheEncoded=false;
93
94     /**
95      * Used in Element.getChildElements.
96      * Will only make this public if someone makes a convincing argument why you would ever need to include server tags in an element hierarchy.
97      */

98     static final boolean IncludeServerTagsInElementHierarchy=false;
99
100     /**
101      * Represents a set of maximum unicode code points to be recognised for the three types of
102      * <a HREF="CharacterReference.html#Unterminated">unterminated</a> character reference in a given context.
103      * <p>
104      * The three types of character reference are:
105      * <ul>
106      * <li>{@linkplain CharacterEntityReference Character entity reference}
107      * <li><a HREF="NumericCharacterReference.html#DecimalCharacterReference">Decimal character reference</a>
108      * <li><a HREF="NumericCharacterReference.html#HexadecimalCharacterReference">Hexadecimal character reference</a>
109      * </ul>
110      * <p>
111      * The two types of contexts used in this library are:
112      * <ul>
113      * <li>Inside an attribute value
114      * <li>Outside an attribute value
115      * </ul>
116      */

117     static class UnterminatedCharacterReferenceSettings {
118         // use volatile fields to make them thread safe
119
public volatile int characterEntityReferenceMaxCodePoint;
120         public volatile int decimalCharacterReferenceMaxCodePoint;
121         public volatile int hexadecimalCharacterReferenceMaxCodePoint;
122
123         public static UnterminatedCharacterReferenceSettings ACCEPT_ALL=new UnterminatedCharacterReferenceSettings(CompatibilityMode.CODE_POINTS_ALL,CompatibilityMode.CODE_POINTS_ALL,CompatibilityMode.CODE_POINTS_ALL);
124
125         public UnterminatedCharacterReferenceSettings() {
126             this(CompatibilityMode.CODE_POINTS_NONE,CompatibilityMode.CODE_POINTS_NONE,CompatibilityMode.CODE_POINTS_NONE);
127         }
128
129         public UnterminatedCharacterReferenceSettings(final int characterEntityReferenceMaxCodePoint, final int decimalCharacterReferenceMaxCodePoint, final int hexadecimalCharacterReferenceMaxCodePoint) {
130             this.characterEntityReferenceMaxCodePoint=characterEntityReferenceMaxCodePoint;
131             this.decimalCharacterReferenceMaxCodePoint=decimalCharacterReferenceMaxCodePoint;
132             this.hexadecimalCharacterReferenceMaxCodePoint=hexadecimalCharacterReferenceMaxCodePoint;
133         }
134
135         public String JavaDoc toString() {
136             return "\n Character entity reference: "+getDescription(characterEntityReferenceMaxCodePoint)
137                         +"\n Decimal character reference: "+getDescription(decimalCharacterReferenceMaxCodePoint)
138                         +"\n Haxadecimal character reference: "+getDescription(hexadecimalCharacterReferenceMaxCodePoint);
139         }
140
141         private String JavaDoc getDescription(final int codePoint) {
142             if (codePoint==CompatibilityMode.CODE_POINTS_NONE) return "None";
143             if (codePoint==CompatibilityMode.CODE_POINTS_ALL) return "All";
144             return "0x"+Integer.toString(codePoint,16);
145         }
146     }
147
148     /**
149      * Represents a set of configuration parameters that relate to
150      * <a target="_blank" HREF="http://www.w3.org/TR/html401/conform.html#didx-user_agent">user agent</a> compatibility issues.
151      * <p>
152      * The predefined compatibility modes {@link #IE}, {@link #MOZILLA}, {@link #OPERA} and {@link #XHTML} provide an easy means of
153      * ensuring the library interprets the markup in a way consistent with some of the most commonly used browsers,
154      * at least in relation to the behaviour described by the properties in this class.
155      * <p>
156      * The properties of any <code>CompatibilityMode</code> object can be modified individually, including those in
157      * the predefined instances as well as newly constructed instances.
158      * Take note however that modifying the properties of the predefined instances has a global affect.
159      * <p>
160      * The currently active compatibility mode is stored in the static
161      * {@link Config#CurrentCompatibilityMode} property.
162      * <p>
163      */

164     public static final class CompatibilityMode {
165         private String JavaDoc name;
166         private volatile boolean formFieldNameCaseInsensitive;
167         volatile UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettingsInsideAttributeValue;
168         volatile UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettingsOutsideAttributeValue;
169
170         /**
171          * Indicates the recognition of all unicode code points.
172          * <p>
173          * This value is used in properties which specify a maximum unicode code point to be recognised by the parser.
174          *
175          * @see #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean insideAttributeValue)
176          * @see #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)
177          * @see #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)
178          */

179         public static final int CODE_POINTS_ALL=CharacterReference.MAX_CODE_POINT;
180
181         /**
182          * Indicates the recognition of no unicode code points.
183          * <p>
184          * This value is used in properties which specify a maximum unicode code point to be recognised by the parser.
185          *
186          * @see #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean insideAttributeValue)
187          * @see #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)
188          * @see #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)
189          */

190         public static final int CODE_POINTS_NONE=CharacterReference.INVALID_CODE_POINT;
191
192         /**
193          * <a target="_blank" HREF="http://www.microsoft.com/windows/ie/">Microsoft Internet Explorer</a> compatibility mode.
194          * <p>
195          * <code>{@link #getName() Name} = IE</code><br />
196          * <code>{@link #isFormFieldNameCaseInsensitive() FormFieldNameCaseInsensitive} = true</code><br />
197          * <table cellspacing="0" cellpadding="0">
198          * <tr><th>Recognition of unterminated character references:<th><th align="center">&nbsp; (inside attribute) &nbsp;<th align="center">&nbsp; (outside attribute) &nbsp;
199          * <tr><td>{@link #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean) UnterminatedCharacterEntityReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">U+00FF<td align="center">U+00FF
200          * <tr><td>{@link #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedDecimalCharacterReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
201          * <tr><td>{@link #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedHexadecimalCharacterReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_NONE None}
202          * </table>
203          */

204         public static final CompatibilityMode IE=new CompatibilityMode("IE",true,
205             new UnterminatedCharacterReferenceSettings(0xFF, CODE_POINTS_ALL, CODE_POINTS_ALL), // inside attributes
206
new UnterminatedCharacterReferenceSettings(0xFF, CODE_POINTS_ALL, CODE_POINTS_NONE) // outside attributes
207
);
208
209         /**
210          * <a target="_blank" HREF="http://www.mozilla.org/products/mozilla1.x/">Mozilla</a> /
211          * <a target="_blank" HREF="http://www.mozilla.org/products/firefox/">Firefox</a> /
212          * <a target="_blank" HREF="http://browser.netscape.com/">Netscape</a> compatibility mode.
213          * <p>
214          * <code>{@link #getName() Name} = Mozilla</code><br />
215          * <code>{@link #isFormFieldNameCaseInsensitive() FormFieldNameCaseInsensitive} = false</code><br />
216          * <table cellspacing="0" cellpadding="0">
217          * <tr><th>Recognition of unterminated character references:<th><th align="center">&nbsp; (inside attribute) &nbsp;<th align="center">&nbsp; (outside attribute) &nbsp;
218          * <tr><td>{@link #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean) UnterminatedCharacterEntityReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">U+00FF<td align="center">{@linkplain #CODE_POINTS_ALL All}
219          * <tr><td>{@link #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedDecimalCharacterReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
220          * <tr><td>{@link #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedHexadecimalCharacterReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
221          * </table>
222          */

223         public static final CompatibilityMode MOZILLA=new CompatibilityMode("Mozilla",false,
224             new UnterminatedCharacterReferenceSettings(0xFF, CODE_POINTS_ALL, CODE_POINTS_ALL), // inside attributes
225
new UnterminatedCharacterReferenceSettings(CODE_POINTS_ALL, CODE_POINTS_ALL, CODE_POINTS_ALL) // outside attributes
226
);
227
228         /**
229          * Opera compatibility mode.
230          * <p>
231          * <code>{@link #getName() Name} = Opera</code><br />
232          * <code>{@link #isFormFieldNameCaseInsensitive() FormFieldNameCaseInsensitive} = true</code><br />
233          * <table cellspacing="0" cellpadding="0">
234          * <tr><th>Recognition of unterminated character references:<th><th align="center">&nbsp; (inside attribute) &nbsp;<th align="center">&nbsp; (outside attribute) &nbsp;
235          * <tr><td>{@link #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean) UnterminatedCharacterEntityReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">U+003E<td align="center">{@linkplain #CODE_POINTS_ALL All}
236          * <tr><td>{@link #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedDecimalCharacterReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
237          * <tr><td>{@link #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedHexadecimalCharacterReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
238          * </table>
239          */

240         public static final CompatibilityMode OPERA=new CompatibilityMode("Opera",true,
241             new UnterminatedCharacterReferenceSettings(0x3E, CODE_POINTS_ALL, CODE_POINTS_ALL), // inside attributes
242
new UnterminatedCharacterReferenceSettings(CODE_POINTS_ALL, CODE_POINTS_ALL, CODE_POINTS_ALL) // outside attributes
243
);
244
245         /**
246          * <a target="_blank" HREF="http://www.w3.org/TR/xhtml1/#xhtml">XHTML</a> compatibility mode.
247          * <p>
248          * <code>{@link #getName() Name} = XHTML</code><br />
249          * <code>{@link #isFormFieldNameCaseInsensitive() FormFieldNameCaseInsensitive} = false</code><br />
250          * <table cellspacing="0" cellpadding="0">
251          * <tr><th>Recognition of unterminated character references:<th><th align="center">&nbsp; (inside attribute) &nbsp;<th align="center">&nbsp; (outside attribute) &nbsp;
252          * <tr><td>{@link #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean) UnterminatedCharacterEntityReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">{@linkplain #CODE_POINTS_NONE None}<td align="center">{@linkplain #CODE_POINTS_NONE None}
253          * <tr><td>{@link #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedDecimalCharacterReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">{@linkplain #CODE_POINTS_NONE None}<td align="center">{@linkplain #CODE_POINTS_NONE None}
254          * <tr><td>{@link #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedHexadecimalCharacterReferenceMaxCodePoint}<td><code>&nbsp;=</code><td align="center">{@linkplain #CODE_POINTS_NONE None}<td align="center">{@linkplain #CODE_POINTS_NONE None}
255          * </table>
256          */

257         public static final CompatibilityMode XHTML=new CompatibilityMode("XHTML");
258
259         /**
260          * Constructs a new <code>CompatibilityMode</code> with the given {@linkplain #getName() name}.
261          * <p>
262          * All properties in the new instance are initially assigned their default values, which are the same as the strict
263          * rules of the {@link #XHTML} compatibility mode.
264          *
265          * @param name the {@linkplain #getName() name} of the new compatibility mode
266          */

267         public CompatibilityMode(final String JavaDoc name) {
268             this(name,false,new UnterminatedCharacterReferenceSettings(),new UnterminatedCharacterReferenceSettings());
269         }
270
271         private CompatibilityMode(final String JavaDoc name, final boolean formFieldNameCaseInsensitive, final UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettingsInsideAttributeValue, final UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettingsOutsideAttributeValue) {
272             this.name=name;
273             this.formFieldNameCaseInsensitive=formFieldNameCaseInsensitive;
274             this.unterminatedCharacterReferenceSettingsInsideAttributeValue=unterminatedCharacterReferenceSettingsInsideAttributeValue;
275             this.unterminatedCharacterReferenceSettingsOutsideAttributeValue=unterminatedCharacterReferenceSettingsOutsideAttributeValue;
276         }
277
278         /**
279          * Returns the name of this compatibility mode.
280          * @return the name of this compatibility mode.
281          */

282         public String JavaDoc getName() {
283             return name;
284         }
285
286         /**
287          * Indicates whether {@linkplain FormField#getName() form field names} are treated as case insensitive.
288          * <p>
289          * Microsoft Internet Explorer treats field names as case insensitive,
290          * while Mozilla treats them as case sensitive.
291          * <p>
292          * The value of this property in the {@linkplain Config#CurrentCompatibilityMode current compatibility mode}
293          * affects all instances of the {@link FormFields} class.
294          * It should be set to the desired configuration before any instances of <code>FormFields</code> are created.
295          *
296          * @return <code>true</code> if {@linkplain FormField#getName() form field names} are treated as case insensitive, otherwise <code>false</code>.
297          * @see #setFormFieldNameCaseInsensitive(boolean)
298          */

299         public boolean isFormFieldNameCaseInsensitive() {
300             return formFieldNameCaseInsensitive;
301         }
302
303         /**
304          * Sets whether {@linkplain FormField#getName() form field names} are treated as case insensitive.
305          * <p>
306          * See {@link #isFormFieldNameCaseInsensitive()} for the documentation of this property.
307          *
308          * @param value the new value of the property
309          */

310         public void setFormFieldNameCaseInsensitive(final boolean value) {
311             formFieldNameCaseInsensitive=value;
312         }
313
314         /**
315          * Returns the maximum unicode code point of an <a HREF="CharacterReference.html#Unterminated">unterminated</a>
316          * {@linkplain CharacterEntityReference character entity reference} which is to be recognised in the specified context.
317          * <p>
318          * For example, if <code>getUnterminatedCharacterEntityReferenceMaxCodePoint(true)</code> has the value <code>0xFF</code> (U+00FF)
319          * in the {@linkplain Config#CurrentCompatibilityMode current compatibility mode}, then:
320          * <ul>
321          * <li>{@link CharacterReference#decode(CharSequence,boolean) CharacterReference.decode("&amp;gt",true)}
322          * returns "<code>&gt;</code>".<br />
323          * The string is recognised as the character entity reference {@link CharacterEntityReference#_gt &amp;gt;}
324          * despite the fact that it is <a HREF="CharacterReference.html#Unterminated">unterminated</a>,
325          * because its unicode code point U+003E is below the maximum of U+00FF set by this property.
326          * <li>{@link CharacterReference#decode(CharSequence,boolean) CharacterReference.decode("&amp;euro",true)}
327          * returns "<code>&amp;euro</code>".<br />
328          * The string is not recognised as the character entity reference {@link CharacterEntityReference#_euro &amp;euro;}
329          * because it is <a HREF="CharacterReference.html#Unterminated">unterminated</a>
330          * and its unicode code point U+20AC is above the maximum of U+00FF set by this property.
331          * </ul>
332          * <p>
333          * See the documentation of the {@link Attribute#getValue()} method for further discussion.
334          *
335          * @param insideAttributeValue the context within an HTML document - <code>true</code> if inside an attribute value or <code>false</code> if outside an attribute value.
336          * @return the maximum unicode code point of an <a HREF="CharacterReference.html#Unterminated">unterminated</a> {@linkplain CharacterEntityReference character entity reference} which is to be recognised in the specified context.
337          * @see #setUnterminatedCharacterEntityReferenceMaxCodePoint(boolean insideAttributeValue, int maxCodePoint)
338          */

339         public int getUnterminatedCharacterEntityReferenceMaxCodePoint(final boolean insideAttributeValue) {
340             return getUnterminatedCharacterReferenceSettings(insideAttributeValue).characterEntityReferenceMaxCodePoint;
341         }
342
343         /**
344          * Sets the maximum unicode code point of an <a HREF="CharacterReference.html#Unterminated">unterminated</a>
345          * {@linkplain CharacterEntityReference character entity reference} which is to be recognised in the specified context.
346          * <p>
347          * See {@link #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean insideAttributeValue)} for the documentation of this property.
348          *
349          * @param insideAttributeValue the context within an HTML document - <code>true</code> if inside an attribute value or <code>false</code> if outside an attribute value.
350          * @param maxCodePoint the maximum unicode code point.
351          */

352         public void setUnterminatedCharacterEntityReferenceMaxCodePoint(final boolean insideAttributeValue, final int maxCodePoint) {
353             getUnterminatedCharacterReferenceSettings(insideAttributeValue).characterEntityReferenceMaxCodePoint=maxCodePoint;
354         }
355
356         /**
357          * Returns the maximum unicode code point of an <a HREF="CharacterReference.html#Unterminated">unterminated</a>
358          * <a HREF="NumericCharacterReference.html#DecimalCharacterReference">decimal character reference</a> which is to be recognised in the specified context.
359          * <p>
360          * For example, if <code>getUnterminatedDecimalCharacterReferenceMaxCodePoint(true)</code> had the hypothetical value <code>0xFF</code> (U+00FF)
361          * in the {@linkplain Config#CurrentCompatibilityMode current compatibility mode}, then:
362          * <ul>
363          * <li>{@link CharacterReference#decode(CharSequence,boolean) CharacterReference.decode("&amp;#62",true)}
364          * returns "<code>&gt;</code>".<br />
365          * The string is recognised as the numeric character reference <code>&amp;#62;</code>
366          * despite the fact that it is <a HREF="CharacterReference.html#Unterminated">unterminated</a>,
367          * because its unicode code point U+003E is below the maximum of U+00FF set by this property.
368          * <li>{@link CharacterReference#decode(CharSequence,boolean) CharacterReference.decode("&amp;#8364",true)}
369          * returns "<code>&amp;#8364</code>".<br />
370          * The string is not recognised as the numeric character reference <code>&amp;#8364;</code>
371          * because it is <a HREF="CharacterReference.html#Unterminated">unterminated</a>
372          * and its unicode code point U+20AC is above the maximum of U+00FF set by this property.
373          * </ul>
374          *
375          * @param insideAttributeValue the context within an HTML document - <code>true</code> if inside an attribute value or <code>false</code> if outside an attribute value.
376          * @return the maximum unicode code point of an <a HREF="CharacterReference.html#Unterminated">unterminated</a> <a HREF="NumericCharacterReference.html#DecimalCharacterReference">decimal character reference</a> which is to be recognised in the specified context.
377          * @see #setUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue, int maxCodePoint)
378          */

379         public int getUnterminatedDecimalCharacterReferenceMaxCodePoint(final boolean insideAttributeValue) {
380             return getUnterminatedCharacterReferenceSettings(insideAttributeValue).decimalCharacterReferenceMaxCodePoint;
381         }
382
383         /**
384          * Sets the maximum unicode code point of an <a HREF="CharacterReference.html#Unterminated">unterminated</a>
385          * <a HREF="NumericCharacterReference.html#DecimalCharacterReference">decimal character reference</a> which is to be recognised in the specified context.
386          * <p>
387          * See {@link #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)} for the documentation of this property.
388          *
389          * @param insideAttributeValue the context within an HTML document - <code>true</code> if inside an attribute value or <code>false</code> if outside an attribute value.
390          * @param maxCodePoint the maximum unicode code point.
391          */

392         public void setUnterminatedDecimalCharacterReferenceMaxCodePoint(final boolean insideAttributeValue, final int maxCodePoint) {
393             getUnterminatedCharacterReferenceSettings(insideAttributeValue).decimalCharacterReferenceMaxCodePoint=maxCodePoint;
394         }
395
396         /**
397          * Returns the maximum unicode code point of an <a HREF="CharacterReference.html#Unterminated">unterminated</a>
398          * <a HREF="NumericCharacterReference.html#HexadecimalCharacterReference">hexadecimal character reference</a> which is to be recognised in the specified context.
399          * <p>
400          * For example, if <code>getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(true)</code> had the hypothetical value <code>0xFF</code> (U+00FF)
401          * in the {@linkplain Config#CurrentCompatibilityMode current compatibility mode}, then:
402          * <ul>
403          * <li>{@link CharacterReference#decode(CharSequence,boolean) CharacterReference.decode("&amp;#x3e",true)}
404          * returns "<code>&gt;</code>".<br />
405          * The string is recognised as the numeric character reference <code>&amp;#x3e;</code>
406          * despite the fact that it is <a HREF="CharacterReference.html#Unterminated">unterminated</a>,
407          * because its unicode code point U+003E is below the maximum of U+00FF set by this property.
408          * <li>{@link CharacterReference#decode(CharSequence,boolean) CharacterReference.decode("&amp;#x20ac",true)}
409          * returns "<code>&amp;#x20ac</code>".<br />
410          * The string is not recognised as the numeric character reference <code>&amp;#20ac;</code>
411          * because it is <a HREF="CharacterReference.html#Unterminated">unterminated</a>
412          * and its unicode code point U+20AC is above the maximum of U+00FF set by this property.
413          * </ul>
414          *
415          * @param insideAttributeValue the context within an HTML document - <code>true</code> if inside an attribute value or <code>false</code> if outside an attribute value.
416          * @return the maximum unicode code point of an <a HREF="CharacterReference.html#Unterminated">unterminated</a> <a HREF="NumericCharacterReference.html#HexadecimalCharacterReference">hexadecimal character reference</a> which is to be recognised in the specified context.
417          * @see #setUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue, int maxCodePoint)
418          */

419         public int getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(final boolean insideAttributeValue) {
420             return getUnterminatedCharacterReferenceSettings(insideAttributeValue).hexadecimalCharacterReferenceMaxCodePoint;
421         }
422
423         /**
424          * Sets the maximum unicode code point of an <a HREF="CharacterReference.html#Unterminated">unterminated</a>
425          * <a HREF="NumericCharacterReference.html#HexadecimalCharacterReference">headecimal character reference</a> which is to be recognised in the specified context.
426          * <p>
427          * See {@link #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)} for the documentation of this property.
428          *
429          * @param insideAttributeValue the context within an HTML document - <code>true</code> if inside an attribute value or <code>false</code> if outside an attribute value.
430          * @param maxCodePoint the maximum unicode code point.
431          */

432         public void setUnterminatedHexadecimalCharacterReferenceMaxCodePoint(final boolean insideAttributeValue, final int maxCodePoint) {
433             getUnterminatedCharacterReferenceSettings(insideAttributeValue).hexadecimalCharacterReferenceMaxCodePoint=maxCodePoint;
434         }
435
436         /**
437          * Returns a string representation of this object useful for debugging purposes.
438          * @return a string representation of this object useful for debugging purposes.
439          */

440         public String JavaDoc getDebugInfo() {
441             return "Form field name case insensitive: "+formFieldNameCaseInsensitive
442                 +"\nMaximum codepoints in unterminated character references:"
443                 +"\n Inside attribute values:"
444                 +unterminatedCharacterReferenceSettingsInsideAttributeValue
445                 +"\n Outside attribute values:"
446                 +unterminatedCharacterReferenceSettingsOutsideAttributeValue;
447         }
448     
449         /**
450          * Returns the {@linkplain #getName() name} of this compatibility mode.
451          * @return the {@linkplain #getName() name} of this compatibility mode.
452          */

453         public String JavaDoc toString() {
454             return getName();
455         }
456
457         UnterminatedCharacterReferenceSettings getUnterminatedCharacterReferenceSettings(final boolean insideAttributeValue) {
458             return insideAttributeValue ? unterminatedCharacterReferenceSettingsInsideAttributeValue : unterminatedCharacterReferenceSettingsOutsideAttributeValue;
459         }
460     }
461 }
462
Popular Tags