KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > elementprocessor > CannotCreateElementProcessorException


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.elementprocessor;
17
18 /**
19  * Exception to be thrown when an ElementProcessor cannot be created.
20  *
21  * @author Marc Johnson (marc_johnson27591@hotmail.com)
22  * @version CVS $Id: CannotCreateElementProcessorException.java 30932 2004-07-29 17:35:38Z vgritsenko $
23  */

24 public class CannotCreateElementProcessorException
25         extends Exception JavaDoc
26 {
27     private String JavaDoc _element_name;
28     private String JavaDoc _reason;
29
30     /**
31      * Constructor
32      *
33      * @param reason a simple explanation why the specified
34      * ElementProcessor could not be created.
35      */

36
37     public CannotCreateElementProcessorException(final String JavaDoc reason)
38     {
39         _element_name = null;
40         _reason = (reason == null) ? "" : reason;
41     }
42
43     public void setElementName(final String JavaDoc name)
44     {
45         _element_name = name;
46     }
47
48     /**
49      * override of Throwable's getMessage; allows us to format it
50      * with the element name
51      *
52      * @return a succinct but useful message describing the
53      * problem and which element name we couldn't handle.
54      */

55
56     public String JavaDoc getMessage()
57     {
58         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
59
60         buffer.append("Could not create ElementProcessor for element ");
61         buffer.append(_element_name);
62         buffer.append(" ");
63         if (_reason.length() != 0) {
64             buffer.append("(").append(_reason).append(")");
65         }
66         return buffer.toString();
67     }
68 } // end public class CannotCreateElementProcessorException
69
Popular Tags