本文整理汇总了Java中org.apache.xerces.util.XMLChar.isValidName方法的典型用法代码示例。如果您正苦于以下问题:Java XMLChar.isValidName方法的具体用法?Java XMLChar.isValidName怎么用?Java XMLChar.isValidName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.util.XMLChar
的用法示例。
在下文中一共展示了XMLChar.isValidName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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);
}
示例5: 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);
}
示例6: addExplodedCategoryAttributes
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
private void addExplodedCategoryAttributes( DataElementCategoryOptionCombo coc )
throws AdxException
{
Map<String, String> categoryAttributes = new HashMap<>();
if ( !coc.isDefault() )
{
for ( DataElementCategory category : coc.getCategoryCombo().getCategories() )
{
String categoryCode = category.getCode();
if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) )
{
throw new AdxException(
"Category code for " + category.getName() + " is missing or invalid: " + categoryCode );
}
String catOptCode = category.getCategoryOption( coc ).getCode();
if ( catOptCode == null || catOptCode.isEmpty() )
{
throw new AdxException(
"CategoryOption code for " + category.getCategoryOption( coc ).getName() + " is missing" );
}
categoryAttributes.put( categoryCode, catOptCode );
}
}
categoryOptionMap.put( coc.getId(), categoryAttributes );
}
示例7: isValid
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
* @param text
* @return
*/
@Override
public boolean isValid( String text )
{
return ( text.startsWith( "<" ) && text.endsWith( "/>" ) && XMLChar.isValidName( text.substring( 1,
text.length() - 2 ) ) )
|| ( text.startsWith( "<!--" ) && text.endsWith( "-->" ) );
}
示例8: isXMLName
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
* Check the string against XML's definition of acceptable names for
* elements and attributes and so on using the XMLCharacterProperties
* utility class
*/
public static final boolean isXMLName(String s, boolean xml11Version) {
if (s == null) {
return false;
}
if(!xml11Version)
return XMLChar.isValidName(s);
else
return XML11Char.isXML11ValidName(s);
}
示例9: isXMLName
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/**
* Check the string against XML's definition of acceptable names for elements and attributes and so on using the
* XMLCharacterProperties utility class
*/
public static final boolean isXMLName(String s, boolean xml11Version) {
if (s == null) {
return false;
}
if (!xml11Version)
return XMLChar.isValidName(s);
else
return XML11Char.isXML11ValidName(s);
}
示例10: processingInstruction
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/** Processing instruction. */
public void processingInstruction(final String target, final XMLString data,
final Augmentations augs)
throws XNIException {
final String s = data.toString();
if (XMLChar.isValidName(s)) {
final ProcessingInstruction pi = fDocument.createProcessingInstruction(target, s);
fCurrentNode.appendChild(pi);
}
}
示例11: startElement
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
/** Start element. */
public void startElement(QName element, XMLAttributes attrs,
Augmentations augs) throws XNIException {
Element elementNode = fDocument.createElement(element.rawname);
int count = attrs != null ? attrs.getLength() : 0;
for (int i = 0; i < count; i++) {
String aname = attrs.getQName(i);
String avalue = attrs.getValue(i);
if (XMLChar.isValidName(aname)) {
elementNode.setAttribute(aname, avalue);
}
}
fCurrentNode.appendChild(elementNode);
fCurrentNode = elementNode;
}
示例12: 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();
}
}
示例13: 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();
}
}
示例14: createItemFromString
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
@Override
public XQItem createItemFromString(String value, XQItemType type) throws XQException {
checkState(ex_connection_closed);
if (value == null) {
throw new XQException("value is null");
}
if (type == null) {
type = createAtomicType(XQBASETYPE_STRING);
}
switch (type.getBaseType()) {
case XQBASETYPE_ANYURI:
case XQBASETYPE_NOTATION:
case XQBASETYPE_STRING:
case XQBASETYPE_UNTYPEDATOMIC:
return new BagriXQItem(xqProcessor, type, value);
case XQBASETYPE_ID: if (XMLChar.isValidNCName(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
case XQBASETYPE_NAME: if (XMLChar.isValidName(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
case XQBASETYPE_ENTITY:
case XQBASETYPE_ENTITIES:
case XQBASETYPE_IDREF:
case XQBASETYPE_NCNAME: if (XMLChar.isValidNCName(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
//throw new XQException("can't convert string \"" + value + "\" to type " + type);
break;
case XQBASETYPE_NMTOKEN: if (XMLChar.isValidNmtoken(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
case XQBASETYPE_NORMALIZED_STRING: if (isValidNormalizedString(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
case XQBASETYPE_TOKEN: if (isValidToken(value)) {
return new BagriXQItem(xqProcessor, type, value);
}
break;
}
throw new XQException("wrong string value: " + value + " for type: " + type);
}
示例15: isValidName
import org.apache.xerces.util.XMLChar; //导入方法依赖的package包/类
protected boolean isValidName(String name) {
return XMLChar.isValidName(name);
}