📄 characterentityreference.java
字号:
NAME_TO_CODE_POINT_MAP.put("crarr",new Integer(_crarr));
NAME_TO_CODE_POINT_MAP.put("lArr",new Integer(_lArr));
NAME_TO_CODE_POINT_MAP.put("uArr",new Integer(_uArr));
NAME_TO_CODE_POINT_MAP.put("rArr",new Integer(_rArr));
NAME_TO_CODE_POINT_MAP.put("dArr",new Integer(_dArr));
NAME_TO_CODE_POINT_MAP.put("hArr",new Integer(_hArr));
NAME_TO_CODE_POINT_MAP.put("forall",new Integer(_forall));
NAME_TO_CODE_POINT_MAP.put("part",new Integer(_part));
NAME_TO_CODE_POINT_MAP.put("exist",new Integer(_exist));
NAME_TO_CODE_POINT_MAP.put("empty",new Integer(_empty));
NAME_TO_CODE_POINT_MAP.put("nabla",new Integer(_nabla));
NAME_TO_CODE_POINT_MAP.put("isin",new Integer(_isin));
NAME_TO_CODE_POINT_MAP.put("notin",new Integer(_notin));
NAME_TO_CODE_POINT_MAP.put("ni",new Integer(_ni));
NAME_TO_CODE_POINT_MAP.put("prod",new Integer(_prod));
NAME_TO_CODE_POINT_MAP.put("sum",new Integer(_sum));
NAME_TO_CODE_POINT_MAP.put("minus",new Integer(_minus));
NAME_TO_CODE_POINT_MAP.put("lowast",new Integer(_lowast));
NAME_TO_CODE_POINT_MAP.put("radic",new Integer(_radic));
NAME_TO_CODE_POINT_MAP.put("prop",new Integer(_prop));
NAME_TO_CODE_POINT_MAP.put("infin",new Integer(_infin));
NAME_TO_CODE_POINT_MAP.put("ang",new Integer(_ang));
NAME_TO_CODE_POINT_MAP.put("and",new Integer(_and));
NAME_TO_CODE_POINT_MAP.put("or",new Integer(_or));
NAME_TO_CODE_POINT_MAP.put("cap",new Integer(_cap));
NAME_TO_CODE_POINT_MAP.put("cup",new Integer(_cup));
NAME_TO_CODE_POINT_MAP.put("int",new Integer(_int));
NAME_TO_CODE_POINT_MAP.put("there4",new Integer(_there4));
NAME_TO_CODE_POINT_MAP.put("sim",new Integer(_sim));
NAME_TO_CODE_POINT_MAP.put("cong",new Integer(_cong));
NAME_TO_CODE_POINT_MAP.put("asymp",new Integer(_asymp));
NAME_TO_CODE_POINT_MAP.put("ne",new Integer(_ne));
NAME_TO_CODE_POINT_MAP.put("equiv",new Integer(_equiv));
NAME_TO_CODE_POINT_MAP.put("le",new Integer(_le));
NAME_TO_CODE_POINT_MAP.put("ge",new Integer(_ge));
NAME_TO_CODE_POINT_MAP.put("sub",new Integer(_sub));
NAME_TO_CODE_POINT_MAP.put("sup",new Integer(_sup));
NAME_TO_CODE_POINT_MAP.put("nsub",new Integer(_nsub));
NAME_TO_CODE_POINT_MAP.put("sube",new Integer(_sube));
NAME_TO_CODE_POINT_MAP.put("supe",new Integer(_supe));
NAME_TO_CODE_POINT_MAP.put("oplus",new Integer(_oplus));
NAME_TO_CODE_POINT_MAP.put("otimes",new Integer(_otimes));
NAME_TO_CODE_POINT_MAP.put("perp",new Integer(_perp));
NAME_TO_CODE_POINT_MAP.put("sdot",new Integer(_sdot));
NAME_TO_CODE_POINT_MAP.put("lceil",new Integer(_lceil));
NAME_TO_CODE_POINT_MAP.put("rceil",new Integer(_rceil));
NAME_TO_CODE_POINT_MAP.put("lfloor",new Integer(_lfloor));
NAME_TO_CODE_POINT_MAP.put("rfloor",new Integer(_rfloor));
NAME_TO_CODE_POINT_MAP.put("lang",new Integer(_lang));
NAME_TO_CODE_POINT_MAP.put("rang",new Integer(_rang));
NAME_TO_CODE_POINT_MAP.put("loz",new Integer(_loz));
NAME_TO_CODE_POINT_MAP.put("spades",new Integer(_spades));
NAME_TO_CODE_POINT_MAP.put("clubs",new Integer(_clubs));
NAME_TO_CODE_POINT_MAP.put("hearts",new Integer(_hearts));
NAME_TO_CODE_POINT_MAP.put("diams",new Integer(_diams));
NAME_TO_CODE_POINT_MAP.put("quot",new Integer(_quot));
NAME_TO_CODE_POINT_MAP.put("amp",new Integer(_amp));
NAME_TO_CODE_POINT_MAP.put("lt",new Integer(_lt));
NAME_TO_CODE_POINT_MAP.put("gt",new Integer(_gt));
NAME_TO_CODE_POINT_MAP.put("OElig",new Integer(_OElig));
NAME_TO_CODE_POINT_MAP.put("oelig",new Integer(_oelig));
NAME_TO_CODE_POINT_MAP.put("Scaron",new Integer(_Scaron));
NAME_TO_CODE_POINT_MAP.put("scaron",new Integer(_scaron));
NAME_TO_CODE_POINT_MAP.put("Yuml",new Integer(_Yuml));
NAME_TO_CODE_POINT_MAP.put("circ",new Integer(_circ));
NAME_TO_CODE_POINT_MAP.put("tilde",new Integer(_tilde));
NAME_TO_CODE_POINT_MAP.put("ensp",new Integer(_ensp));
NAME_TO_CODE_POINT_MAP.put("emsp",new Integer(_emsp));
NAME_TO_CODE_POINT_MAP.put("thinsp",new Integer(_thinsp));
NAME_TO_CODE_POINT_MAP.put("zwnj",new Integer(_zwnj));
NAME_TO_CODE_POINT_MAP.put("zwj",new Integer(_zwj));
NAME_TO_CODE_POINT_MAP.put("lrm",new Integer(_lrm));
NAME_TO_CODE_POINT_MAP.put("rlm",new Integer(_rlm));
NAME_TO_CODE_POINT_MAP.put("ndash",new Integer(_ndash));
NAME_TO_CODE_POINT_MAP.put("mdash",new Integer(_mdash));
NAME_TO_CODE_POINT_MAP.put("lsquo",new Integer(_lsquo));
NAME_TO_CODE_POINT_MAP.put("rsquo",new Integer(_rsquo));
NAME_TO_CODE_POINT_MAP.put("sbquo",new Integer(_sbquo));
NAME_TO_CODE_POINT_MAP.put("ldquo",new Integer(_ldquo));
NAME_TO_CODE_POINT_MAP.put("rdquo",new Integer(_rdquo));
NAME_TO_CODE_POINT_MAP.put("bdquo",new Integer(_bdquo));
NAME_TO_CODE_POINT_MAP.put("dagger",new Integer(_dagger));
NAME_TO_CODE_POINT_MAP.put("Dagger",new Integer(_Dagger));
NAME_TO_CODE_POINT_MAP.put("permil",new Integer(_permil));
NAME_TO_CODE_POINT_MAP.put("lsaquo",new Integer(_lsaquo));
NAME_TO_CODE_POINT_MAP.put("rsaquo",new Integer(_rsaquo));
NAME_TO_CODE_POINT_MAP.put("euro",new Integer(_euro));
NAME_TO_CODE_POINT_MAP.put("apos",new Integer(_apos));
CODE_POINT_TO_NAME_MAP=new IntStringHashMap((int)(NAME_TO_CODE_POINT_MAP.size()/0.75F),1.0F);
for (Map.Entry<String,Integer> entry : NAME_TO_CODE_POINT_MAP.entrySet()) {
String name=entry.getKey();
if (MAX_NAME_LENGTH<name.length()) MAX_NAME_LENGTH=name.length();
CODE_POINT_TO_NAME_MAP.put(entry.getValue().intValue(),name);
}
MAX_ENTITY_REFERENCE_LENGTH=MAX_NAME_LENGTH+2; // '&'+name+';'
}
private CharacterEntityReference(final Source source, final int begin, final int end, final int codePoint) {
super(source,begin,end,codePoint);
name=getName(codePoint);
}
/**
* Returns the name of this character entity reference.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code>((CharacterEntityReference)CharacterReference.parse("&gt;")).getName()</code> returns "<code>gt</code>"</dd>
* </dl>
* @return the name of this character entity reference.
* @see #getName(int codePoint)
*/
public String getName() {
return name;
}
/**
* Returns the character entity reference name of the specified character.
* <p>
* Since all character entity references represent unicode <a target="_blank" href="http://www.unicode.org/glossary/#bmp_code_point">BMP</a> code points,
* the functionality of this method is identical to that of {@link #getName(int codePoint)}.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code>CharacterEntityReference.getName('>')</code> returns "<code>gt</code>"</dd>
* </dl>
* @return the character entity reference name of the specified character, or <code>null</code> if none exists.
*/
public static String getName(final char ch) {
return getName((int)ch);
}
/**
* Returns the character entity reference name of the specified unicode code point.
* <p>
* Since all character entity references represent unicode <a target="_blank" href="http://www.unicode.org/glossary/#bmp_code_point">BMP</a> code points,
* the functionality of this method is identical to that of {@link #getName(char ch)}.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code>CharacterEntityReference.getName(62)</code> returns "<code>gt</code>"</dd>
* </dl>
* @return the character entity reference name of the specified unicode code point, or <code>null</code> if none exists.
*/
public static String getName(final int codePoint) {
return CODE_POINT_TO_NAME_MAP.get(codePoint);
}
/**
* Returns the unicode code point of the specified character entity reference name.
* <p>
* If the string does not represent a valid character entity reference name, this method returns {@link #INVALID_CODE_POINT INVALID_CODE_POINT}.
* <p>
* Although character entity reference names are case sensitive, and in some cases differ from other entity references only by their case,
* some browsers also recognise them in a case-insensitive way.
* For this reason, all decoding methods in this library recognise character entity reference names even if they are in the wrong case.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code>CharacterEntityReference.getCodePointFromName("gt")</code> returns <code>62</code></dd>
* </dl>
* @return the unicode code point of the specified character entity reference name, or {@link #INVALID_CODE_POINT INVALID_CODE_POINT} if the string does not represent a valid character entity reference name.
*/
public static int getCodePointFromName(final String name) {
Integer codePoint=NAME_TO_CODE_POINT_MAP.get(name);
if (codePoint==null) {
// Most browsers recognise character entity references even if they have the wrong case, so check for this as well:
final String lowerCaseName=name.toLowerCase();
if (lowerCaseName!=name) codePoint=NAME_TO_CODE_POINT_MAP.get(lowerCaseName);
}
return (codePoint!=null) ? codePoint.intValue() : INVALID_CODE_POINT;
}
/**
* Returns the correct encoded form of this character entity reference.
* <p>
* Note that the returned string is not necessarily the same as the original source text used to create this object.
* This library recognises certain invalid forms of character references, as detailed in the {@link #decode(CharSequence) decode(String encodedString)} method.
* <p>
* To retrieve the original source text, use the {@link #toString() toString()} method instead.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code>CharacterReference.parse("&GT").getCharacterReferenceString()</code> returns "<code>&gt;</code>"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -