本文整理匯總了Java中org.w3c.dom.DOMException.TYPE_MISMATCH_ERR屬性的典型用法代碼示例。如果您正苦於以下問題:Java DOMException.TYPE_MISMATCH_ERR屬性的具體用法?Java DOMException.TYPE_MISMATCH_ERR怎麽用?Java DOMException.TYPE_MISMATCH_ERR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.w3c.dom.DOMException
的用法示例。
在下文中一共展示了DOMException.TYPE_MISMATCH_ERR屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newTypeMismatchError
private static DOMException newTypeMismatchError(String name) {
String msg =
DOMMessageFormatter.formatMessage (
DOMMessageFormatter.DOM_DOMAIN,
"TYPE_MISMATCH_ERR",
new Object[] { name });
return new DOMException (DOMException.TYPE_MISMATCH_ERR, msg);
}
示例2: setAttributeNode
/**
* Adds a new attribute node. If an attribute with that name (
* <code>nodeName</code>) is already present in the element, it is
* replaced by the new one. Replacing an attribute node by itself has no
* effect.
* <br>To add a new attribute node with a qualified name and namespace
* URI, use the <code>setAttributeNodeNS</code> method.
* @param newAttr The <code>Attr</code> node to add to the attribute list.
* @return If the <code>newAttr</code> attribute replaces an existing
* attribute, the replaced <code>Attr</code> node is returned,
* otherwise <code>null</code> is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a
* different document than the one that created the element.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already an
* attribute of another <code>Element</code> object. The DOM user must
* explicitly clone <code>Attr</code> nodes to re-use them in other
* elements.
*/
public Attribute setAttributeNode(org.w3c.dom.Attr newAttr) {
checkNotInTree();
if(newAttr instanceof Attribute) {
Attribute attribute = (Attribute)newAttr;
Attribute oldAttr = getAttributeNode(newAttr.getName());
if (oldAttr==null) {
getAttributesForWrite().add(attribute);
return attribute;
} else {
int index = getAttributesForRead().indexOf(oldAttr);
return getAttributesForWrite().set(index,attribute);
}
} else {
throw new DOMException(DOMException.TYPE_MISMATCH_ERR,null);
}
}