本文整理汇总了Java中org.apache.xerces.util.XMLChar.isHighSurrogate方法的典型用法代码示例。如果您正苦于以下问题:Java XMLChar.isHighSurrogate方法的具体用法?Java XMLChar.isHighSurrogate怎么用?Java XMLChar.isHighSurrogate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.util.XMLChar
的用法示例。
在下文中一共展示了XMLChar.isHighSurrogate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanComment
import org.apache.xerces.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 {
// text
// REVISIT: handle invalid character, eof
text.clear();
while (fEntityScanner.scanData("--", text)) {
int c = fEntityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(text);
}
else if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInComment",
new Object[] { Integer.toHexString(c) });
fEntityScanner.scanChar();
}
}
}
if (!fEntityScanner.skipChar('>')) {
reportFatalError("DashDashInComment", null);
}
}
示例2: surrogates
import org.apache.xerces.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");
}
}
示例3: surrogates
import org.apache.xerces.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");
}
}
示例4: scanPIData
import org.apache.xerces.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)
*
* <strong>Note:</strong> This method uses fStringBuffer, anything in it
* at the time of calling is lost.
*
* @param target The PI target
* @param data The string to fill in with the data
*/
protected void scanPIData(String target, XMLString 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
data.clear();
return;
}
else {
if(fNamespaces && fEntityScanner.peekChar() == ':') {
fEntityScanner.scanChar();
XMLStringBuffer colonName = new XMLStringBuffer(target);
colonName.append(':');
String str = fEntityScanner.scanName();
if (str != null)
colonName.append(str);
reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
fEntityScanner.skipSpaces();
} else {
// if there is data there should be some space
reportFatalError("SpaceRequiredInPI", null);
}
}
}
fStringBuffer.clear();
// data
if (fEntityScanner.scanData("?>", fStringBuffer)) {
do {
int c = fEntityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
}
else if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInPI",
new Object[]{Integer.toHexString(c)});
fEntityScanner.scanChar();
}
}
} while (fEntityScanner.scanData("?>", fStringBuffer));
}
data.setValues(fStringBuffer);
}
示例5: scanExternalID
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
* Scans External ID and return the public and system IDs.
*
* @param identifiers An array of size 2 to return the system id,
* and public id (in that order).
* @param optionalSystemId Specifies whether the system id is optional.
*
* <strong>Note:</strong> This method uses fString and fStringBuffer,
* anything in them at the time of calling is lost.
*/
protected void scanExternalID(String[] identifiers,
boolean optionalSystemId)
throws IOException, XNIException {
String systemId = null;
String publicId = null;
if (fEntityScanner.skipString("PUBLIC")) {
if (!fEntityScanner.skipSpaces()) {
reportFatalError("SpaceRequiredAfterPUBLIC", null);
}
scanPubidLiteral(fString);
publicId = fString.toString();
if (!fEntityScanner.skipSpaces() && !optionalSystemId) {
reportFatalError("SpaceRequiredBetweenPublicAndSystem", null);
}
}
if (publicId != null || fEntityScanner.skipString("SYSTEM")) {
if (publicId == null && !fEntityScanner.skipSpaces()) {
reportFatalError("SpaceRequiredAfterSYSTEM", null);
}
int quote = fEntityScanner.peekChar();
if (quote != '\'' && quote != '"') {
if (publicId != null && optionalSystemId) {
// looks like we don't have any system id
// simply return the public id
identifiers[0] = null;
identifiers[1] = publicId;
return;
}
reportFatalError("QuoteRequiredInSystemID", null);
}
fEntityScanner.scanChar();
XMLString ident = fString;
if (fEntityScanner.scanLiteral(quote, ident) != quote) {
fStringBuffer.clear();
do {
fStringBuffer.append(ident);
int c = fEntityScanner.peekChar();
if (XMLChar.isMarkup(c) || c == ']') {
fStringBuffer.append((char)fEntityScanner.scanChar());
}
else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
}
else if (isInvalidLiteral(c)) {
reportFatalError("InvalidCharInSystemID",
new Object[] { Integer.toHexString(c) });
fEntityScanner.scanChar();
}
} while (fEntityScanner.scanLiteral(quote, ident) != quote);
fStringBuffer.append(ident);
ident = fStringBuffer;
}
systemId = ident.toString();
if (!fEntityScanner.skipChar(quote)) {
reportFatalError("SystemIDUnterminated", null);
}
}
// store result in array
identifiers[0] = systemId;
identifiers[1] = publicId;
}
示例6: scanExternalID
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected void scanExternalID(String[] identifiers, boolean optionalSystemId) throws IOException,
TmxEndEntityException, RepairableException {
String systemId = null;
String publicId = null;
if (entityScanner.skipString("PUBLIC")) {
if (!entityScanner.skipSpaces()) {
newRepairableException("SpaceRequiredAfterPUBLIC");
}
scanPubidLiteral(fString);
publicId = fString.toString();
if (!entityScanner.skipSpaces() && !optionalSystemId) {
newRepairableException("SpaceRequiredBetweenPublicAndSystem");
}
}
if (publicId != null || entityScanner.skipString("SYSTEM")) {
if (publicId == null && !entityScanner.skipSpaces()) {
newRepairableException("SpaceRequiredAfterSYSTEM");
}
int quote = entityScanner.peekChar();
if (quote != '\'' && quote != '"') {
if (publicId != null && optionalSystemId) {
// looks like we don't have any system id
// simply return the public id
identifiers[0] = null;
identifiers[1] = publicId;
return;
}
newRepairableException("QuoteRequiredInSystemID");
}
entityScanner.scanChar();
XMLString ident = fString;
if (entityScanner.scanLiteral(quote, ident) != quote) {
fStringBuffer.clear();
do {
fStringBuffer.append(ident);
int c = entityScanner.peekChar();
if (XMLChar.isMarkup(c) || c == ']') {
fStringBuffer.append((char) entityScanner.scanChar());
} else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
} else if (XMLChar.isInvalid(c)) {
newRepairableException("InvalidCharInSystemID");
entityScanner.scanChar();
}
} while (entityScanner.scanLiteral(quote, ident) != quote);
fStringBuffer.append(ident);
ident = fStringBuffer;
}
systemId = ident.toString();
if (!entityScanner.skipChar((char) quote)) {
newRepairableException("SystemIDUnterminated");
}
}
// store result in array
identifiers[0] = systemId;
identifiers[1] = publicId;
}
示例7: scanPseudoAttribute
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private String scanPseudoAttribute(boolean scanningTextDecl, XMLString value) throws IOException,
RepairableException, TmxEndEntityException {
String name = entityScanner.scanName();
if (name.isEmpty()) {
newRepairableException("not found Pseudo Attribute name", entityScanner.getLineNumber(),
entityScanner.getOffsetNumber());
}
entityScanner.skipDeclSpaces();
if (!entityScanner.skipChar('=')) {
newRepairableException("not found '=' when scan Pseudo Attribute", entityScanner.getLineNumber(),
entityScanner.getOffsetNumber());
}
entityScanner.skipDeclSpaces();
int quote = entityScanner.peekChar();
if (quote != '\'' && quote != '"') {
newRepairableException("not found 'quote' when scan Pseudo Attribute", entityScanner.getLineNumber(),
entityScanner.getOffsetNumber());
}
entityScanner.scanChar();
int c = entityScanner.scanLiteral(quote, value);
if (c != quote) {
fStringBuffer2.clear();
do {
fStringBuffer2.append(value);
if (c != -1) {
if (c == '&' || c == '%' || c == '<' || c == ']') {
fStringBuffer2.append((char) entityScanner.scanChar());
}
// REVISIT: Even if you could reliably read non-ASCII chars
// why bother scanning for surrogates here? Only ASCII chars
// match the productions in XMLDecls and TextDecls. -- mrglavas
else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer2);
} else if (XMLChar.isInvalid(c)) {
entityScanner.scanChar();
// TODO should we report error, or skip this char silence?
// error("Invalid Char in xml declaration : '&#" + Integer.toHexString(c) + "'");
}
}
c = entityScanner.scanLiteral(quote, value);
} while (c != quote);
fStringBuffer2.append(value);
value.setValues(fStringBuffer2);
}
if (!entityScanner.skipChar((char) quote)) {
throw new RepairableException("not found close quote");
}
return name;
}
示例8: scanPIData
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private void scanPIData(String target, XMLString xs) throws IOException, TmxEndEntityException {
// 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') {
// TODO 非法命名
return;
}
}
// spaces
if (!entityScanner.skipSpaces()) {
if (entityScanner.skipString("?>")) {
// we found the end, there is no data
xs.clear();
return;
} else {
if (entityScanner.peekChar() == ':') {
entityScanner.scanChar();
XMLStringBuffer colonName = new XMLStringBuffer(target);
colonName.append(':');
String str = entityScanner.scanName();
if (str != null)
colonName.append(str);
// TODO reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
entityScanner.skipSpaces();
} else {
// TODO reportFatalError("SpaceRequiredInPI", null);
}
}
}
fStringBuffer.clear();
// data
if (entityScanner.scanData("?>", fStringBuffer)) {
do {
int c = entityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
} else if (XMLChar.isInvalid(c)) {
// reportFatalError("InvalidCharInPI",
// new Object[]{Integer.toHexString(c)});
entityScanner.scanChar();
}
}
} while (entityScanner.scanData("?>", fStringBuffer));
}
xs.setValues(fStringBuffer);
}
示例9: scanPIData
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private void scanPIData(String target, XMLString xs) throws IOException {
// 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') {
// TODO
// reportFatalError("ReservedPITarget", null);
}
}
// spaces
if (!entityScanner.skipSpaces()) {
if (entityScanner.skipString("?>")) {
// we found the end, there is no data
xs.clear();
return;
} else {
if (entityScanner.peekChar() == ':') {
entityScanner.scanChar();
XMLStringBuffer colonName = new XMLStringBuffer(target);
colonName.append(':');
String str = entityScanner.scanName();
if (str != null)
colonName.append(str);
// TODO
// reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
entityScanner.skipSpaces();
} else {
// TODO
// if there is data there should be some space
// reportFatalError("SpaceRequiredInPI", null);
}
}
}
fStringBuffer.clear();
// data
if (entityScanner.scanData("?>", fStringBuffer)) {
do {
int c = entityScanner.peekChar();
if (c != -1) {
if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer);
} else if (XMLChar.isInvalid(c)) {
// reportFatalError("InvalidCharInPI",
// new Object[]{Integer.toHexString(c)});
entityScanner.scanChar();
}
}
} while (entityScanner.scanData("?>", fStringBuffer));
}
xs.setValues(fStringBuffer);
}
示例10: scanPseudoAttribute
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private String scanPseudoAttribute(boolean scanningTextDecl, XMLString value) throws IOException {
String name = entityScanner.scanName();
if (name == null) {
error("not found paseudo attribute");
}
entityScanner.skipDeclSpaces();
if (!entityScanner.skipChar('=')) {
error("not found '='");
}
entityScanner.skipDeclSpaces();
int quote = entityScanner.peekChar();
if (quote != '\'' && quote != '"') {
error("not found quote when scan pseudo attribute");
}
entityScanner.scanChar();
int c = entityScanner.scanLiteral(quote, value);
if (c != quote) {
fStringBuffer2.clear();
do {
fStringBuffer2.append(value);
if (c != -1) {
if (c == '&' || c == '%' || c == '<' || c == ']') {
fStringBuffer2.append((char) entityScanner.scanChar());
}
// REVISIT: Even if you could reliably read non-ASCII chars
// why bother scanning for surrogates here? Only ASCII chars
// match the productions in XMLDecls and TextDecls. -- mrglavas
else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer2);
} else if (XMLChar.isInvalid(c)) {
String key = scanningTextDecl ? "InvalidCharInTextDecl" : "InvalidCharInXMLDecl";
error("invalid char '&#" + Integer.toHexString(c) + "'");
// reportFatalError(key,
// new Object[] {Integer.toString(c, 16)});
entityScanner.scanChar();
}
}
c = entityScanner.scanLiteral(quote, value);
} while (c != quote);
fStringBuffer2.append(value);
value.setValues(fStringBuffer2);
}
if (!entityScanner.skipChar((char) quote)) {
error("not found close quote");
}
// return
return name;
}