Path: blob/master/src/java.xml/share/classes/org/w3c/dom/DOMException.java
40948 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/*25* This file is available under and governed by the GNU General Public26* License version 2 only, as published by the Free Software Foundation.27* However, the following notice accompanied the original version of this28* file and, per its terms, should not be removed:29*30* Copyright (c) 2004 World Wide Web Consortium,31*32* (Massachusetts Institute of Technology, European Research Consortium for33* Informatics and Mathematics, Keio University). All Rights Reserved. This34* work is distributed under the W3C(r) Software License [1] in the hope that35* it will be useful, but WITHOUT ANY WARRANTY; without even the implied36* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.37*38* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-2002123139*/4041package org.w3c.dom;4243/**44* DOM operations only raise exceptions in "exceptional" circumstances, i.e.,45* when an operation is impossible to perform (either for logical reasons,46* because data is lost, or because the implementation has become unstable).47* In general, DOM methods return specific error values in ordinary48* processing situations, such as out-of-bound errors when using49* <code>NodeList</code>.50* <p>Implementations should raise other exceptions under other circumstances.51* For example, implementations should raise an implementation-dependent52* exception if a <code>null</code> argument is passed when <code>null</code>53* was not expected.54* <p>Some languages and object systems do not support the concept of55* exceptions. For such systems, error conditions may be indicated using56* native error reporting mechanisms. For some bindings, for example,57* methods may return error codes similar to those listed in the58* corresponding method descriptions.59* <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>Document Object Model (DOM) Level 3 Core Specification</a>.60*/61public class DOMException extends RuntimeException {62public DOMException(short code, String message) {63super(message);64this.code = code;65}66public short code;67// ExceptionCode68/**69* If index or size is negative, or greater than the allowed value.70*/71public static final short INDEX_SIZE_ERR = 1;72/**73* If the specified range of text does not fit into a74* <code>DOMString</code>.75*/76public static final short DOMSTRING_SIZE_ERR = 2;77/**78* If any <code>Node</code> is inserted somewhere it doesn't belong.79*/80public static final short HIERARCHY_REQUEST_ERR = 3;81/**82* If a <code>Node</code> is used in a different document than the one83* that created it (that doesn't support it).84*/85public static final short WRONG_DOCUMENT_ERR = 4;86/**87* If an invalid or illegal character is specified, such as in an XML name.88*/89public static final short INVALID_CHARACTER_ERR = 5;90/**91* If data is specified for a <code>Node</code> which does not support92* data.93*/94public static final short NO_DATA_ALLOWED_ERR = 6;95/**96* If an attempt is made to modify an object where modifications are not97* allowed.98*/99public static final short NO_MODIFICATION_ALLOWED_ERR = 7;100/**101* If an attempt is made to reference a <code>Node</code> in a context102* where it does not exist.103*/104public static final short NOT_FOUND_ERR = 8;105/**106* If the implementation does not support the requested type of object or107* operation.108*/109public static final short NOT_SUPPORTED_ERR = 9;110/**111* If an attempt is made to add an attribute that is already in use112* elsewhere.113*/114public static final short INUSE_ATTRIBUTE_ERR = 10;115/**116* If an attempt is made to use an object that is not, or is no longer,117* usable.118* @since 1.4, DOM Level 2119*/120public static final short INVALID_STATE_ERR = 11;121/**122* If an invalid or illegal string is specified.123* @since 1.4, DOM Level 2124*/125public static final short SYNTAX_ERR = 12;126/**127* If an attempt is made to modify the type of the underlying object.128* @since 1.4, DOM Level 2129*/130public static final short INVALID_MODIFICATION_ERR = 13;131/**132* If an attempt is made to create or change an object in a way which is133* incorrect with regard to namespaces.134* @since 1.4, DOM Level 2135*/136public static final short NAMESPACE_ERR = 14;137/**138* If a parameter or an operation is not supported by the underlying139* object.140* @since 1.4, DOM Level 2141*/142public static final short INVALID_ACCESS_ERR = 15;143/**144* If a call to a method such as <code>insertBefore</code> or145* <code>removeChild</code> would make the <code>Node</code> invalid146* with respect to "partial validity", this exception would be raised147* and the operation would not be done. This code is used in [<a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Val-20040127/'>DOM Level 3 Validation</a>]148* . Refer to this specification for further information.149* @since 1.5, DOM Level 3150*/151public static final short VALIDATION_ERR = 16;152/**153* If the type of an object is incompatible with the expected type of the154* parameter associated to the object.155* @since 1.5, DOM Level 3156*/157public static final short TYPE_MISMATCH_ERR = 17;158159// Added serialVersionUID to preserve binary compatibility160static final long serialVersionUID = 6627732366795969916L;161}162163164