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


Java XMLChar.isNCName方法代码示例

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


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

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 * Given a namespace, add a '#' character to the end of the namespace if it ends with a
 * valid NCName character. If it does not then it already has a termination that allows
 * splitting namespace from localname in resource URIs so return the input namespace.
 *
 * @param inputNamespace
 * @return
 */
public static synchronized String addHashToNonTerminatedNamespace(String inputNamespace) {
       if (inputNamespace.length() > 0 && XMLChar.isNCName( inputNamespace.charAt(inputNamespace.length() -1) )) {
       	// this is for backward compatibility--in V1 a valid ending character was not required--
       	//  and for convenience (so the user doesn't have to provide an ending character from a
       	//  "secret" set of characters)
       	return inputNamespace + "#";
       }
       else {
       	return inputNamespace;
       }
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:20,代码来源:ConfigurationManager.java

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

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

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

示例6: isValidNCName

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected boolean isValidNCName(int value) {
    return (XMLChar.isNCName(value));
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:4,代码来源:XMLScanner.java

示例7: notNameChar

import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
 answer true iff this is not a legal NCName character, ie, is
 a possible split-point start.
*/
public static boolean notNameChar( char ch )
    { return !XMLChar.isNCName( ch ); }
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:7,代码来源:Util.java


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