本文整理汇总了Java中com.sun.org.apache.xerces.internal.util.XMLChar.isHighSurrogate方法的典型用法代码示例。如果您正苦于以下问题:Java XMLChar.isHighSurrogate方法的具体用法?Java XMLChar.isHighSurrogate怎么用?Java XMLChar.isHighSurrogate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xerces.internal.util.XMLChar
的用法示例。
在下文中一共展示了XMLChar.isHighSurrogate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: skipDTD
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Skip the DTD if javax.xml.stream.supportDTD is false.
*
* @param supportDTD The value of the property javax.xml.stream.supportDTD.
* @return true if DTD is skipped, false otherwise.
* @throws java.io.IOException if i/o error occurs
*/
@Override
public boolean skipDTD(boolean supportDTD) throws IOException {
if (supportDTD)
return false;
fStringBuffer.clear();
while (fEntityScanner.scanData("]", fStringBuffer, 0)) {
int c = fEntityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
}
if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInDTD",
new Object[] { Integer.toHexString(c) });
fEntityScanner.scanChar(null);
}
}
}
fEntityScanner.fCurrentEntity.position--;
return true;
}
示例2: scanComment
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans a comment.
* <p>
* <pre>
* [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
* </pre>
* <p>
* <strong>Note:</strong> Called after scanning past '<!--'
* <strong>Note:</strong> This method uses fString, anything in it
* at the time of calling is lost.
*
* @param text The buffer to fill in with the text.
*/
protected void scanComment(XMLStringBuffer text)
throws IOException, XNIException {
//System.out.println( "XMLScanner#scanComment# In Scan Comment" );
// text
// REVISIT: handle invalid character, eof
text.clear();
while (fEntityScanner.scanData("--", text)) {
int c = fEntityScanner.peekChar();
//System.out.println( "XMLScanner#scanComment#text.toString() == " + text.toString() );
//System.out.println( "XMLScanner#scanComment#c == " + c );
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(text);
}
if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInComment",
new Object[] { Integer.toHexString(c) });
fEntityScanner.scanChar();
}
}
}
if (!fEntityScanner.skipChar('>')) {
reportFatalError("DashDashInComment", null);
}
}
示例3: 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");
}
}
示例4: 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");
}
}
示例5: scanComment
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans a comment.
* <p>
* <pre>
* [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
* </pre>
* <p>
* <strong>Note:</strong> Called after scanning past '<!--'
* <strong>Note:</strong> This method uses fString, anything in it
* at the time of calling is lost.
*
* @param text The buffer to fill in with the text.
*/
protected void scanComment(XMLStringBuffer text)
throws IOException, XNIException {
//System.out.println( "XMLScanner#scanComment# In Scan Comment" );
// text
// REVISIT: handle invalid character, eof
text.clear();
while (fEntityScanner.scanData("--", text, 0)) {
int c = fEntityScanner.peekChar();
//System.out.println( "XMLScanner#scanComment#text.toString() == " + text.toString() );
//System.out.println( "XMLScanner#scanComment#c == " + c );
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(text);
}
else if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInComment",
new Object[] { Integer.toHexString(c) });
fEntityScanner.scanChar(NameType.COMMENT);
}
}
}
if (!fEntityScanner.skipChar('>', NameType.COMMENT)) {
reportFatalError("DashDashInComment", null);
}
}
示例6: 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");
}
}
示例7: 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");
}
}
示例8: scanPseudoAttribute
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans a pseudo attribute.
*
* @param scanningTextDecl True if scanning this pseudo-attribute for a
* TextDecl; false if scanning XMLDecl. This
* flag is needed to report the correct type of
* error.
* @param value The string to fill in with the attribute
* value.
*
* @return The name of the attribute
*
* <strong>Note:</strong> This method uses fStringBuffer2, anything in it
* at the time of calling is lost.
*/
public String scanPseudoAttribute(boolean scanningTextDecl,
XMLString value)
throws IOException, XNIException {
String name = scanPseudoAttributeName();
// XMLEntityManager.print(fEntityManager.getCurrentEntity());
if (name == null) {
reportFatalError("PseudoAttrNameExpected", null);
}
fEntityScanner.skipSpaces();
if (!fEntityScanner.skipChar('=')) {
reportFatalError(scanningTextDecl ? "EqRequiredInTextDecl"
: "EqRequiredInXMLDecl", new Object[]{name});
}
fEntityScanner.skipSpaces();
int quote = fEntityScanner.peekChar();
if (quote != '\'' && quote != '"') {
reportFatalError(scanningTextDecl ? "QuoteRequiredInTextDecl"
: "QuoteRequiredInXMLDecl" , new Object[]{name});
}
fEntityScanner.scanChar();
int c = fEntityScanner.scanLiteral(quote, value);
if (c != quote) {
fStringBuffer2.clear();
do {
fStringBuffer2.append(value);
if (c != -1) {
if (c == '&' || c == '%' || c == '<' || c == ']') {
fStringBuffer2.append((char)fEntityScanner.scanChar());
} else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer2);
} else if (isInvalidLiteral(c)) {
String key = scanningTextDecl
? "InvalidCharInTextDecl" : "InvalidCharInXMLDecl";
reportFatalError(key,
new Object[] {Integer.toString(c, 16)});
fEntityScanner.scanChar();
}
}
c = fEntityScanner.scanLiteral(quote, value);
} while (c != quote);
fStringBuffer2.append(value);
value.setValues(fStringBuffer2);
}
if (!fEntityScanner.skipChar(quote)) {
reportFatalError(scanningTextDecl ? "CloseQuoteMissingInTextDecl"
: "CloseQuoteMissingInXMLDecl",
new Object[]{name});
}
// return
return name;
}
示例9: scanPIData
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans a processing data. This is needed to handle the situation
* where a document starts with a processing instruction whose
* target name <em>starts with</em> "xml". (e.g. xmlfoo)
*
* This method would always read the whole data. We have while loop and data is buffered
* until delimeter is encountered.
*
* @param target The PI target
* @param data The string to fill in with the data
*/
//CHANGED:
//Earlier:This method uses the fStringBuffer and later buffer values are set to
//the supplied XMLString....
//Now: Changed the signature of this function to pass XMLStringBuffer.. and data would
//be appended to that buffer
protected void scanPIData(String target, XMLStringBuffer data)
throws IOException, XNIException {
// check target
if (target.length() == 3) {
char c0 = Character.toLowerCase(target.charAt(0));
char c1 = Character.toLowerCase(target.charAt(1));
char c2 = Character.toLowerCase(target.charAt(2));
if (c0 == 'x' && c1 == 'm' && c2 == 'l') {
reportFatalError("ReservedPITarget", null);
}
}
// spaces
if (!fEntityScanner.skipSpaces()) {
if (fEntityScanner.skipString("?>")) {
// we found the end, there is no data just return
return;
} else {
// if there is data there should be some space
reportFatalError("SpaceRequiredInPI", null);
}
}
// since scanData appends the parsed data to the buffer passed
// a while loop would append the whole of parsed data to the buffer(data:XMLStringBuffer)
//until all of the data is buffered.
if (fEntityScanner.scanData("?>", data)) {
do {
int c = fEntityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(data);
} else if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInPI",
new Object[]{Integer.toHexString(c)});
fEntityScanner.scanChar();
}
}
} while (fEntityScanner.scanData("?>", data));
}
}
示例10: 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;
}
}
}
示例11: scanPseudoAttribute
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans a pseudo attribute.
*
* @param scanningTextDecl True if scanning this pseudo-attribute for a
* TextDecl; false if scanning XMLDecl. This
* flag is needed to report the correct type of
* error.
* @param value The string to fill in with the attribute
* value.
*
* @return The name of the attribute
*
* <strong>Note:</strong> This method uses fStringBuffer2, anything in it
* at the time of calling is lost.
*/
protected String scanPseudoAttribute(boolean scanningTextDecl,
XMLString value)
throws IOException, XNIException {
String name = scanPseudoAttributeName();
// XMLEntityManager.print(fEntityManager.getCurrentEntity());
if (name == null) {
reportFatalError("PseudoAttrNameExpected", null);
}
fEntityScanner.skipSpaces();
if (!fEntityScanner.skipChar('=', null)) {
reportFatalError(scanningTextDecl ? "EqRequiredInTextDecl"
: "EqRequiredInXMLDecl", new Object[]{name});
}
fEntityScanner.skipSpaces();
int quote = fEntityScanner.peekChar();
if (quote != '\'' && quote != '"') {
reportFatalError(scanningTextDecl ? "QuoteRequiredInTextDecl"
: "QuoteRequiredInXMLDecl" , new Object[]{name});
}
fEntityScanner.scanChar(NameType.ATTRIBUTE);
int c = fEntityScanner.scanLiteral(quote, value, false);
if (c != quote) {
fStringBuffer2.clear();
do {
fStringBuffer2.append(value);
if (c != -1) {
if (c == '&' || c == '%' || c == '<' || c == ']') {
fStringBuffer2.append((char)fEntityScanner.scanChar(NameType.ATTRIBUTE));
} else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer2);
} else if (isInvalidLiteral(c)) {
String key = scanningTextDecl
? "InvalidCharInTextDecl" : "InvalidCharInXMLDecl";
reportFatalError(key,
new Object[] {Integer.toString(c, 16)});
fEntityScanner.scanChar(null);
}
}
c = fEntityScanner.scanLiteral(quote, value, false);
} while (c != quote);
fStringBuffer2.append(value);
value.setValues(fStringBuffer2);
}
if (!fEntityScanner.skipChar(quote, null)) {
reportFatalError(scanningTextDecl ? "CloseQuoteMissingInTextDecl"
: "CloseQuoteMissingInXMLDecl",
new Object[]{name});
}
// return
return name;
}
示例12: scanPIData
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans a processing data. This is needed to handle the situation
* where a document starts with a processing instruction whose
* target name <em>starts with</em> "xml". (e.g. xmlfoo)
*
* This method would always read the whole data. We have while loop and data is buffered
* until delimeter is encountered.
*
* @param target The PI target
* @param data The string to fill in with the data
*/
//CHANGED:
//Earlier:This method uses the fStringBuffer and later buffer values are set to
//the supplied XMLString....
//Now: Changed the signature of this function to pass XMLStringBuffer.. and data would
//be appended to that buffer
protected void scanPIData(String target, XMLStringBuffer data)
throws IOException, XNIException {
// check target
if (target.length() == 3) {
char c0 = Character.toLowerCase(target.charAt(0));
char c1 = Character.toLowerCase(target.charAt(1));
char c2 = Character.toLowerCase(target.charAt(2));
if (c0 == 'x' && c1 == 'm' && c2 == 'l') {
reportFatalError("ReservedPITarget", null);
}
}
// spaces
if (!fEntityScanner.skipSpaces()) {
if (fEntityScanner.skipString("?>")) {
// we found the end, there is no data just return
return;
} else {
// if there is data there should be some space
reportFatalError("SpaceRequiredInPI", null);
}
}
// since scanData appends the parsed data to the buffer passed
// a while loop would append the whole of parsed data to the buffer(data:XMLStringBuffer)
//until all of the data is buffered.
if (fEntityScanner.scanData("?>", data, 0)) {
do {
int c = fEntityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(data);
} else if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInPI",
new Object[]{Integer.toHexString(c)});
fEntityScanner.scanChar(null);
}
}
} while (fEntityScanner.scanData("?>", data, 0));
}
}
示例13: scanCDATASection
import com.sun.org.apache.xerces.internal.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans a CDATA section.
* <p>
* <strong>Note:</strong> This method uses the fTempString and
* fStringBuffer variables.
*
* @param complete True if the CDATA section is to be scanned
* completely.
*
* @return True if CDATA is completely scanned.
*/
//CHANGED:
protected boolean scanCDATASection(XMLStringBuffer contentBuffer, boolean complete)
throws IOException, XNIException {
// call handler
if (fDocumentHandler != null) {
//fDocumentHandler.startCDATA(null);
}
while (true) {
//scanData will fill the contentBuffer
if (!fEntityScanner.scanData("]]>", contentBuffer, fChunkSize)) {
fInCData = false;
fCDataEnd = true;
fMarkupDepth--;
break ;
} else {
int c = fEntityScanner.peekChar();
if (c != -1 && isInvalidLiteral(c)) {
if (XMLChar.isHighSurrogate(c)) {
//contentBuffer.clear();
//scan surrogates if any....
scanSurrogates(contentBuffer);
} else {
reportFatalError("InvalidCharInCDSect",
new Object[]{Integer.toString(c,16)});
fEntityScanner.scanChar(null);
}
} else {
//CData partially returned due to the size limit
break;
}
//by this time we have also read surrogate contents if any...
if (fDocumentHandler != null) {
//fDocumentHandler.characters(contentBuffer, null);
}
}
}
return true;
}
示例14: 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;
}
}
}