001: /* ModificationException.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Thu Aug 8 19:59:53 2002, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2002 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.util;
020:
021: import org.zkoss.lang.CommonException;
022: import org.zkoss.lang.Exceptions;
023: import org.zkoss.lang.Expectable;
024:
025: /**
026: * Denotes a modification fails. It is considered as
027: * a program bug, while {@link InvalidValueException} is considered as
028: * an operational error of user.
029: *
030: * <p>The create, remove and setter method of peristent beans (i3pb) must
031: * declare this exception. Besides this exception and,
032: * {@link InvalidValueException},
033: * org.zkoss.i3.pb.RemoveException and org.zkoss.i3.pb.CreateException,
034: * who derive from this class, might be thrown
035: *
036: * @author tomyeh
037: */
038: public class ModificationException extends CommonException {
039: /** Utilities.
040: *
041: * <p>The reason to use a class to hold static utilities is we can
042: * override the method's return type later.
043: */
044: public static class Aide {
045: /** Converts an exception to ModificationException or InvalidValueException
046: * depending on whether t implements {@link Expectable}.
047: * @see Exceptions#wrap
048: */
049: public static ModificationException wrap(Throwable t) {
050: t = Exceptions.unwrap(t);
051: if (t instanceof Expectable)
052: return (InvalidValueException) Exceptions.wrap(t,
053: InvalidValueException.class);
054: return (ModificationException) Exceptions.wrap(t,
055: ModificationException.class);
056: }
057:
058: /** Converts an exception to ModificationException or InvalidValueException
059: * depending on whether t implements {@link Expectable}.
060: * @see Exceptions#wrap
061: */
062: public static ModificationException wrap(Throwable t, String msg) {
063: t = Exceptions.unwrap(t);
064: if (t instanceof Expectable)
065: return (InvalidValueException) Exceptions.wrap(t,
066: InvalidValueException.class, msg);
067: return (ModificationException) Exceptions.wrap(t,
068: ModificationException.class, msg);
069: }
070:
071: /** Converts an exception to ModificationException or InvalidValueException
072: * depending on whether t implements {@link Expectable}.
073: * @see Exceptions#wrap
074: */
075: public static ModificationException wrap(Throwable t, int code,
076: Object[] fmtArgs) {
077: t = Exceptions.unwrap(t);
078: if (t instanceof Expectable)
079: return (InvalidValueException) Exceptions.wrap(t,
080: InvalidValueException.class, code, fmtArgs);
081: return (ModificationException) Exceptions.wrap(t,
082: ModificationException.class, code, fmtArgs);
083: }
084:
085: /** Converts an exception to ModificationException or InvalidValueException
086: * depending on whether t implements {@link Expectable}.
087: * @see Exceptions#wrap
088: */
089: public static ModificationException wrap(Throwable t, int code,
090: Object fmtArg) {
091: t = Exceptions.unwrap(t);
092: if (t instanceof Expectable)
093: return (InvalidValueException) Exceptions.wrap(t,
094: InvalidValueException.class, code, fmtArg);
095: return (ModificationException) Exceptions.wrap(t,
096: ModificationException.class, code, fmtArg);
097: }
098:
099: /** Converts an exception to ModificationException or InvalidValueException
100: * depending on whether t implements {@link Expectable}.
101: * @see Exceptions#wrap
102: */
103: public static ModificationException wrap(Throwable t, int code) {
104: t = Exceptions.unwrap(t);
105: if (t instanceof Expectable)
106: return (InvalidValueException) Exceptions.wrap(t,
107: InvalidValueException.class, code);
108: return (ModificationException) Exceptions.wrap(t,
109: ModificationException.class, code);
110: }
111: }
112:
113: public ModificationException(String msg, Throwable cause) {
114: super (msg, cause);
115: }
116:
117: public ModificationException(String s) {
118: super (s);
119: }
120:
121: public ModificationException(Throwable cause) {
122: super (cause);
123: }
124:
125: public ModificationException() {
126: }
127:
128: public ModificationException(int code, Object[] fmtArgs,
129: Throwable cause) {
130: super (code, fmtArgs, cause);
131: }
132:
133: public ModificationException(int code, Object fmtArg,
134: Throwable cause) {
135: super (code, fmtArg, cause);
136: }
137:
138: public ModificationException(int code, Object[] fmtArgs) {
139: super (code, fmtArgs);
140: }
141:
142: public ModificationException(int code, Object fmtArg) {
143: super (code, fmtArg);
144: }
145:
146: public ModificationException(int code, Throwable cause) {
147: super (code, cause);
148: }
149:
150: public ModificationException(int code) {
151: super(code);
152: }
153: }
|