• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java XMLChar类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.xerces.util.XMLChar的典型用法代码示例。如果您正苦于以下问题:Java XMLChar类的具体用法?Java XMLChar怎么用?Java XMLChar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XMLChar类属于org.apache.xerces.util包,在下文中一共展示了XMLChar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:19,代码来源:DmozParser.java


示例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;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:23,代码来源:DefaultAdxDataService.java


示例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;
}
 
开发者ID:yahoo,项目名称:anthelion,代码行数:20,代码来源:DmozParser.java


示例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;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:23,代码来源:DefaultADXDataService.java


示例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;
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:26,代码来源:TextParser.java


示例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;
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:25,代码来源:CoreDocumentImpl.java


示例7: scanComment

import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
 * Scans a comment.
 * <p>
 * <pre>
 * [15] Comment ::= '&lt!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
 * </pre>
 * <p>
 * <strong>Note:</strong> Called after scanning past '&lt;!--'
 * <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);
    }

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:38,代码来源:XMLScanner.java


示例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);
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:31,代码来源:IDDatatypeValidator.java


示例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);
    
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:28,代码来源:IDREFDatatypeValidator.java


示例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();
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:25,代码来源:Selector.java


示例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);
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:26,代码来源:TmxScanner2.java


示例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;
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:24,代码来源:TmxScanner2.java


示例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("&amp;#");
		appendCharacter(fStringBuffer3.toString());
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:22,代码来源:TmxScanner.java


示例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;
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:24,代码来源:TmxScanner.java


示例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;
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:42,代码来源:DriverRDB.java


示例16: parseQName

import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
private final ExpandedName parseQName(String qName) throws SAXException {
	String prefix = "";
	String uri = "";
	String localName = qName;
	int commaPos = qName.indexOf(':');
	if (commaPos > 0 && commaPos < qName.length() - 1) {
		prefix = qName.substring(0, commaPos);
		if (!NAMESPACE_DECLARATION_PREFIX.equals(prefix)
				&& !prefixMappings.containsKey(prefix))
			throwException("undeclared namespace prefix " + prefix);
		localName = qName.substring(commaPos + 1);
	}
	// check that localName is an NCName
	if (localName.length() > 0 && !XMLChar.isValidNCName(localName))
		throwException(localName + " local name is not a valid NCName");
	Mapping mapping = prefixMappings.get(prefix);
	if (mapping != null)
		uri = mapping.uri;
	return new ExpandedName(uri, localName);
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:21,代码来源:ExpatReaderWrapper.java


示例17: 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;
}
 
开发者ID:whummer,项目名称:scaleDOM,代码行数:24,代码来源:CoreDocumentImpl.java


示例18: checkQName

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
 */
protected final void checkQName(String prefix, String local) {
	if (!errorChecking) {
		return;
	}

	// check that both prefix and local part match NCName
	boolean validNCName = false;
	if (!xml11Version) {
		validNCName = (prefix == null || XMLChar.isValidNCName(prefix)) && XMLChar.isValidNCName(local);
	} else {
		validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
				&& XML11Char.isXML11ValidNCName(local);
	}

	if (!validNCName) {
		// REVISIT: add qname parameter to the message
		String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR",
				null);
		throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
	}
}
 
开发者ID:whummer,项目名称:scaleDOM,代码行数:29,代码来源:CoreDocumentImpl.java


示例19: getValidXmlName

import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
 * Remove invalid XML characters.
 * @param label
 * @return
 */
private static String getValidXmlName(String label) {
	final StringBuilder validNameBuilder = new StringBuilder();
	for(int index=0;index<label.length();index++){
		char c = label.charAt(index);
		if ((index == 0 && XMLChar.isNameStart(c)) || (index != 0 && XMLChar.isName(c))) {
			validNameBuilder.append(c);
		}
	}
	final String validName = validNameBuilder.toString();
	if(validName.isEmpty()){
		return DEFAULT_COLUMN_NAME;
	}
	return validName;
}
 
开发者ID:Neotys-Labs,项目名称:Database-Advanced-Actions,代码行数:20,代码来源:Sqlactionutils.java


示例20: setXLinkLabel

import org.apache.xerces.util.XMLChar; //导入依赖的package包/类
/**
 * This method set the xlink:label
 * 
 * @param label
 *            the xlink:label
 */
public final void setXLinkLabel(String label) {
    if (label != null && !XMLChar.isValidNCName(label)) {
        throw new MCRException("xlink:label is not a valid NCName: " + label);
    }
    this.label = label;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:13,代码来源:MCRMetaLink.java



注:本文中的org.apache.xerces.util.XMLChar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HashTree类代码示例发布时间:2022-05-21
下一篇:
Java OAuth2ClientAuthenticationProcessingFilter类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap