KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > engine > dm > DeviceDMState


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.framework.engine.dm;
20
21 import java.util.Date JavaDoc;
22
23 import java.io.Serializable JavaDoc;
24 import org.apache.commons.lang.builder.ToStringBuilder;
25
26 /**
27  * This class represents the device's DM state.
28  *
29  * @author Stefano Fornari @ Funambol
30  *
31  * @version $Id: DeviceDMState.java,v 1.1 2005/05/16 17:32:55 nichele Exp $
32  *
33  */

34 public class DeviceDMState implements Serializable JavaDoc {
35
36     // --------------------------------------------------------------- Constants
37

38     public static final byte STATE_UNKNOWN = '-';
39     public static final byte STATE_UNMANAGEABLE = 'U';
40     public static final byte STATE_MANAGEABLE = 'M';
41     public static final byte STATE_NOTIFIED = 'N';
42     public static final byte STATE_IN_PROGRESS = 'P';
43     public static final byte STATE_COMPLETED = 'C';
44     public static final byte STATE_ERROR = 'E';
45     public static final byte STATE_ABORTED = 'A';
46
47     public static final String JavaDoc PROPERTY_STATE = "state" ;
48     public static final String JavaDoc PROPERTY_SESSION_ID = "mssid" ;
49     public static final String JavaDoc PROPERTY_DEVICE_ID = "device";
50
51     // ------------------------------------------------------------- Public data
52

53     public String JavaDoc id ;
54     public String JavaDoc deviceId ;
55     public String JavaDoc mssid ;
56     public byte state ;
57     public Date JavaDoc start ;
58     public Date JavaDoc end ;
59     public String JavaDoc operation ;
60     public String JavaDoc info ;
61
62     // ------------------------------------------------------------- Costructors
63

64     /** Creates a new instance of Sync4jDevice */
65     public DeviceDMState() {
66         init(null, null, STATE_UNKNOWN, null, null, null, null);
67     }
68
69     /**
70      * Creates a new instance of Sync4jDevice for a give device
71      *
72      * @param deviceId the device id
73      */

74     public DeviceDMState(String JavaDoc deviceId) {
75         init(deviceId, null, STATE_UNKNOWN, null, null, null, null);
76     }
77
78     // ---------------------------------------------------------- Public methods
79

80     /**
81      * Copies the given object into this.
82      *
83      * @param dms the DeviceDMState to copy from
84      */

85     public void copyFrom(DeviceDMState dms) {
86         this.id = dms.id ;
87         this.deviceId = dms.deviceId ;
88         this.mssid = dms.mssid ;
89         this.state = dms.state ;
90         this.start = dms.start ;
91         this.end = dms.end ;
92         this.operation = dms.operation;
93         this.info = dms.info ;
94     }
95     // --------------------------------------------------------- Private methods
96

97     /**
98      * Init method.
99      *
100      * @param deviceId device id
101      * @param mssid management server session id
102      * @param state state
103      * @param start session start
104      * @param end session end
105      * @param operation application specific management operation
106      * @param info application specific details
107      *
108      */

109     private void init(String JavaDoc deviceId ,
110                       String JavaDoc mmsid ,
111                       byte state ,
112                       Date JavaDoc start ,
113                       Date JavaDoc end ,
114                       String JavaDoc operation,
115                       String JavaDoc info ) {
116         this.deviceId = deviceId ;
117         this.mssid = mssid ;
118         this.state = state ;
119         this.start = start ;
120         this.end = end ;
121         this.operation = operation;
122         this.info = info ;
123     }
124
125
126     // -------------------------------------------------------------- toString()
127
public String JavaDoc toString() {
128         ToStringBuilder sb = new ToStringBuilder(this);
129
130         sb.append("deviceId", deviceId );
131         sb.append("mssid", mssid );
132         sb.append("state", (char)state);
133         sb.append("start", start );
134         sb.append("end", end );
135         sb.append("operation", operation );
136         sb.append("info", info );
137
138         return sb.toString();
139     }
140
141 }
Popular Tags