本文整理汇总了Java中com.sun.org.apache.xerces.internal.util.XMLChar.isLowSurrogate方法的典型用法代码示例。如果您正苦于以下问题:Java XMLChar.isLowSurrogate方法的具体用法?Java XMLChar.isLowSurrogate怎么用?Java XMLChar.isLowSurrogate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xerces.internal.util.XMLChar
的用法示例。
在下文中一共展示了XMLChar.isLowSurrogate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanSurrogates
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans surrogates and append them to the specified buffer.
* <p>
* <strong>Note:</strong> This assumes the current char has already been
* identified as a high surrogate.
*
* @param buf The StringBuffer to append the read surrogates to.
* @return True if it succeeded.
*/
protected boolean scanSurrogates(XMLStringBuffer buf)
throws IOException, XNIException {
int high = fEntityScanner.scanChar();
int low = fEntityScanner.peekChar();
if (!XMLChar.isLowSurrogate(low)) {
reportFatalError("InvalidCharInContent",
new Object[] {Integer.toString(high, 16)});
return false;
}
fEntityScanner.scanChar();
// convert surrogates to supplemental character
int c = XMLChar.supplemental((char)high, (char)low);
// supplemental character must be a valid XML character
if (isInvalid(c)) {
reportFatalError("InvalidCharInContent",
new Object[]{Integer.toString(c, 16)});
return false;
}
// fill in the buffer
buf.append((char)high);
buf.append((char)low);
return true;
}
示例2: surrogates
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
protected final void surrogates(int high, int low) throws IOException{
if (XMLChar.isHighSurrogate(high)) {
if (!XMLChar.isLowSurrogate(low)) {
//Invalid XML
fatalError("The character '"+(char)low+"' is an invalid XML character");
}
else {
int supplemental = XMLChar.supplemental((char)high, (char)low);
if (!XML11Char.isXML11Valid(supplemental)) {
//Invalid XML
fatalError("The character '"+(char)supplemental+"' is an invalid XML character");
}
else {
if (content().inCData ) {
_printer.printText("]]>&#x");
_printer.printText(Integer.toHexString(supplemental));
_printer.printText(";<![CDATA[");
}
else {
printHex(supplemental);
}
}
}
} else {
fatalError("The character '"+(char)high+"' is an invalid XML character");
}
}
示例3: surrogates
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
protected void surrogates(int high, int low) throws IOException{
if (XMLChar.isHighSurrogate(high)) {
if (!XMLChar.isLowSurrogate(low)) {
//Invalid XML
fatalError("The character '"+(char)low+"' is an invalid XML character");
}
else {
int supplemental = XMLChar.supplemental((char)high, (char)low);
if (!XMLChar.isValid(supplemental)) {
//Invalid XML
fatalError("The character '"+(char)supplemental+"' is an invalid XML character");
}
else {
if (content().inCData ) {
_printer.printText("]]>&#x");
_printer.printText(Integer.toHexString(supplemental));
_printer.printText(";<![CDATA[");
}
else {
printHex(supplemental);
}
}
}
} else {
fatalError("The character '"+(char)high+"' is an invalid XML character");
}
}
示例4: scanSurrogates
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans surrogates and append them to the specified buffer.
* <p>
* <strong>Note:</strong> This assumes the current char has already been
* identified as a high surrogate.
*
* @param buf The StringBuffer to append the read surrogates to.
* @return True if it succeeded.
*/
protected boolean scanSurrogates(XMLStringBuffer buf)
throws IOException, XNIException {
int high = fEntityScanner.scanChar(null);
int low = fEntityScanner.peekChar();
if (!XMLChar.isLowSurrogate(low)) {
reportFatalError("InvalidCharInContent",
new Object[] {Integer.toString(high, 16)});
return false;
}
fEntityScanner.scanChar(null);
// convert surrogates to supplemental character
int c = XMLChar.supplemental((char)high, (char)low);
// supplemental character must be a valid XML character
if (isInvalid(c)) {
reportFatalError("InvalidCharInContent",
new Object[]{Integer.toString(c, 16)});
return false;
}
// fill in the buffer
buf.append((char)high);
buf.append((char)low);
return true;
}
示例5: surrogates
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
protected final void surrogates(int high, int low, boolean inContent) throws IOException{
if (XMLChar.isHighSurrogate(high)) {
if (!XMLChar.isLowSurrogate(low)) {
//Invalid XML
fatalError("The character '"+(char)low+"' is an invalid XML character");
}
else {
int supplemental = XMLChar.supplemental((char)high, (char)low);
if (!XML11Char.isXML11Valid(supplemental)) {
//Invalid XML
fatalError("The character '"+(char)supplemental+"' is an invalid XML character");
}
else {
if (inContent && content().inCData) {
_printer.printText("]]>&#x");
_printer.printText(Integer.toHexString(supplemental));
_printer.printText(";<![CDATA[");
}
else {
printHex(supplemental);
}
}
}
}
else {
fatalError("The character '"+(char)high+"' is an invalid XML character");
}
}
示例6: surrogates
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
protected void surrogates(int high, int low, boolean inContent) throws IOException{
if (XMLChar.isHighSurrogate(high)) {
if (!XMLChar.isLowSurrogate(low)) {
//Invalid XML
fatalError("The character '"+(char)low+"' is an invalid XML character");
}
else {
int supplemental = XMLChar.supplemental((char)high, (char)low);
if (!XMLChar.isValid(supplemental)) {
//Invalid XML
fatalError("The character '"+(char)supplemental+"' is an invalid XML character");
}
else {
if (inContent && content().inCData) {
_printer.printText("]]>&#x");
_printer.printText(Integer.toHexString(supplemental));
_printer.printText(";<![CDATA[");
}
else {
printHex(supplemental);
}
}
}
} else {
fatalError("The character '"+(char)high+"' is an invalid XML character");
}
}
示例7: write
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
public void write(int c) throws IOException {
// Check in we are encoding at high and low surrogates
if (lastUTF16CodePoint != 0) {
final int uc =
(((lastUTF16CodePoint & 0x3ff) << 10) | (c & 0x3ff)) + 0x10000;
if (uc < 0 || uc >= 0x200000) {
throw new IOException("Atttempting to write invalid Unicode code point '" + uc + "'");
}
out.write(0xF0 | (uc >> 18));
out.write(0x80 | ((uc >> 12) & 0x3F));
out.write(0x80 | ((uc >> 6) & 0x3F));
out.write(0x80 | (uc & 0x3F));
lastUTF16CodePoint = 0;
return;
}
// Otherwise, encode char as defined in UTF-8
if (c < 0x80) {
// 1 byte, 7 bits
out.write((int) c);
}
else if (c < 0x800) {
// 2 bytes, 11 bits
out.write(0xC0 | (c >> 6)); // first 5
out.write(0x80 | (c & 0x3F)); // second 6
}
else if (c <= '\uFFFF') {
if (!XMLChar.isHighSurrogate(c) && !XMLChar.isLowSurrogate(c)) {
// 3 bytes, 16 bits
out.write(0xE0 | (c >> 12)); // first 4
out.write(0x80 | ((c >> 6) & 0x3F)); // second 6
out.write(0x80 | (c & 0x3F)); // third 6
}
else {
lastUTF16CodePoint = c;
}
}
}
示例8: write
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
public void write(int c) throws IOException {
// Check in we are encoding at high and low surrogates
if (lastUTF16CodePoint != 0) {
final int uc =
(((lastUTF16CodePoint & 0x3ff) << 10) | (c & 0x3ff)) + 0x10000;
if (uc < 0 || uc >= 0x200000) {
throw new IOException("Atttempting to write invalid Unicode code point '" + uc + "'");
}
out.write(0xF0 | (uc >> 18));
out.write(0x80 | ((uc >> 12) & 0x3F));
out.write(0x80 | ((uc >> 6) & 0x3F));
out.write(0x80 | (uc & 0x3F));
lastUTF16CodePoint = 0;
return;
}
// Otherwise, encode char as defined in UTF-8
if (c < 0x80) {
// 1 byte, 7 bits
out.write(c);
}
else if (c < 0x800) {
// 2 bytes, 11 bits
out.write(0xC0 | (c >> 6)); // first 5
out.write(0x80 | (c & 0x3F)); // second 6
}
else if (c <= '\uFFFF') {
if (!XMLChar.isHighSurrogate(c) && !XMLChar.isLowSurrogate(c)) {
// 3 bytes, 16 bits
out.write(0xE0 | (c >> 12)); // first 4
out.write(0x80 | ((c >> 6) & 0x3F)); // second 6
out.write(0x80 | (c & 0x3F)); // third 6
}
else {
lastUTF16CodePoint = c;
}
}
}