1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
/*
* Copyright (c) 1999 World Wide Web Consortium
* (Massachusetts Institute of Technology, Institut National de Recherche
* en Informatique et en Automatique, Keio University).
* All Rights Reserved. http://www.w3.org/Consortium/Legal/
*
* The original version of this interface comes from SAX :
* http://www.megginson.com/SAX/
*
* $Id: CSSException.java,v 1.3 2002/06/17 14:09:36 plehegar Exp $
*/
package org.w3c.css.sac;
/**
* @version $Revision: 1.3 $
* @author Philippe Le Hegaret
*/
public class CSSException extends RuntimeException {
protected String s;
/**
* this error is unspecified.
*/
public static final short SAC_UNSPECIFIED_ERR = 0;
/**
* If the operation is not supported
*/
public static final short SAC_NOT_SUPPORTED_ERR = 1;
/**
* If an invalid or illegal string is specified
*/
public static final short SAC_SYNTAX_ERR = 2;
/*
* Default message for unspecified error.
*/
protected static final String S_SAC_UNSPECIFIED_ERR
= "unknown error";
/*
* Default message for not supported error.
*/
protected static final String S_SAC_NOT_SUPPORTED_ERR
= "not supported";
/*
* Default message for syntax error.
*/
protected static final String S_SAC_SYNTAX_ERR
= "syntax error";
/**
* The internal exception.
*/
protected Exception e;
protected short code;
/**
* Creates a new CSSException
*/
public CSSException() {
}
/**
* Creates a new CSSException
*/
public CSSException(String s) {
this.code = SAC_UNSPECIFIED_ERR;
this.s = s;
}
/**
* Creates a new CSSException with an embeded exception.
* @param a the embeded exception.
*/
public CSSException(Exception e) {
this.code = SAC_UNSPECIFIED_ERR;
this.e = e;
}
/**
* Creates a new CSSException with a specific code.
* @param a the embeded exception.
*/
public CSSException(short code) {
this.code = code;
}
/**
* Creates a new CSSException with an embeded exception and a specified
* message.
* @param code the specified code.
* @param e the embeded exception.
*/
public CSSException(short code, String s, Exception e) {
this.code = code;
this.s = s;
this.e = e;
}
/**
* Returns the detail message of this throwable object.
*
* @return the detail message of this Throwable, or null if this Throwable
* does not have a detail message.
*/
public String getMessage() {
if (s != null) {
return s;
} else if (e != null) {
return e.getMessage();
} else {
switch (code) {
case SAC_UNSPECIFIED_ERR:
return S_SAC_UNSPECIFIED_ERR;
case SAC_NOT_SUPPORTED_ERR:
return S_SAC_NOT_SUPPORTED_ERR;
case SAC_SYNTAX_ERR:
return S_SAC_SYNTAX_ERR;
default:
return null;
}
}
}
/**
* returns the error code for this exception.
*/
public short getCode() {
return code;
}
/**
* Returns the internal exception if any, null otherwise.
*/
public Exception getException() {
return e;
}
}
|