KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > storage > api > LifeCycleEvent


1 /*
2 * CLIF is a Load Injection Framework
3 * Copyright (C) 2003,2004 France Telecom R&D
4 * Copyright (C) 2003 INRIA
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * CLIF $Name: $
21 *
22 * Contact: clif@objectweb.org
23 */

24
25 package org.objectweb.clif.storage.api;
26
27 import org.objectweb.clif.supervisor.api.BladeState;
28
29
30 /**
31  * This class represents the different events
32  *
33  * @author Julien Buret
34  * @author Nicolas Droze
35  * @author Bruno Dillenseger
36  */

37 public class LifeCycleEvent extends AbstractEvent
38 {
39     static public final String JavaDoc EVENT_TYPE_LABEL = "lifecycle";
40     static private final String JavaDoc[] EVENT_FIELD_LABELS =
41         new String JavaDoc[] { "date", "blade id", "state" };
42
43
44     static
45     {
46         AbstractEvent.registerEventFieldLabels(
47             EVENT_TYPE_LABEL,
48             EVENT_FIELD_LABELS);
49     }
50
51
52     protected BladeState state;
53
54
55     public LifeCycleEvent(long date, String JavaDoc bladeId, BladeState state)
56     {
57         super(date, bladeId);
58         this.state = state;
59     }
60
61
62     public String JavaDoc getTypeLabel()
63     {
64         return EVENT_TYPE_LABEL;
65     }
66
67
68     public int getStateId()
69     {
70         return state.getCode();
71     }
72
73
74     public String JavaDoc toString()
75     {
76         return toString(0, ";");
77     }
78
79
80     public String JavaDoc toString(long dateOrigin, String JavaDoc separator)
81     {
82         return
83             (date - dateOrigin) + separator
84             + bladeId + separator
85             + state.getCode() + separator
86             + state;
87     }
88 }
89
Popular Tags