KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > w3c > css > sac > CSSException


1 /*
2  * Copyright (c) 1999 World Wide Web Consortium
3  * (Massachusetts Institute of Technology, Institut National de Recherche
4  * en Informatique et en Automatique, Keio University).
5  * All Rights Reserved. http://www.w3.org/Consortium/Legal/
6  *
7  * The original version of this interface comes from SAX :
8  * http://www.megginson.com/SAX/
9  *
10  * $Id: CSSException.java,v 1.1.1.1 2003/12/28 21:23:46 davidsch Exp $
11  */

12 package org.w3c.css.sac;
13
14 /**
15  * @version $Revision: 1.1.1.1 $
16  * @author Philippe Le Hegaret
17  */

18 public class CSSException extends RuntimeException JavaDoc {
19
20     protected String JavaDoc s;
21
22     /**
23      * this error is unspecified.
24      */

25     public static short SAC_UNSPECIFIED_ERR = 0;
26
27     /**
28      * If the operation is not supported
29      */

30     public static short SAC_NOT_SUPPORTED_ERR = 1;
31
32     /**
33      * If an invalid or illegal string is specified
34      */

35     public static short SAC_SYNTAX_ERR = 2;
36
37     /**
38      * The internal exception.
39      */

40     protected Exception JavaDoc e;
41
42     protected short code;
43
44     /**
45      * Creates a new CSSException
46      */

47     public CSSException() {
48     }
49
50     /**
51      * Creates a new CSSException
52      */

53     public CSSException(String JavaDoc s) {
54     this.code = SAC_UNSPECIFIED_ERR;
55         this.s = s;
56     }
57     
58     /**
59      * Creates a new CSSException with an embeded exception.
60      * @param a the embeded exception.
61      */

62     public CSSException(Exception JavaDoc e) {
63     this.code = SAC_UNSPECIFIED_ERR;
64         this.e = e;
65     }
66
67     /**
68      * Creates a new CSSException with a specific code.
69      * @param a the embeded exception.
70      */

71     public CSSException(short code) {
72         this.code = code;
73     }
74
75     /**
76      * Creates a new CSSException with an embeded exception and a specified
77      * message.
78      * @param code the specified code.
79      * @param e the embeded exception.
80      */

81     public CSSException(short code, String JavaDoc s, Exception JavaDoc e) {
82     this.code = code;
83     this.s = s;
84         this.e = e;
85     }
86
87     /**
88      * Returns the detail message of this throwable object.
89      *
90      * @return the detail message of this Throwable, or null if this Throwable
91      * does not have a detail message.
92      */

93     public String JavaDoc getMessage() {
94     if (s != null) {
95         return s;
96     } else if (e != null) {
97         return e.getMessage();
98     } else {
99         return null;
100     }
101     }
102
103     /**
104      * returns the error code for this exception.
105      */

106     public short getCode() {
107     return code;
108     }
109
110     /**
111      * Returns the internal exception if any, null otherwise.
112      */

113     public Exception JavaDoc getException() {
114     return e;
115     }
116
117 }
118
Popular Tags