當前位置: 首頁>>代碼示例>>Java>>正文


Java VilException.ID_INVALID_CHARACTER屬性代碼示例

本文整理匯總了Java中net.ssehub.easy.instantiation.core.model.common.VilException.ID_INVALID_CHARACTER屬性的典型用法代碼示例。如果您正苦於以下問題:Java VilException.ID_INVALID_CHARACTER屬性的具體用法?Java VilException.ID_INVALID_CHARACTER怎麽用?Java VilException.ID_INVALID_CHARACTER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在net.ssehub.easy.instantiation.core.model.common.VilException的用法示例。


在下文中一共展示了VilException.ID_INVALID_CHARACTER屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

/**
 * Creates a new Attribute for given XmlElement, with given name and value.
 * Overwrites by default.
 * 
 * @param parent The XmlElement the attribute is for.
 * @param name The name of the attribute.
 * @param value The value of the new attribute.
 * @param forceOverwrite True if existing attributes with same name shall be overwritten. Default = true.
 * @return The created XmlAttribute. The existing attribute if forceOverwrite is false.
 * @throws VilException if attribute could not be created for different reason then pre-existance.
 */
public static XmlAttribute create(XmlElement parent, String name, String value, boolean forceOverwrite) 
    throws VilException {
    XmlAttribute newAttribute = null;
    if (null == parent) {
        throw new VilException("Can not add attribute to NULL element!", VilException.ID_IS_NULL);
    }
    Element parentElem = (Element) parent.getNode();
    if (forceOverwrite || !parentElem.hasAttribute(name)) {
        try {
            parentElem.setAttribute(name, value);
            newAttribute = parent.addAttribute(name, value); // notifies change
            parent.synchronizeAttributeSequence();
        } catch (DOMException exc) {
            throw new VilException("Invalid character, name or ID!", 
                VilException.ID_INVALID_CHARACTER);
        }
    } else {
        newAttribute = parent.getAttribute(name);
    }
    return newAttribute;
}
 
開發者ID:SSEHUB,項目名稱:EASyProducer,代碼行數:32,代碼來源:XmlAttribute.java

示例2: checkJavaPath

/**
 * Checks the given path for compliance to Java path conventions.
 * @param path the path to be checked
 * @return <code>path</code>
 * @throws VilException in case that the path does not comply to Java conventions
 */
private static String checkJavaPath(String path) throws VilException {
    // we allow empty paths!
    boolean atIdentifierStart = true;
    for (int i = 0; i < path.length(); i++) {
        char c = path.charAt(i);
        if (atIdentifierStart) {
            if (!Character.isJavaIdentifierStart(c)) {
                throw new VilException("Java identifer must not start with '" + c + "'", 
                    VilException.ID_INVALID_CHARACTER);
            }
            atIdentifierStart = false;
        } else {
            if ('.' == c) {
                atIdentifierStart = true;
            } else {
                if (!Character.isJavaIdentifierPart(c)) {
                    throw new VilException("Java identifier must not contain '" + c + "'", 
                        VilException.ID_INVALID_CHARACTER);
                }
            }
        }
    }
    if (0 == path.length() && atIdentifierStart) {
        throw new VilException("Java path must not end with '.'", 
            VilException.ID_INVALID_CHARACTER);
    }
    return path;
}
 
開發者ID:SSEHUB,項目名稱:EASyProducer,代碼行數:34,代碼來源:JavaPath.java


注:本文中的net.ssehub.easy.instantiation.core.model.common.VilException.ID_INVALID_CHARACTER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。