KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > core > CmdID


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
20 package sync4j.framework.core;
21
22 /**
23  * This class represents the <CmdID> element specified by the
24  * SyncML representation DTD
25  *
26  * @author Stefano Fornari @ Funambol
27  *
28 * @version $Id: CmdID.java,v 1.3 2005/03/02 20:57:37 harrie Exp $
29  */

30 public final class CmdID
31 implements java.io.Serializable JavaDoc {
32     
33     // ------------------------------------------------------------ Private data
34
private String JavaDoc cmdID;
35
36     // ------------------------------------------------------------ Constructors
37
/** For serialization purposes */
38     protected CmdID() {}
39
40     /**
41      * Creates a new CmdID object with the given String cmdID
42      *
43      * @param cmdID the cmdID of CmdID - NOT NULL
44      *
45      */

46     public CmdID(final String JavaDoc cmdID) {
47         if ((cmdID == null) || (cmdID.length() == 0)) {
48             throw new IllegalArgumentException JavaDoc("cmdID cannot be empty");
49         }
50         this.cmdID = cmdID;
51     }
52
53     /**
54      * Creates a new CmdID object with the given numeric cmdID
55      *
56      * @param cmdID the cmdID of CmdID
57      *
58      */

59     public CmdID(final long cmdID) {
60         this(String.valueOf(cmdID));
61     }
62
63     // ---------------------------------------------------------- Public methods
64

65     /**
66      * Gets cmdID properties
67      *
68      * @return cmdID properties
69      */

70     public String JavaDoc getCmdID() {
71         return this.cmdID;
72     }
73
74     /**
75      * Compares the string cmdID to the specified input object.
76      *
77      * @param object the object to be compared
78      *
79      * @return true if the specified input object equals the cmdID of the
80      * CmdID
81      *
82      */

83     public boolean equals(Object JavaDoc object) {
84         String JavaDoc cmdID = null;
85
86         if (object instanceof String JavaDoc) {
87             cmdID = (String JavaDoc)object;
88         } else if (object instanceof CmdID) {
89             cmdID = ((CmdID)object).getCmdID();
90         }
91
92         return (cmdID == null) ? false : cmdID.equals(cmdID);
93     }
94 }
Popular Tags