本文整理汇总了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;
}
示例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;
}
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例6: isValidNCName
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected boolean isValidNCName(int value) {
return (XMLChar.isNCName(value));
}
示例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 ); }