001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com> and
003: * JR Boyens <gnu-jrb[remove] at gmx dot net>
004: * Distributed under the terms of either:
005: * - the common development and distribution license (CDDL), v1.0; or
006: * - the GNU Lesser General Public License, v2.1 or later
007: * $Id: CallbacksProviderBean.java 3669 2007-02-26 13:51:23Z gbevin $
008: */
009: package com.uwyn.rife.database.querymanagers.generic.beans;
010:
011: import java.util.ArrayList;
012: import java.util.List;
013:
014: import com.uwyn.rife.database.querymanagers.generic.Callbacks;
015: import com.uwyn.rife.database.querymanagers.generic.CallbacksProvider;
016:
017: public class CallbacksProviderBean implements
018: CallbacksProvider<CallbacksProviderBean> {
019: private int mId = -1;
020: private String mTestString = null;
021:
022: static TheCallbacks mCallbacks = new TheCallbacks();
023:
024: public CallbacksProviderBean() {
025: }
026:
027: public void setId(int id) {
028: mId = id;
029: }
030:
031: public int getId() {
032: return mId;
033: }
034:
035: public Callbacks<CallbacksProviderBean> getCallbacks() {
036: return mCallbacks;
037: }
038:
039: public void setTestString(String testString) {
040: this .mTestString = testString;
041: }
042:
043: public String getTestString() {
044: return mTestString;
045: }
046:
047: public String toString() {
048: return mId + ";" + mTestString;
049: }
050:
051: public static List<String> getExecutedCallbacks() {
052: return mCallbacks.getExecutedCallbacks();
053: }
054:
055: public static void clearExecuteCallbacks() {
056: mCallbacks.clearExecuteCallbacks();
057: }
058:
059: public static class TheCallbacks implements
060: Callbacks<CallbacksProviderBean> {
061: private List<String> mExecutedCallbacks = new ArrayList<String>();
062:
063: public List<String> getExecutedCallbacks() {
064: return mExecutedCallbacks;
065: }
066:
067: public void clearExecuteCallbacks() {
068: mExecutedCallbacks = new ArrayList<String>();
069: }
070:
071: public boolean beforeValidate(CallbacksProviderBean object) {
072: mExecutedCallbacks.add("beforeValidate "
073: + object.toString());
074: return true;
075: }
076:
077: public boolean beforeInsert(CallbacksProviderBean object) {
078: mExecutedCallbacks.add("beforeInsert " + object.toString());
079: return true;
080: }
081:
082: public boolean beforeDelete(int objectId) {
083: mExecutedCallbacks.add("beforeDelete " + objectId);
084: return true;
085: }
086:
087: public boolean beforeSave(CallbacksProviderBean object) {
088: mExecutedCallbacks.add("beforeSave " + object.toString());
089: return true;
090: }
091:
092: public boolean beforeUpdate(CallbacksProviderBean object) {
093: mExecutedCallbacks.add("beforeUpdate " + object.toString());
094: return true;
095: }
096:
097: public boolean afterValidate(CallbacksProviderBean object) {
098: mExecutedCallbacks
099: .add("afterValidate " + object.toString());
100: return true;
101: }
102:
103: public boolean afterInsert(CallbacksProviderBean object,
104: boolean success) {
105: mExecutedCallbacks.add("afterInsert " + success + " "
106: + object.toString());
107: return true;
108: }
109:
110: public boolean afterDelete(int objectId, boolean success) {
111: mExecutedCallbacks.add("afterDelete " + success + " "
112: + objectId);
113: return true;
114: }
115:
116: public boolean afterSave(CallbacksProviderBean object,
117: boolean success) {
118: mExecutedCallbacks.add("afterSave " + success + " "
119: + object.toString());
120: return true;
121: }
122:
123: public boolean afterUpdate(CallbacksProviderBean object,
124: boolean success) {
125: mExecutedCallbacks.add("afterUpdate " + success + " "
126: + object.toString());
127: return true;
128: }
129:
130: public boolean afterRestore(CallbacksProviderBean object) {
131: mExecutedCallbacks.add("afterRestore " + object.toString());
132: return true;
133: }
134: }
135: }
|