本文整理汇总了Java中org.apache.xerces.util.XMLChar类的典型用法代码示例。如果您正苦于以下问题:Java XMLChar类的具体用法?Java XMLChar怎么用?Java XMLChar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLChar类属于org.apache.xerces.util包,在下文中一共展示了XMLChar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
public int read(char[] cbuf, int off, int len) throws IOException {
int n = in.read(cbuf, off, len);
if (n != -1) {
for (int i = 0; i < n; i++) {
char c = cbuf[off + i];
char value = c;
if (!(XMLChar.isValid(c))) // fix invalid characters
value = 'X';
else if (lastBad && c == '<') { // fix mis-matched brackets
if (i != n - 1 && cbuf[off + i + 1] != '/')
value = 'X';
}
lastBad = (c == 65533);
cbuf[off + i] = value;
}
}
return n;
}
示例2: getCodeCategoryMap
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
private Map<String, DataElementCategory> getCodeCategoryMap( DataElementCategoryCombo categoryCombo )
throws AdxException
{
Map<String, DataElementCategory> categoryMap = new HashMap<>();
List<DataElementCategory> categories = categoryCombo.getCategories();
for ( DataElementCategory category : categories )
{
String categoryCode = category.getCode();
if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) )
{
throw new AdxException(
"Category code for " + category.getName() + " is missing or invalid: " + categoryCode );
}
categoryMap.put( category.getCode(), category );
}
return categoryMap;
}
示例3: read
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
public int read(char[] cbuf, int off, int len)
throws IOException {
int n = in.read(cbuf, off, len);
if (n != -1) {
for (int i = 0; i < n; i++) {
char c = cbuf[off+i];
char value = c;
if (!(XMLChar.isValid(c))) // fix invalid characters
value = 'X';
else if (lastBad && c == '<') { // fix mis-matched brackets
if (i != n-1 && cbuf[off+i+1] != '/')
value = 'X';
}
lastBad = (c == 65533);
cbuf[off+i] = value;
}
}
return n;
}
示例4: createCategoryMap
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
private Map<String, DataElementCategory> createCategoryMap( DataElementCategoryCombo catcombo )
throws ADXException
{
Map<String, DataElementCategory> categoryMap = new HashMap<>();
List<DataElementCategory> categories = catcombo.getCategories();
for ( DataElementCategory category : categories )
{
String categoryCode = category.getCode();
if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) )
{
throw new ADXException( "Category code for " + category.getName() + " is missing or invalid: "
+ categoryCode );
}
categoryMap.put( category.getCode(), category );
}
return categoryMap;
}
示例5: isValidStateIdentifier
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
* test if this is a valid state identifier, essentially must be a valid
* XML attribute name *without* : or . character within.
*/
public static boolean isValidStateIdentifier(String id)
{
if (id != null)
{
for (int i=0; i < id.length(); i++)
{
if (!isIdentifierChar(id.charAt(i)))
{
return false;
}
}
if (!XMLChar.isValidName(id))
{
return false;
}
return true;
}
return false;
}
示例6: isValidQName
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
* Checks if the given qualified name is legal with respect
* to the version of XML to which this document must conform.
*
* @param prefix prefix of qualified name
* @param local local part of qualified name
*/
public static final boolean isValidQName(String prefix, String local, boolean xml11Version) {
// check that both prefix and local part match NCName
if (local == null) return false;
boolean validNCName = false;
if (!xml11Version) {
validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
&& XMLChar.isValidNCName(local);
}
else {
validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
&& XML11Char.isXML11ValidNCName(local);
}
return validNCName;
}
示例7: 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);
}
}
示例8: validate
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
* Checks that "content" string is valid ID value.
* If invalid a Datatype validation exception is thrown.
*
* @param content the string value that needs to be validated
* @param context the validation context
* @throws InvalidDatatypeException if the content is
* invalid according to the rules for the validators
* @see InvalidDatatypeValueException
*/
public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
//Check if is valid key-[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
if(context.useNamespaces()) {
if (!XMLChar.isValidNCName(content)) {
throw new InvalidDatatypeValueException("IDInvalidWithNamespaces", new Object[]{content});
}
}
else {
if (!XMLChar.isValidName(content)) {
throw new InvalidDatatypeValueException("IDInvalid", new Object[]{content});
}
}
if (context.isIdDeclared(content)) {
throw new InvalidDatatypeValueException("IDNotUnique", new Object[]{content});
}
context.addId(content);
}
示例9: validate
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
* Checks that "content" string is valid IDREF value.
* If invalid a Datatype validation exception is thrown.
*
* @param content the string value that needs to be validated
* @param context the validation context
* @throws InvalidDatatypeException if the content is
* invalid according to the rules for the validators
* @see InvalidDatatypeValueException
*/
public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
//Check if is valid key-[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
if(context.useNamespaces()) {
if (!XMLChar.isValidNCName(content)) {
throw new InvalidDatatypeValueException("IDREFInvalidWithNamespaces", new Object[]{content});
}
}
else {
if (!XMLChar.isValidName(content)) {
throw new InvalidDatatypeValueException("IDREFInvalid", new Object[]{content});
}
}
context.addIdRef(content);
}
示例10: normalize
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
private static String normalize(String xpath) {
// NOTE: We have to prefix the selector XPath with "./" in
// order to handle selectors such as "." that select
// the element container because the fields could be
// relative to that element. -Ac
// Unless xpath starts with a descendant node -Achille Fokoue
// ... or a '.' or a '/' - NG
// And we also need to prefix exprs to the right of | with ./ - NG
StringBuffer modifiedXPath = new StringBuffer(xpath.length()+5);
int unionIndex = -1;
do {
if(!(XMLChar.trim(xpath).startsWith("/") || XMLChar.trim(xpath).startsWith("."))) {
modifiedXPath.append("./");
}
unionIndex = xpath.indexOf('|');
if(unionIndex == -1) {
modifiedXPath.append(xpath);
break;
}
modifiedXPath.append(xpath.substring(0,unionIndex+1));
xpath = xpath.substring(unionIndex+1, xpath.length());
} while(true);
return modifiedXPath.toString();
}
示例11: scanStartElement
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
protected void scanStartElement() throws IOException, RepairableException, TmxEndEntityException {
entityScanner.scanQName(elementQName);
attributes.removeAllAttributes();
copyQname(elementQName, fCurrentElement);
do {
boolean sawSpace = entityScanner.skipSpaces();
int c = entityScanner.peekChar();
if (c == '>') {
entityScanner.scanChar();
break;
} else if (c == '/') {
entityScanner.scanChar();
if (!entityScanner.skipChar('>')) {
newRepairableException("[start element] miss '>' after '/'");
}
break;
} else if (!XMLChar.isNameStart(c) || !sawSpace) {
setScannerState(SCANNER_STATE_CONTENT);
newRepairableException("[start element] illegal char '" + Integer.toHexString(c) + '\'');
}
scanAttribute(attributes);
} while (true);
cwriter.writeStartElement(fCurrentElement, attributes);
}
示例12: scanSurrogates
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
private boolean scanSurrogates(XMLStringBuffer buf) throws IOException, TmxEndEntityException {
int high = entityScanner.scanChar();
int low = entityScanner.peekChar();
if (!XMLChar.isLowSurrogate(low)) {
error("invalid char in content");
return false;
}
entityScanner.scanChar();
int c = XMLChar.supplemental((char) high, (char) low);
if (XMLChar.isInvalid(c)) {
error("invalid char in content");
return false;
}
// fill in the buffer
buf.append((char) high);
buf.append((char) low);
return true;
}
示例13: scanCharReference
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
private void scanCharReference() throws IOException {
fStringBuffer2.clear();
boolean hex = entityScanner.peekChar() == 'x';
int ch = scanCharReferenceValue(fStringBuffer2, null);
if (ch != -1) {
int c = Integer.valueOf(fStringBuffer3.toString(), hex ? 16 : 10);
if (c < 0x20 && !XMLChar.isSpace(c)) {
return;
}
if (hex) {//
appendCharacter("&x");
} else {
appendCharacter("&");
}
appendCharacter(fStringBuffer3.toString());
appendCharacter(";");
} else {
appendCharacter("&#");
appendCharacter(fStringBuffer3.toString());
}
}
示例14: scanSurrogates
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
private boolean scanSurrogates(XMLStringBuffer buf) throws IOException {
int high = entityScanner.scanChar();
int low = entityScanner.peekChar();
if (!XMLChar.isLowSurrogate(low)) {
error("invalid char in content");
return false;
}
entityScanner.scanChar();
int c = XMLChar.supplemental((char) high, (char) low);
// supplemental character must be a valid XML character
if (XMLChar.isInvalid(c)) {
error("invalid char in content");
return false;
}
// fill in the buffer
buf.append((char) high);
buf.append((char) low);
return true;
}
示例15: dbSplitNamespace
import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/** This is cuurently a copy of Util.splitNamespace. It was
* copied rather than used directly for two reasons. 1) in the
* future it may be desirable to use a different split algorithm
* for persistence. 2) the util version could change at any time,
* which would render existing databases inaccessible. having a
* copy allows the db version to evolve in a controlled way.
*
* Given an absolute URI, determine the split point between the namespace part
* and the localname part.
* If there is no valid localname part then the length of the
* string is returned.
* The algorithm tries to find the longest NCName at the end
* of the uri, not immediately preceeded by the first colon
* in the string.
* @param uri
* @return the index of the first character of the localname
*/
public static int dbSplitNamespace(String uri) {
char ch;
int lg = uri.length();
if (lg == 0)
return 0;
int j;
int i;
for (i = lg - 1; i >= 1; i--) {
ch = uri.charAt(i);
if (!XMLChar.isNCName(ch))
break;
}
for (j = i + 1; j < lg; j++) {
ch = uri.charAt(j);
if (XMLChar.isNCNameStart(ch)) {
if (uri.charAt(j - 1) == ':'
&& uri.lastIndexOf(':', j - 2) == -1)
continue; // split "mailto:me" as "mailto:m" and "e" !
else
break;
}
}
return j;
}