01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.elementprocessor;
18:
19: /**
20: * Exception to be thrown when an ElementProcessor cannot be created.
21: *
22: * @author Marc Johnson (marc_johnson27591@hotmail.com)
23: * @version CVS $Id: CannotCreateElementProcessorException.java 433543 2006-08-22 06:22:54Z crossley $
24: */
25: public class CannotCreateElementProcessorException extends Exception {
26: private String _element_name;
27: private String _reason;
28:
29: /**
30: * Constructor
31: *
32: * @param reason a simple explanation why the specified
33: * ElementProcessor could not be created.
34: */
35:
36: public CannotCreateElementProcessorException(final String reason) {
37: _element_name = null;
38: _reason = (reason == null) ? "" : reason;
39: }
40:
41: public void setElementName(final String name) {
42: _element_name = name;
43: }
44:
45: /**
46: * override of Throwable's getMessage; allows us to format it
47: * with the element name
48: *
49: * @return a succinct but useful message describing the
50: * problem and which element name we couldn't handle.
51: */
52:
53: public String getMessage() {
54: StringBuffer buffer = new StringBuffer();
55:
56: buffer.append("Could not create ElementProcessor for element ");
57: buffer.append(_element_name);
58: buffer.append(" ");
59: if (_reason.length() != 0) {
60: buffer.append("(").append(_reason).append(")");
61: }
62: return buffer.toString();
63: }
64: } // end public class CannotCreateElementProcessorException
|