001: /*--
002:
003: $Id: IllegalAddException.java,v 1.1 2005/04/27 09:32:37 wittek Exp $
004:
005: Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin.
006: All rights reserved.
007:
008: Redistribution and use in source and binary forms, with or without
009: modification, are permitted provided that the following conditions
010: are met:
011:
012: 1. Redistributions of source code must retain the above copyright
013: notice, this list of conditions, and the following disclaimer.
014:
015: 2. Redistributions in binary form must reproduce the above copyright
016: notice, this list of conditions, and the disclaimer that follows
017: these conditions in the documentation and/or other materials
018: provided with the distribution.
019:
020: 3. The name "JDOM" must not be used to endorse or promote products
021: derived from this software without prior written permission. For
022: written permission, please contact <request_AT_jdom_DOT_org>.
023:
024: 4. Products derived from this software may not be called "JDOM", nor
025: may "JDOM" appear in their name, without prior written permission
026: from the JDOM Project Management <request_AT_jdom_DOT_org>.
027:
028: In addition, we request (but do not require) that you include in the
029: end-user documentation provided with the redistribution and/or in the
030: software itself an acknowledgement equivalent to the following:
031: "This product includes software developed by the
032: JDOM Project (http://www.jdom.org/)."
033: Alternatively, the acknowledgment may be graphical using the logos
034: available at http://www.jdom.org/images/logos.
035:
036: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
040: CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: SUCH DAMAGE.
048:
049: This software consists of voluntary contributions made by many
050: individuals on behalf of the JDOM Project and was originally
051: created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
052: Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
053: on the JDOM Project, please see <http://www.jdom.org/>.
054:
055: */
056:
057: package org.jdom;
058:
059: /**
060: * Thrown when trying to add a illegal object to a JDOM construct.
061: *
062: * @version $Revision: 1.1 $, $Date: 2005/04/27 09:32:37 $
063: * @author Brett McLaughlin
064: * @author Jason Hunter
065: */
066: public class IllegalAddException extends IllegalArgumentException {
067:
068: private static final String CVS_ID = "@(#) $RCSfile: IllegalAddException.java,v $ $Revision: 1.1 $ $Date: 2005/04/27 09:32:37 $ $Name: $";
069:
070: /**
071: * This will create an <code>Exception</code> indicating
072: * that the addition of the <code>{@link Attribute}</code>
073: * to the <code>{@link Element}</code> is illegal.
074: *
075: * @param base <code>Element</code> that <code>Attribute</code>
076: * couldn't be added to
077: * @param added <code>Attribute</code> that could not be added
078: * @param reason cause of the problem
079: */
080: IllegalAddException(Element base, Attribute added, String reason) {
081: super (new StringBuffer().append("The attribute \"").append(
082: added.getQualifiedName()).append(
083: "\" could not be added to the element \"").append(
084: base.getQualifiedName()).append("\": ").append(reason)
085: .toString());
086: }
087:
088: /**
089: * This will create an <code>Exception</code> indicating
090: * that the addition of the <code>{@link Element}</code>
091: * to parent is illegal.
092: *
093: * @param base <code>Element</code> that the child
094: * couldn't be added to
095: * @param added <code>Element</code> that could not be added
096: * @param reason cause of the problem
097: */
098: IllegalAddException(Element base, Element added, String reason) {
099: super (new StringBuffer().append("The element \"").append(
100: added.getQualifiedName()).append(
101: "\" could not be added as a child of \"").append(
102: base.getQualifiedName()).append("\": ").append(reason)
103: .toString());
104: }
105:
106: /**
107: * This will create an <code>Exception</code> indicating
108: * that the addition of the <code>{@link Element}</code>
109: * to the <code>{@link Document}</code> is illegal.
110: *
111: * @param added <code>Element</code> that could not be added
112: * @param reason cause of the problem
113: */
114: IllegalAddException(Element added, String reason) {
115: super (new StringBuffer().append("The element \"").append(
116: added.getQualifiedName()).append(
117: "\" could not be added as the root of the document: ")
118: .append(reason).toString());
119: }
120:
121: /**
122: * This will create an <code>Exception</code> indicating
123: * that the addition of the <code>{@link ProcessingInstruction}</code>
124: * to the <code>{@link Element}</code> is illegal.
125: *
126: * @param base <code>Element</code> that the
127: * <code>ProcessingInstruction</code> couldn't be added to
128: * @param added <code>ProcessingInstruction</code> that could not be added
129: * @param reason cause of the problem
130: */
131: IllegalAddException(Element base, ProcessingInstruction added,
132: String reason) {
133: super (new StringBuffer().append("The PI \"").append(
134: added.getTarget()).append(
135: "\" could not be added as content to \"").append(
136: base.getQualifiedName()).append("\": ").append(reason)
137: .toString());
138: }
139:
140: /**
141: * This will create an <code>Exception</code> indicating
142: * that the addition of the <code>{@link ProcessingInstruction}</code>
143: * to the <code>{@link Document}</code> is illegal.
144: *
145: * @param added <code>ProcessingInstruction</code> that could not be added
146: * @param reason cause of the problem
147: */
148: IllegalAddException(ProcessingInstruction added, String reason) {
149: super (
150: new StringBuffer()
151: .append("The PI \"")
152: .append(added.getTarget())
153: .append(
154: "\" could not be added to the top level of the document: ")
155: .append(reason).toString());
156: }
157:
158: /**
159: * This will create an <code>Exception</code> indicating
160: * that the addition of the <code>{@link Comment}</code>
161: * to the <code>{@link Element}</code> is illegal.
162: *
163: * @param base <code>Element</code> that the <code>Comment</code>
164: * couldn't be added to
165: * @param added <code>Comment</code> that could not be added
166: * @param reason cause of the problem
167: */
168: IllegalAddException(Element base, Comment added, String reason) {
169: super (new StringBuffer().append("The comment \"").append(
170: added.getText()).append(
171: "\" could not be added as content to \"").append(
172: base.getQualifiedName()).append("\": ").append(reason)
173: .toString());
174: }
175:
176: /**
177: * This will create an <code>Exception</code> indicating
178: * that the addition of the <code>{@link CDATA}</code>
179: *
180: * @param base <code>Element</code> that the <code>CDATA</code>
181: * couldn't be added to
182: * @param added <code>CDATA</code> that could not be added
183: * @param reason cause of the problem
184: */
185: IllegalAddException(Element base, CDATA added, String reason) {
186: super (new StringBuffer().append("The CDATA \"").append(
187: added.getText()).append(
188: "\" could not be added as content to \"").append(
189: base.getQualifiedName()).append("\": ").append(reason)
190: .toString());
191: }
192:
193: /**
194: * This will create an <code>Exception</code> indicating
195: * that the addition of the <code>{@link Text}</code>
196: * to the <code>{@link Element}</code> is illegal.
197: *
198: * @param base <code>Element</code> that the <code>Comment</code>
199: * couldn't be added to
200: * @param added <code>Text</code> that could not be added
201: * @param reason cause of the problem
202: */
203: IllegalAddException(Element base, Text added, String reason) {
204: super (new StringBuffer().append("The Text \"").append(
205: added.getText()).append(
206: "\" could not be added as content to \"").append(
207: base.getQualifiedName()).append("\": ").append(reason)
208: .toString());
209: }
210:
211: /**
212: * This will create an <code>Exception</code> indicating
213: * that the addition of the <code>{@link Comment}</code>
214: * to the <code>{@link Document}</code> is illegal.
215: *
216: * @param added <code>Comment</code> that could not be added
217: * @param reason cause of the problem
218: */
219: IllegalAddException(Comment added, String reason) {
220: super (
221: new StringBuffer()
222: .append("The comment \"")
223: .append(added.getText())
224: .append(
225: "\" could not be added to the top level of the document: ")
226: .append(reason).toString());
227: }
228:
229: /**
230: * This will create an <code>Exception</code> indicating
231: * that the addition of the <code>{@link EntityRef}</code>
232: * to the <code>{@link Element}</code> is illegal.
233: *
234: * @param base <code>Element</code> that the <code>EntityRef</code>
235: * couldn't be added to
236: * @param added <code>EntityRef</code> reference that could not be added
237: * @param reason cause of the problem
238: */
239: IllegalAddException(Element base, EntityRef added, String reason) {
240: super (new StringBuffer().append("The entity reference\"")
241: .append(added.getName()).append(
242: "\" could not be added as content to \"")
243: .append(base.getQualifiedName()).append("\": ").append(
244: reason).toString());
245: }
246:
247: /**
248: * This will create an <code>Exception</code> indicating
249: * that the addition of the <code>{@link Namespace}</code>
250: * to the <code>{@link Element}</code> is illegal.
251: *
252: * @param base <code>Element</code> that the <code>Namespace</code>
253: * couldn't be added to
254: * @param added <code>Namespace</code> that could not be added
255: * @param reason cause of the problem
256: */
257: IllegalAddException(Element base, Namespace added, String reason) {
258: super (new StringBuffer().append("The namespace xmlns").append(
259: (added.getPrefix() == null || added.getPrefix().equals(
260: "")) ? "=" : ":" + added.getPrefix() + "=")
261: .append("\"").append(added.getURI()).append(
262: "\" could not be added as a namespace to \"")
263: .append(base.getQualifiedName()).append("\": ").append(
264: reason).toString());
265: }
266:
267: /**
268: * This will create an <code>Exception</code> indicating
269: * that the addition of the <code>{@link DocType}</code>
270: * to the <code>{@link Document}</code> is illegal.
271: *
272: * @param added <code>DocType</code> that could not be added
273: * @param reason cause of the problem
274: */
275: IllegalAddException(DocType added, String reason) {
276: super (new StringBuffer().append("The DOCTYPE ").append(
277: added.toString()).append(
278: " could not be added to the document: ").append(reason)
279: .toString());
280: }
281:
282: /**
283: * This will create an <code>Exception</code> with the specified
284: * error message.
285: *
286: * @param reason cause of the problem
287: */
288: public IllegalAddException(String reason) {
289: super(reason);
290: }
291: }
|