📄 config.java
字号:
* The three types of character reference are:
* <ul>
* <li>{@linkplain CharacterEntityReference Character entity reference}
* <li><a href="NumericCharacterReference.html#DecimalCharacterReference">Decimal character reference</a>
* <li><a href="NumericCharacterReference.html#HexadecimalCharacterReference">Hexadecimal character reference</a>
* </ul>
* <p>
* The two types of contexts used in this library are:
* <ul>
* <li>Inside an attribute value
* <li>Outside an attribute value
* </ul>
*/
static class UnterminatedCharacterReferenceSettings {
// use volatile fields to make them thread safe
public volatile int characterEntityReferenceMaxCodePoint;
public volatile int decimalCharacterReferenceMaxCodePoint;
public volatile int hexadecimalCharacterReferenceMaxCodePoint;
public static UnterminatedCharacterReferenceSettings ACCEPT_ALL=new UnterminatedCharacterReferenceSettings(CompatibilityMode.CODE_POINTS_ALL,CompatibilityMode.CODE_POINTS_ALL,CompatibilityMode.CODE_POINTS_ALL);
public UnterminatedCharacterReferenceSettings() {
this(CompatibilityMode.CODE_POINTS_NONE,CompatibilityMode.CODE_POINTS_NONE,CompatibilityMode.CODE_POINTS_NONE);
}
public UnterminatedCharacterReferenceSettings(final int characterEntityReferenceMaxCodePoint, final int decimalCharacterReferenceMaxCodePoint, final int hexadecimalCharacterReferenceMaxCodePoint) {
this.characterEntityReferenceMaxCodePoint=characterEntityReferenceMaxCodePoint;
this.decimalCharacterReferenceMaxCodePoint=decimalCharacterReferenceMaxCodePoint;
this.hexadecimalCharacterReferenceMaxCodePoint=hexadecimalCharacterReferenceMaxCodePoint;
}
public String toString() {
return Config.NewLine+" Character entity reference: "+getDescription(characterEntityReferenceMaxCodePoint)
+Config.NewLine+" Decimal character reference: "+getDescription(decimalCharacterReferenceMaxCodePoint)
+Config.NewLine+" Haxadecimal character reference: "+getDescription(hexadecimalCharacterReferenceMaxCodePoint);
}
private String getDescription(final int codePoint) {
if (codePoint==CompatibilityMode.CODE_POINTS_NONE) return "None";
if (codePoint==CompatibilityMode.CODE_POINTS_ALL) return "All";
return "0x"+Integer.toString(codePoint,16);
}
}
/**
* Represents a set of configuration parameters that relate to
* <a target="_blank" href="http://www.w3.org/TR/html401/conform.html#didx-user_agent">user agent</a> compatibility issues.
* <p>
* The predefined compatibility modes {@link #IE}, {@link #MOZILLA}, {@link #OPERA} and {@link #XHTML} provide an easy means of
* ensuring the library interprets the markup in a way consistent with some of the most commonly used browsers,
* at least in relation to the behaviour described by the properties in this class.
* <p>
* The properties of any <code>CompatibilityMode</code> object can be modified individually, including those in
* the predefined instances as well as newly constructed instances.
* Take note however that modifying the properties of the predefined instances has a global affect.
* <p>
* The currently active compatibility mode is stored in the static {@link Config#CurrentCompatibilityMode} property.
* <p>
*/
public static final class CompatibilityMode {
private String name;
private volatile boolean formFieldNameCaseInsensitive;
volatile UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettingsInsideAttributeValue;
volatile UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettingsOutsideAttributeValue;
/**
* Indicates the recognition of all unicode code points.
* <p>
* This value is used in properties which specify a maximum unicode code point to be recognised by the parser.
*
* @see #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean insideAttributeValue)
* @see #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)
* @see #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)
*/
public static final int CODE_POINTS_ALL=Character.MAX_CODE_POINT; // 0x10FFFF (decimal 1114111)
/**
* Indicates the recognition of no unicode code points.
* <p>
* This value is used in properties which specify a maximum unicode code point to be recognised by the parser.
*
* @see #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean insideAttributeValue)
* @see #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)
* @see #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean insideAttributeValue)
*/
public static final int CODE_POINTS_NONE=CharacterReference.INVALID_CODE_POINT;
/**
* <a target="_blank" href="http://www.microsoft.com/windows/ie/">Microsoft Internet Explorer</a> compatibility mode.
* <p>
* <code>{@link #getName() Name} = IE</code><br />
* <code>{@link #isFormFieldNameCaseInsensitive() FormFieldNameCaseInsensitive} = true</code><br />
* <table cellspacing="0" cellpadding="0">
* <tr><th>Recognition of unterminated character references:<th><th align="center"> (inside attribute) <th align="center"> (outside attribute)
* <tr><td>{@link #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean) UnterminatedCharacterEntityReferenceMaxCodePoint}<td><code> =</code><td align="center">U+00FF<td align="center">U+00FF
* <tr><td>{@link #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedDecimalCharacterReferenceMaxCodePoint}<td><code> =</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
* <tr><td>{@link #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedHexadecimalCharacterReferenceMaxCodePoint}<td><code> =</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_NONE None}
* </table>
*/
public static final CompatibilityMode IE=new CompatibilityMode("IE",true,
new UnterminatedCharacterReferenceSettings(0xFF, CODE_POINTS_ALL, CODE_POINTS_ALL), // inside attributes
new UnterminatedCharacterReferenceSettings(0xFF, CODE_POINTS_ALL, CODE_POINTS_NONE) // outside attributes
);
/**
* <a target="_blank" href="http://www.mozilla.org/products/mozilla1.x/">Mozilla</a> /
* <a target="_blank" href="http://www.mozilla.org/products/firefox/">Firefox</a> /
* <a target="_blank" href="http://browser.netscape.com/">Netscape</a> compatibility mode.
* <p>
* <code>{@link #getName() Name} = Mozilla</code><br />
* <code>{@link #isFormFieldNameCaseInsensitive() FormFieldNameCaseInsensitive} = false</code><br />
* <table cellspacing="0" cellpadding="0">
* <tr><th>Recognition of unterminated character references:<th><th align="center"> (inside attribute) <th align="center"> (outside attribute)
* <tr><td>{@link #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean) UnterminatedCharacterEntityReferenceMaxCodePoint}<td><code> =</code><td align="center">U+00FF<td align="center">{@linkplain #CODE_POINTS_ALL All}
* <tr><td>{@link #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedDecimalCharacterReferenceMaxCodePoint}<td><code> =</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
* <tr><td>{@link #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedHexadecimalCharacterReferenceMaxCodePoint}<td><code> =</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
* </table>
*/
public static final CompatibilityMode MOZILLA=new CompatibilityMode("Mozilla",false,
new UnterminatedCharacterReferenceSettings(0xFF, CODE_POINTS_ALL, CODE_POINTS_ALL), // inside attributes
new UnterminatedCharacterReferenceSettings(CODE_POINTS_ALL, CODE_POINTS_ALL, CODE_POINTS_ALL) // outside attributes
);
/**
* Opera compatibility mode.
* <p>
* <code>{@link #getName() Name} = Opera</code><br />
* <code>{@link #isFormFieldNameCaseInsensitive() FormFieldNameCaseInsensitive} = true</code><br />
* <table cellspacing="0" cellpadding="0">
* <tr><th>Recognition of unterminated character references:<th><th align="center"> (inside attribute) <th align="center"> (outside attribute)
* <tr><td>{@link #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean) UnterminatedCharacterEntityReferenceMaxCodePoint}<td><code> =</code><td align="center">U+003E<td align="center">{@linkplain #CODE_POINTS_ALL All}
* <tr><td>{@link #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedDecimalCharacterReferenceMaxCodePoint}<td><code> =</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
* <tr><td>{@link #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedHexadecimalCharacterReferenceMaxCodePoint}<td><code> =</code><td align="center">{@linkplain #CODE_POINTS_ALL All}<td align="center">{@linkplain #CODE_POINTS_ALL All}
* </table>
*/
public static final CompatibilityMode OPERA=new CompatibilityMode("Opera",true,
new UnterminatedCharacterReferenceSettings(0x3E, CODE_POINTS_ALL, CODE_POINTS_ALL), // inside attributes
new UnterminatedCharacterReferenceSettings(CODE_POINTS_ALL, CODE_POINTS_ALL, CODE_POINTS_ALL) // outside attributes
);
/**
* <a target="_blank" href="http://www.w3.org/TR/xhtml1/#xhtml">XHTML</a> compatibility mode.
* <p>
* <code>{@link #getName() Name} = XHTML</code><br />
* <code>{@link #isFormFieldNameCaseInsensitive() FormFieldNameCaseInsensitive} = false</code><br />
* <table cellspacing="0" cellpadding="0">
* <tr><th>Recognition of unterminated character references:<th><th align="center"> (inside attribute) <th align="center"> (outside attribute)
* <tr><td>{@link #getUnterminatedCharacterEntityReferenceMaxCodePoint(boolean) UnterminatedCharacterEntityReferenceMaxCodePoint}<td><code> =</code><td align="center">{@linkplain #CODE_POINTS_NONE None}<td align="center">{@linkplain #CODE_POINTS_NONE None}
* <tr><td>{@link #getUnterminatedDecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedDecimalCharacterReferenceMaxCodePoint}<td><code> =</code><td align="center">{@linkplain #CODE_POINTS_NONE None}<td align="center">{@linkplain #CODE_POINTS_NONE None}
* <tr><td>{@link #getUnterminatedHexadecimalCharacterReferenceMaxCodePoint(boolean) UnterminatedHexadecimalCharacterReferenceMaxCodePoint}<td><code> =</code><td align="center">{@linkplain #CODE_POINTS_NONE None}<td align="center">{@linkplain #CODE_POINTS_NONE None}
* </table>
*/
public static final CompatibilityMode XHTML=new CompatibilityMode("XHTML");
/**
* Constructs a new <code>CompatibilityMode</code> with the given {@linkplain #getName() name}.
* <p>
* All properties in the new instance are initially assigned their default values, which are the same as the strict
* rules of the {@link #XHTML} compatibility mode.
*
* @param name the {@linkplain #getName() name} of the new compatibility mode
*/
public CompatibilityMode(final String name) {
this(name,false,new UnterminatedCharacterReferenceSettings(),new UnterminatedCharacterReferenceSettings());
}
private CompatibilityMode(final String name, final boolean formFieldNameCaseInsensitive, final UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettingsInsideAttributeValue, final UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettingsOutsideAttributeValue) {
this.name=name;
this.formFieldNameCaseInsensitive=formFieldNameCaseInsensitive;
this.unterminatedCharacterReferenceSettingsInsideAttributeValue=unterminatedCharacterReferenceSettingsInsideAttributeValue;
this.unterminatedCharacterReferenceSettingsOutsideAttributeValue=unterminatedCharacterReferenceSettingsOutsideAttributeValue;
}
/**
* Returns the name of this compatibility mode.
* @return the name of this compatibility mode.
*/
public String getName() {
return name;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -