本文整理匯總了Java中net.ssehub.easy.instantiation.core.model.common.VilException.ID_IS_NULL屬性的典型用法代碼示例。如果您正苦於以下問題:Java VilException.ID_IS_NULL屬性的具體用法?Java VilException.ID_IS_NULL怎麽用?Java VilException.ID_IS_NULL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類net.ssehub.easy.instantiation.core.model.common.VilException
的用法示例。
在下文中一共展示了VilException.ID_IS_NULL屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
/**
* Creates a new XmlComment as child of given parent.
* @param parent The parent of the new XmlComment.
* @param contents optional initial contents, ignored if empty
* @return The created XmlElement.
* @throws VilException if element could not be created.
*/
public static XmlComment create(XmlElement parent, @ParameterMeta(name = "contents") String contents)
throws VilException {
XmlComment newElement = null;
if (null == parent) {
throw new VilException("Can not append child from NULL element!", VilException.ID_IS_NULL);
}
try {
Comment newNode = parent.getNode().getOwnerDocument().createComment(contents);
parent.getNode().appendChild(newNode); // notifies change
newElement = new XmlComment(parent, newNode);
parent.addChild(newElement); // notifies change
} catch (DOMException exc) {
throw new VilException("Invalid character, name or ID!", VilException.ID_INVALID);
}
if (null != contents && contents.length() > 0) {
newElement.setCdata(contents);
}
return newElement;
}
示例2: create
/**
* Creates a new XmlElement as child of given parent, with given name.
* @param parent The parent of the new XmlElement.
* @param name The name of the new XmlElement.
* @param contents optional initial contents, ignored if empty
* @return The created XmlElement.
* @throws VilException if element could not be created.
*/
public static XmlElement create(XmlElement parent, String name,
@ParameterMeta(name = "contents") String contents) throws VilException {
XmlElement newElement = null;
if (null == parent) {
throw new VilException("Can not append child from NULL element!", VilException.ID_IS_NULL);
}
try {
Element newNode = parent.getNode().getOwnerDocument().createElement(name);
parent.getNode().appendChild(newNode); // notifies change
newElement = new XmlElement(parent, name, null, newNode);
parent.addChild(newElement); // notifies change
parent.synchronizeAttributeSequence();
} catch (DOMException exc) {
throw new VilException("Invalid character, name or ID!", VilException.ID_INVALID);
}
if (null != contents && contents.length() > 0) {
newElement.setCdata(contents);
}
return newElement;
}
示例3: addChild
/**
* Adds a child XmlElement to this XmlElement.
* @param child The new child.
* @throws VilException If child could not be added.
*/
void addChild(XmlNode child) throws VilException {
if (null == child) {
throw new VilException("NULL can not be added as a child of an XmlElement!",
VilException.ID_IS_NULL);
}
XmlNode[] newElements;
if (null != this.nodes) {
newElements = new XmlNode[this.nodes.length + 1];
} else {
newElements = new XmlNode[1];
}
for (int i = 0; i < (newElements.length - 1); i++) {
newElements[i] = this.nodes[i];
}
newElements[newElements.length - 1] = child;
this.nodes = newElements;
notifyChange();
}
示例4: appendChild
/**
* Appends a new child. Default position is after last child of the parent.
*
* @param child The new child XmlElement.
* @param childNode The new child Node.
* @return The created XmlElement.
* @throws VilException If child could not be appended.
*/
XmlElement appendChild(XmlElement child, Node childNode) throws VilException {
if (null == child || null == childNode) {
throw new VilException("NULL can not be added as a child of an XmlElement!",
VilException.ID_IS_NULL);
}
this.insertElement(child, this.nodes[this.nodes.length - 1]);
try {
getNode().appendChild(childNode);
} catch (DOMException exc) {
throw new VilException("Unable to append a child from a " + getNode().getNodeName() + " Node!",
VilException.ID_INVALID);
}
notifyChange();
return child;
}
示例5: insertElement
/**
* Inserts an XmlElement at a certain position.
* @param elem The XmlElement that is to be inserted.
* @param previous The XmlElement previous to the new XmlElement. If null, XmlElement will be inserted as first.
* @throws VilException if XmlElement could not be inserted for whatever reason.
*/
private void insertElement(XmlNode elem, XmlNode previous) throws VilException {
if (null == elem) {
throw new VilException("Tried to insert NULL element as child!", VilException.ID_IS_NULL);
}
XmlNode[] newElements;
if (null != this.nodes) {
newElements = new XmlNode[this.nodes.length + 1];
} else {
newElements = new XmlNode[1];
}
for (int i = 0; i < (newElements.length - 1); i++) {
newElements[i] = this.nodes[i];
if (null != previous && newElements[i].equals(previous)) {
newElements[i + 1] = elem;
i++;
}
}
if (null == previous) {
newElements[newElements.length - 1] = elem;
}
this.nodes = newElements;
notifyChange();
}
示例6: 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;
}
示例7: createArtifact
/**
* Creates an artifact instance.
*
* @param <T> the type of the artifact to be returned
* @param kind the kind of artifact in terms of a class (typically the top-level interfaces)
* @param real the real (underlying) artifact instance (must be instance of Comparable)
* @param model the model to add the artifact to, <b>null</b> if the factory shall determine the artifact model
* @return the resulting handling artifact
* @throws VilException in case that the creation fails, e.g., <code>real</code> is <b>null</b>
*/
public static <T extends IArtifact> T createArtifact(Class<T> kind, Object real, ArtifactModel model)
throws VilException {
if (null == real) {
throw new VilException("given object must not be null", VilException.ID_IS_NULL);
}
if (null == model) {
model = findModel(real);
}
IArtifact artifact = model.getArtifact(real);
if (null == artifact) {
IArtifactCreator creator = findCreator(kind, real);
if (null == creator) {
throw new VilException("no artifact creator handles " + real.getClass().getName() + " " + real,
VilException.ID_NO_ARTIFACT_CREATOR);
}
artifact = creator.createArtifactInstance(real, model);
model.register(real, artifact);
} else {
artifact.update();
}
try {
return kind.cast(artifact);
} catch (ClassCastException e) {
throw new VilException("obtained artifact is of type "
+ artifact.getClass().getName() + " but " + kind.getName() + " is requested",
VilException.ID_INVALID_TYPE);
}
}