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


Java VilException.ID_IS_NULL屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:SSEHUB,項目名稱:EASyProducer,代碼行數:26,代碼來源:XmlComment.java

示例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;
}
 
開發者ID:SSEHUB,項目名稱:EASyProducer,代碼行數:28,代碼來源:XmlElement.java

示例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();
}
 
開發者ID:SSEHUB,項目名稱:EASyProducer,代碼行數:23,代碼來源:XmlElement.java

示例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;
}
 
開發者ID:SSEHUB,項目名稱:EASyProducer,代碼行數:23,代碼來源:XmlElement.java

示例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();
}
 
開發者ID:SSEHUB,項目名稱:EASyProducer,代碼行數:29,代碼來源:XmlElement.java

示例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;
}
 
開發者ID:SSEHUB,項目名稱:EASyProducer,代碼行數:32,代碼來源:XmlAttribute.java

示例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);
    }
}
 
開發者ID:SSEHUB,項目名稱:EASyProducer,代碼行數:39,代碼來源:ArtifactFactory.java


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