KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > xml > XmlBeanDefinitionStoreException


1 /*
2  * Copyright 2002-2006 the original author or authors.
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
17 package org.springframework.beans.factory.xml;
18
19 import org.xml.sax.SAXException JavaDoc;
20 import org.xml.sax.SAXParseException JavaDoc;
21
22 import org.springframework.beans.factory.BeanDefinitionStoreException;
23
24 /**
25  * XML-specific BeanDefinitionStoreException subclass that wraps a
26  * {@link org.xml.sax.SAXException}, typically a {@link org.xml.sax.SAXParseException}
27  * which contains information about the error location.
28  *
29  * @author Juergen Hoeller
30  * @since 2.0.2
31  * @see #getLineNumber()
32  * @see org.xml.sax.SAXParseException
33  */

34 public class XmlBeanDefinitionStoreException extends BeanDefinitionStoreException {
35
36     /**
37      * Create a new XmlBeanDefinitionStoreException.
38      * @param resourceDescription description of the resource that the bean definition came from
39      * @param msg the detail message (used as exception message as-is)
40      * @param cause the SAXException (typically a SAXParseException) root cause
41      * @see org.xml.sax.SAXParseException
42      */

43     public XmlBeanDefinitionStoreException(String JavaDoc resourceDescription, String JavaDoc msg, SAXException JavaDoc cause) {
44         super(resourceDescription, msg, cause);
45     }
46
47     /**
48      * Return the line number in the XML resource that failed.
49      * @return the line number if available (in case of a SAXParseException); -1 else
50      * @see org.xml.sax.SAXParseException#getLineNumber()
51      */

52     public int getLineNumber() {
53         Throwable JavaDoc cause = getCause();
54         if (cause instanceof SAXParseException JavaDoc) {
55             return ((SAXParseException JavaDoc) cause).getLineNumber();
56         }
57         return -1;
58     }
59
60 }
61
Popular Tags