KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > trans > XPathException


1 package net.sf.saxon.trans;
2
3 import net.sf.saxon.om.NamespaceConstant;
4 import net.sf.saxon.value.Value;
5
6 import javax.xml.transform.SourceLocator JavaDoc;
7 import javax.xml.transform.TransformerException JavaDoc;
8
9 /**
10 * XPathException is used to indicate an error in an XPath expression.
11 * We don't distinguish compile-time errors from run-time errors because there are
12 * too many overlaps, e.g. constant expressions can be evaluated at compile-time, and
13 * expressions can be optimised either at compile-time or at run-time.
14 */

15
16 public abstract class XPathException extends TransformerException JavaDoc {
17
18     // Rewritten in 8.3 to remove the dependency on the javax.xml.QName class, which is not present in JDK 1.4
19

20     private boolean isTypeError = false;
21     String JavaDoc errorCodeNamespace;
22     String JavaDoc errorCode;
23     Value errorObject;
24     private boolean hasBeenReported = false;
25
26     public XPathException(String JavaDoc message) {
27         super(message);
28     }
29
30     public XPathException(Throwable JavaDoc err) {
31         super(err);
32     }
33
34     public XPathException(String JavaDoc message, Throwable JavaDoc err) {
35         super(message, err);
36     }
37
38     public XPathException(String JavaDoc message, SourceLocator JavaDoc loc) {
39         super(message, loc);
40     }
41
42     public XPathException(String JavaDoc message, SourceLocator JavaDoc loc, Throwable JavaDoc err) {
43         super(message, loc, err);
44     }
45
46     /**
47      * Force an exception to a static error
48      */

49
50     public StaticError makeStatic() {
51         return new StaticError(this);
52     }
53
54     public void setIsTypeError(boolean is) {
55         isTypeError = is;
56     }
57
58     public boolean isTypeError() {
59         return isTypeError;
60     }
61
62     /**
63      * Set the error code. The error code is a QName; this method sets the local part of the name,
64      * and if no other namespace has been set, it sets the namespace of the error code to the standard
65      * system namespace {@link NamespaceConstant#ERR}
66      * @param code The local part of the name of the error code
67      */

68
69     public void setErrorCode(String JavaDoc code) {
70         if (code != null) {
71             this.errorCode = code;
72             if (errorCodeNamespace == null) {
73                 errorCodeNamespace = NamespaceConstant.ERR;
74             }
75         }
76     }
77
78     /**
79      * Set the error code. The error code is a QName; this method sets both parts of the name.
80      * @param namespace The namespace URI part of the name of the error code
81      * @param code The local part of the name of the error code
82      */

83
84     public void setErrorCode(String JavaDoc namespace, String JavaDoc code) {
85         this.errorCode = code;
86         this.errorCodeNamespace = namespace;
87     }
88
89     /**
90      * Get the local part of the name of the error code
91      * @return the local part of the name of the error code
92      */

93
94     public String JavaDoc getErrorCodeLocalPart() {
95         return errorCode;
96     }
97     
98     /**
99      * Get the namespace URI part of the name of the error code
100      * @return the namespace URI part of the name of the error code
101      */

102
103     public String JavaDoc getErrorCodeNamespace() {
104         return errorCodeNamespace;
105     }
106
107     public void setErrorObject(Value value) {
108         errorObject = value;
109     }
110
111     public Value getErrorObject() {
112         return errorObject;
113     }
114
115     public void setHasBeenReported() {
116         hasBeenReported = true;
117     }
118
119     public boolean hasBeenReported() {
120         return hasBeenReported;
121     }
122
123     /**
124      * Subclass used to report circularities
125      */

126
127     public static class Circularity extends DynamicError {
128         public Circularity(String JavaDoc message) {
129             super(message);
130         }
131     }
132
133 }
134
135 //
136
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
137
// you may not use this file except in compliance with the License. You may obtain a copy of the
138
// License at http://www.mozilla.org/MPL/
139
//
140
// Software distributed under the License is distributed on an "AS IS" basis,
141
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
142
// See the License for the specific language governing rights and limitations under the License.
143
//
144
// The Original Code is: all this file.
145
//
146
// The Initial Developer of the Original Code is Michael H. Kay.
147
//
148
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
149
//
150
// Contributor(s): none.
151
//
152
Popular Tags