KickJava   Java API By Example, From Geeks To Geeks.

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


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

29 public final class DSMem
30 implements java.io.Serializable JavaDoc {
31     
32     // ------------------------------------------------------------ Private data
33
private Boolean JavaDoc sharedMem;
34     private long maxMem ;
35     private long maxID ;
36     
37     // ------------------------------------------------------------ Constructors
38

39     /** For serialization purposes */
40     protected DSMem() {}
41
42     /**
43      * Creates a new DSMem object with the given sharedMem, maxMem and maxID
44      *
45      * @param sharedMem is true if the datastore uses shared memory
46      * @param maxMem the maximum memory size for o given datastore
47      * @param maxID the maximum number of items that can be stored in a given
48      * datastore
49      *
50      */

51     public DSMem(final boolean sharedMem, final long maxMem, final long maxID) {
52         setMaxMem(maxMem);
53         setMaxID(maxID);
54         this.sharedMem = (sharedMem) ? new Boolean JavaDoc(sharedMem) : null;
55
56     }
57
58     // ---------------------------------------------------------- Public methods
59

60     /**
61      * Returns the memoryShared status
62      *
63      * @return <i>true</i> if the datastore memory is shared, <i>false</i> otherwise
64      */

65     public boolean isSharedMem() {
66         return (sharedMem != null);
67     }
68     
69     /**
70      * Sets the memoryShared status
71      *
72      * @param sharedMem the new memoryShared status
73      */

74     public void setSharedMem(Boolean JavaDoc sharedMem) {
75         this.sharedMem = (sharedMem.booleanValue()) ? sharedMem : null;
76     }
77     
78     /**
79      * Gets Boolean shared memory
80      *
81      * @return sharedMem the Boolean sharedMem
82      */

83     public Boolean JavaDoc getSharedMem() {
84         if (!sharedMem.booleanValue()) {
85             return null;
86         }
87         return sharedMem;
88     }
89         
90     /**
91      * Gets the maximum memory size in bytes
92      *
93      * @return if value is -1 indicates that the property value is unspecified
94      */

95     public long getMaxMem() {
96         return this.maxMem;
97     }
98     
99     /**
100      * Sets the max memory property
101      *
102      * @param maxMem the value of max memory property
103      *
104      */

105     public void setMaxMem(long maxMem) {
106         this.maxMem = maxMem;
107     }
108
109     /**
110      * Gets the maximum number of items
111      *
112      * @return if value is -1 indicates that the property value is unspecified
113      */

114     public long getMaxID() {
115         return this.maxID;
116     }
117     
118     /**
119      * Sets the max ID property
120      *
121      * @param maxID the value of maxID property
122      */

123     public void setMaxID(long maxID) {
124         this.maxID = maxID;
125     }
126 }
127
Popular Tags