KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.*;
23
24 /**
25  * This class represents the content type property such as property name, value,
26  * display name, size and the content type parameters
27  *
28  * @author Stefano Fornari @ Funambol
29  *
30  * @version $Id: CTPropParam.java,v 1.4 2005/03/02 20:57:37 harrie Exp $
31  */

32 public final class CTPropParam
33 implements java.io.Serializable JavaDoc {
34     
35     // ------------------------------------------------------------ Private data
36
private String JavaDoc propName;
37     private ArrayList valEnum = new ArrayList();
38     private String JavaDoc displayName;
39     private String JavaDoc dataType;
40     private int size;
41     private ArrayList ctParameters = new ArrayList();
42     
43     // ------------------------------------------------------------ Constructors
44

45     /** For serialization purposes */
46     protected CTPropParam() {}
47
48     /**
49      * Creates a new ContentTypeProperty object with the given name, value and
50      * display name
51      *
52      * @param propName corresponds to <PropName> element in the SyncML
53      * specification - NOT NULL
54      * @param valEnum corresponds to <ValEnum> element in the SyncML
55      * specification
56      * @param displayName corresponds to <DisplayName> element in the SyncML
57      * specification
58      * @param ctParameters the array of content type parameters - NOT NULL
59      *
60      */

61     public CTPropParam(final String JavaDoc propName,
62                        final String JavaDoc[] valEnum,
63                        final String JavaDoc displayName,
64                        final ContentTypeParameter[] ctParameters) {
65         setPropName(propName);
66         setValEnum(valEnum);
67         setContentTypeParameters(ctParameters);
68         
69         this.displayName = displayName;
70     }
71
72     
73     /**
74      * Creates a new ContentTypeProperty object with the given name, value and
75      * display name
76      *
77      * @param propName corresponds to <PropName> element in the SyncML
78      * specification - NOT NULL
79      * @param dataType corresponds to <DataType> element in the SyncML
80      * specification
81      * @param size corresponds to <Size> element in the SyncML
82      * specification
83      * @param displayName corresponds to <DisplayName> element in the SyncML
84      * specification
85      * @param ctParameters the array of content type parameters - NOT NULL
86      *
87      */

88     public CTPropParam(final String JavaDoc propName,
89                        final String JavaDoc dataType,
90                        final int size,
91                        final String JavaDoc displayName,
92                        final ContentTypeParameter[] ctParameters) {
93         
94         setPropName(propName);
95         setContentTypeParameters(ctParameters);
96         
97         this.dataType = dataType;
98         this.size = size;
99         this.displayName = displayName;
100     }
101
102     // ---------------------------------------------------------- Public methods
103

104     /**
105      * Gets the property name
106      *
107      * @return the property name
108      */

109     public String JavaDoc getPropName() {
110         return propName;
111     }
112     
113     /**
114      * Sets the property name
115      *
116      * @param propName the property name
117      */

118     public void setPropName(String JavaDoc propName) {
119         if (propName == null){
120             throw new IllegalArgumentException JavaDoc("propName cannot be null");
121         }
122         this.propName = propName;
123     }
124     
125     /**
126      * Gets the array of value for the property
127      *
128      * @return the array of value for the property
129      */

130     public ArrayList getValEnum() {
131         return this.valEnum;
132     }
133     
134     /**
135      * Sets the array of enumerated value property
136      *
137      * @param valEnum the array of enumerated value property
138      */

139     public void setValEnum(String JavaDoc[] valEnum) {
140         if (valEnum != null) {
141             this.valEnum.clear();
142             this.valEnum.addAll(Arrays.asList(valEnum));
143         } else {
144             this.valEnum = null;
145         }
146     }
147     
148     /**
149      * Gets the display name property
150      *
151      * @return the display name property
152      */

153     public String JavaDoc getDisplayName() {
154         return displayName;
155     }
156     
157     /**
158      * Sets the display name of a given content type property
159      *
160      * @param displayName the display name of a given content type property
161      */

162     public void setDisplayName(String JavaDoc displayName) {
163         this.displayName = displayName;
164     }
165     
166     /**
167      * Gets the data type propeties
168      *
169      * @return the data type propeties
170      */

171     public String JavaDoc getDataType() {
172         return dataType;
173     }
174     
175     /**
176      * Sets the data type of a given content type property
177      *
178      * @param dataType the data type of a given content type property
179      */

180     public void setDataType(String JavaDoc dataType) {
181         this.dataType = dataType;
182     }
183
184     /**
185      * Gets the size propeties
186      *
187      * @return the size propeties
188      */

189     public int getSize() {
190         return size;
191     }
192
193     /**
194      * Sets the size of a given content type property
195      *
196      * @param size the size of a given content type property
197      *
198      */

199     public void setSize(int size) {
200         this.size = size;
201     }
202     
203     /**
204      * Gets the array of ContentTypeParameter
205      *
206      * @return the size propeties
207      */

208     public ArrayList getContentTypeParameters() {
209         return this.ctParameters;
210     }
211     
212     /**
213      * Sets an array of content type properties
214      *
215      * @param ctParameters array of content type properties
216      *
217      */

218     public void setContentTypeParameters(ContentTypeParameter[] ctParameters) {
219         if (ctParameters != null) {
220             this.ctParameters.clear();
221             this.ctParameters.addAll(Arrays.asList(ctParameters));
222         } else {
223             this.ctParameters = null;
224         }
225     }
226 }
227
Popular Tags