KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Corresponds to the <Delete> element in the SyncML represent DTD
24  *
25  * @author Stefano Fornari @ Funambol
26  *
27  * @version $Id: Delete.java,v 1.4 2005/03/02 20:57:37 harrie Exp $
28  */

29 public final class Delete
30 extends ModificationCommand
31 implements java.io.Serializable JavaDoc {
32     
33     // --------------------------------------------------------------- Constants
34
/** Command name */
35     public static final String JavaDoc COMMAND_NAME = "Delete";
36
37     // ------------------------------------------------------------ Private data
38
private Boolean JavaDoc archive;
39     private Boolean JavaDoc sftDel;
40     
41     // ------------------------------------------------------------ Constructors
42
/** For serialization purposes */
43     protected Delete() {}
44
45     /**
46      * Creates a new Delete object with the given command identifier,
47      * noResponse, archiveData, softDelete, credential, meta and array of item
48      *
49      * @param cmdID the command identifier - NOT NULL
50      * @param noResp true if no response is required
51      * @param archive true if the deleted data should be archived
52      * @param sftDel true if this is a "soft delete". If set to false, then
53      * this delete command is a "hard delete"
54      * @param cred the authentication credential
55      * @param meta the meta data
56      * @param items the array of item - NOT NULL
57      *
58      */

59     public Delete(final CmdID cmdID,
60                   final boolean noResp,
61                   final boolean archive,
62                   final boolean sftDel,
63                   final Cred cred,
64                   final Meta meta,
65                   final Item[] items) {
66         super(cmdID, meta, items);
67         
68         setCred(cred);
69         this.noResp = (noResp) ? new Boolean JavaDoc(noResp) : null;
70         this.archive = (archive) ? new Boolean JavaDoc(archive) : null;
71         this.sftDel = (sftDel) ? new Boolean JavaDoc(sftDel) : null;
72     }
73
74     // ---------------------------------------------------------- Public methods
75

76     /**
77      * Gets the command name property
78      *
79      * @return the command name property
80      */

81     public String JavaDoc getName() {
82         return Delete.COMMAND_NAME;
83     }
84
85     /**
86      * Gets the Archive property
87      *
88      * @return true if the deleted data should be archived
89      */

90     public boolean isArchive() {
91         return (archive != null);
92     }
93
94     /**
95      * Gets the Boolean archive property
96      *
97      * @return archive the Boolean archive property
98      */

99     public Boolean JavaDoc getArchive() {
100         if (!archive.booleanValue()) {
101             return null;
102         }
103         return archive;
104     }
105
106     /**
107      * Sets the archive property
108      *
109      * @param archive the Boolean archive object
110      */

111     public void setArchive(Boolean JavaDoc archive) {
112         this.archive = (archive.booleanValue()) ? archive : null;
113     }
114     
115     /**
116      * Gets the SftDel property
117      *
118      * @return <b>true</b> if this is a "Soft delete"
119      * <b>false</b> if this is a "hard delete"
120      */

121     public boolean isSftDel() {
122         return (sftDel != null);
123     }
124
125     public Boolean JavaDoc getSftDel() {
126         if (!sftDel.booleanValue()) {
127             return null;
128         }
129         return sftDel;
130     }
131     
132
133     public void setSftDel(Boolean JavaDoc sftDel) {
134         this.sftDel = (sftDel.booleanValue()) ? sftDel : null;
135     }
136 }
137
Popular Tags