本文整理汇总了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;
}
示例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;
}