01: package org.drools.audit.event;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * An object event logged by the WorkingMemoryLogger.
21: * It is a snapshot of the event as it was thrown by the working memory.
22: * It contains the fact id and a String represention of the object
23: * at the time the event was logged.
24: *
25: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen </a>
26: */
27: public class ObjectLogEvent extends LogEvent {
28:
29: private long factId;
30: private String objectToString;
31:
32: /**
33: * Create a new activation log event.
34: *
35: * @param type The type of event. This can only be LogEvent.OBJECT_ASSERTED,
36: * LogEvent.OBJECT_MODIFIED or LogEvent.OBJECT_RETRACTED.
37: * @param factId The id of the fact
38: * @param objectToString A toString of the fact
39: */
40: public ObjectLogEvent(final int type, final long factId,
41: final String objectToString) {
42: super (type);
43: this .factId = factId;
44: this .objectToString = objectToString;
45: }
46:
47: /**
48: * Returns the fact id of the object this event is about.
49: *
50: * @return the id of the fact
51: */
52: public long getFactId() {
53: return this .factId;
54: }
55:
56: /**
57: * Returns a toString of the fact this event is about at the
58: * time the event was created.
59: *
60: * @return the toString of the fact
61: */
62: public String getObjectToString() {
63: return this .objectToString;
64: }
65:
66: public String toString() {
67: String msg = null;
68: switch (this .getType()) {
69: case INSERTED:
70: msg = "OBJECT ASSERTED";
71: break;
72: case UPDATED:
73: msg = "OBJECT MODIFIED";
74: break;
75:
76: case RETRACTED:
77: msg = "OBJECT RETRACTED";
78: break;
79: }
80: return msg + " value:" + this .objectToString + " factId: "
81: + this.factId;
82:
83: }
84: }
|