当前位置: 首页>>代码示例>>Java>>正文


Java XMLChar.isNCNameStart方法代码示例

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


在下文中一共展示了XMLChar.isNCNameStart方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: escapedId

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
static private String escapedId(String id) {
	StringBuffer result = new StringBuffer();
	for (int i = 0; i < id.length(); i++) {
		char ch = id.charAt(i);
		if (ch != ESCAPE
			&& (i == 0 ? XMLChar.isNCNameStart(ch) : XMLChar.isNCName(ch))) {
			result.append( ch );
		} else {
			escape( result, ch );
		}
	}
	return result.toString();
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:14,代码来源:BaseXMLWriter.java

示例3: encode

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Encode a string according to ISO 9075
 * 
 * @param toEncode String
 * @return String
 */
public static String encode(String toEncode)
{
    if ((toEncode == null) || (toEncode.length() == 0))
    {
        return toEncode;
    }
    else if (XMLChar.isValidName(toEncode) && (toEncode.indexOf("_x") == -1) && (toEncode.indexOf(':') == -1))
    {
        return toEncode;
    }
    else
    {
        StringBuilder builder = new StringBuilder(toEncode.length());
        for (int i = 0; i < toEncode.length(); i++)
        {
            char c = toEncode.charAt(i);
            // First requires special test
            if (i == 0)
            {
                if (XMLChar.isNCNameStart(c))
                {
                    // The first character may be the _ at the start of an
                    // encoding pattern
                    if (matchesEncodedPattern(toEncode, i))
                    {
                        // Encode the first _
                        encode('_', builder);
                    }
                    else
                    {
                        // Just append
                        builder.append(c);
                    }
                }
                else
                {
                    // Encode an invalid start character for an XML element
                    // name.
                    encode(c, builder);
                }
            }
            else if (!XMLChar.isNCName(c))
            {
                encode(c, builder);
            }
            else
            {
                if (matchesEncodedPattern(toEncode, i))
                {
                    // '_' must be encoded
                    encode('_', builder);
                }
                else
                {
                    builder.append(c);
                }
            }
        }
        return builder.toString();
    }

}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:69,代码来源:ISO9075.java

示例4: encode

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Encode a string according to ISO 9075
 * 
 * @param toEncode
 * @return
 */
public static String encode(String toEncode)
{
    if ((toEncode == null) || (toEncode.length() == 0))
    {
        return toEncode;
    }
    else if (XMLChar.isValidName(toEncode) && (toEncode.indexOf("_x") == -1))
    {
        return toEncode;
    }
    else
    {
        StringBuilder builder = new StringBuilder(toEncode.length());
        for (int i = 0; i < toEncode.length(); i++)
        {
            char c = toEncode.charAt(i);
            // First requires special test
            if (i == 0)
            {
                if (XMLChar.isNCNameStart(c))
                {
                    // The first character may be the _ at the start of an
                    // encoding pattern
                    if (matchesEncodedPattern(toEncode, i))
                    {
                        // Encode the first _
                        encode('_', builder);
                    }
                    else
                    {
                        // Just append
                        builder.append(c);
                    }
                }
                else
                {
                    // Encode an invalid start character for an XML element
                    // name.
                    encode(c, builder);
                }
            }
            else if (!XMLChar.isNCName(c))
            {
                encode(c, builder);
            }
            else
            {
                if (matchesEncodedPattern(toEncode, i))
                {
                    // '_' must be encoded
                    encode('_', builder);
                }
                else
                {
                    builder.append(c);
                }
            }
        }
        return builder.toString();
    }

}
 
开发者ID:xenit-eu,项目名称:move2alf,代码行数:69,代码来源:ISO9075.java

示例5: splitNamespace

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/** 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 splitNamespace(String uri) {
        
        // XML Namespaces 1.0:
        // A qname name is NCName ':' NCName
        // NCName             ::=      NCNameStartChar NCNameChar*
        // NCNameChar         ::=      NameChar - ':'
        // NCNameStartChar    ::=      Letter | '_'
        // 
        // XML 1.0
        // NameStartChar      ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] |
        //                        [#xD8-#xF6] | [#xF8-#x2FF] |
        //                        [#x370-#x37D] | [#x37F-#x1FFF] |
        //                        [#x200C-#x200D] | [#x2070-#x218F] |
        //                        [#x2C00-#x2FEF] | [#x3001-#xD7FF] |
        //                        [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
        // NameChar           ::= NameStartChar | "-" | "." | [0-9] | #xB7 |
        //                        [#x0300-#x036F] | [#x203F-#x2040]
        // Name               ::= NameStartChar (NameChar)*
        
        char ch;
        int lg = uri.length();
        if (lg == 0)
            return 0;
        int i = lg-1 ;
        for ( ; i >= 1 ; i--) {
            ch = uri.charAt(i);
            if (notNameChar(ch)) break;
        }
        
        int j = i + 1 ;

        if ( j >= lg )
            return lg ;
        
        // Check we haven't split up a %-encoding.
        if ( j >= 2 && uri.charAt(j-2) == '%' )
            j = j+1 ;
        if ( j >= 1 && uri.charAt(j-1) == '%' )
            j = j+2 ;
        
        // Have found the leftmost NCNameChar from the
        // end of the URI string.
        // Now scan forward for an NCNameStartChar
        // The split must start with NCNameStart.
        for (; j < lg; j++) {
            ch = uri.charAt(j);
//            if (XMLChar.isNCNameStart(ch))
//                break ;
            if (XMLChar.isNCNameStart(ch))
            {
                // "mailto:" is special.
                // Keep part after mailto: at least one charcater.
                // Do a quick test before calling .startsWith
                // OLD: if ( uri.charAt(j - 1) == ':' && uri.lastIndexOf(':', j - 2) == -1)
                if ( j == 7 && uri.startsWith("mailto:"))
                    continue; // split "mailto:me" as "mailto:m" and "e" !
                else
                    break;
            }
        }
        return j;
    }
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:73,代码来源:Util.java


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