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