~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/jgdi/src/com/sun/grid/jgdi/event/ChangedObjectEvent.java

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 *
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 *
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 *
 
9
 *
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 *
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 *
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 *
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 *
 
28
 *   All Rights Reserved.
 
29
 *
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
package com.sun.grid.jgdi.event;
 
33
 
 
34
/**
 
35
 * Base class of all events which signalizes a changes of
 
36
 * objects in the Sun [tm] Grid Engine.
 
37
 *
 
38
 */
 
39
public abstract class ChangedObjectEvent extends Event implements java.io.Serializable {
 
40
    
 
41
    /** the new version of the changed objects */
 
42
    private Object changedObject;
 
43
    private Class objectType;
 
44
    
 
45
    /**
 
46
     * Creates a new instance of ChangedObjectEvent
 
47
     * @param eventType   type of event
 
48
     * @param timestamp   timestamp when the event occured
 
49
     * @param eventId     id of the event
 
50
     * @param objectType  type of the changed objects
 
51
     */
 
52
    public ChangedObjectEvent(EventType eventType, long timestamp, int eventId, Class objectType) {
 
53
        super(eventType, timestamp, eventId);
 
54
        this.objectType = objectType;
 
55
    }
 
56
    
 
57
    /**
 
58
     *  Get the type of the changed objects
 
59
     *  @return type of the changed objects
 
60
     */
 
61
    public Class getObjectType() {
 
62
        return objectType;
 
63
    }
 
64
    
 
65
    /**
 
66
     *  Set the new version of the changed object
 
67
     *  @param changedObj  the changed object
 
68
     *  @throws IllegalArgumentException if <code>changedObj</code> is <code>null</code>
 
69
     *  @throws IllegalArgumentException if the class object type for the event is not
 
70
     *                                   assignable from the class of <code>changedObj</code>
 
71
     *  @see #getObjectType
 
72
     */
 
73
    public void setChangedObject(Object changedObj) {
 
74
        if (changedObj == null) {
 
75
            throw new IllegalArgumentException("changedObj must not be null");
 
76
        }
 
77
        if (!objectType.isAssignableFrom(changedObj.getClass())) {
 
78
            throw new IllegalArgumentException("changedObj must instanceof " + objectType.getName());
 
79
        }
 
80
        this.changedObject = changedObj;
 
81
    }
 
82
    
 
83
    /**
 
84
     *  Get the new version of the changed object which has been changed by this event
 
85
     *  @return list of changed objects
 
86
     */
 
87
    public Object getChangedObject() {
 
88
        return changedObject;
 
89
    }
 
90
    
 
91
    public String toString() {
 
92
        StringBuilder ret = new StringBuilder();
 
93
        ret.append("[");
 
94
        ret.append(super.toString());
 
95
        ret.append(", ");
 
96
        ret.append(changedObject);
 
97
        ret.append("]");
 
98
        return ret.toString();
 
99
    }
 
100
    
 
101
    /**
 
102
     *  Set the primary key information of the changed object into the event.
 
103
     *
 
104
     *  <p>This method is called from the the native part of jgdi to fill the
 
105
     *     primary key information into a del event</p>
 
106
     *
 
107
     *  @param  numKey1  first numerical primary key of the deleted object
 
108
     *  @param  numKey2  second numerical primary key of the deleted object
 
109
     *  @param  strKey1  first string primary key of the deleted object
 
110
     *  @param  strKey2  second string primary key of the deleted object
 
111
     */
 
112
    public abstract void setPKInfo(int numKey1, int numKey2, String strKey1, String strKey2);
 
113
}