01: /* DOMException.java
02:
03: {{IS_NOTE
04:
05: Purpose:
06: Description:
07: History:
08: 2001/09/28 14:04:16, Create, Tom M. Yeh.
09: }}IS_NOTE
10:
11: Copyright (C) 2001 Potix Corporation. All Rights Reserved.
12:
13: {{IS_RIGHT
14: This program is distributed under GPL Version 2.0 in the hope that
15: it will be useful, but WITHOUT ANY WARRANTY.
16: }}IS_RIGHT
17: */
18: package org.zkoss.idom;
19:
20: import org.xml.sax.Locator;
21:
22: import org.zkoss.lang.Objects;
23: import org.zkoss.idom.util.SimpleLocator;
24:
25: /**
26: * Denotes an operation is not supported.
27: *
28: * @author tomyeh
29: */
30: public class DOMException extends org.w3c.dom.DOMException {
31: protected Locator _loc;
32:
33: public DOMException(short code) {
34: super (code, message(code, null, null));
35: }
36:
37: public DOMException(short code, String extraMsg) {
38: super (code, message(code, extraMsg, null));
39: }
40:
41: public DOMException(short code, Locator loc) {
42: super (code, message(code, null, loc));
43: _loc = loc;
44: }
45:
46: public DOMException(short code, String extraMsg, Locator loc) {
47: super (code, message(code, extraMsg, loc));
48: _loc = loc;
49: }
50:
51: private static final String message(short code, String extraMsg,
52: Locator loc) {
53: StringBuffer sb = new StringBuffer(64);
54: switch (code) {
55: case HIERARCHY_REQUEST_ERR:
56: sb.append("Hierarchy request error");
57: break;
58: case INVALID_ACCESS_ERR:
59: sb.append("Invalid access to the underly object");
60: break;
61: case INVALID_CHARACTER_ERR:
62: sb.append("Invalid character(s)");
63: break;
64: case NAMESPACE_ERR:
65: sb.append("Namespace error");
66: break;
67: case NO_DATA_ALLOWED_ERR:
68: sb.append("Data not allowed");
69: break;
70: case NO_MODIFICATION_ALLOWED_ERR:
71: sb.append("No modification allowed");
72: break;
73: case NOT_FOUND_ERR:
74: sb.append("Not found");
75: break;
76: case NOT_SUPPORTED_ERR:
77: sb.append("Not supported yet");
78: break;
79: case SYNTAX_ERR:
80: sb.append("Syntax error");
81: break;
82: default:
83: sb.append("Unknown error");
84: break;
85: }
86: if (extraMsg != null)
87: sb.append(": ").append(extraMsg);
88:
89: if (loc != null) {
90: if (sb.length() > 0)
91: sb.append(' ');
92:
93: sb.append(SimpleLocator.toString(loc));
94: }
95: return sb.toString();
96: }
97: }
|