KickJava   Java API By Example, From Geeks To Geeks.

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


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 parameter such as paramName, valEnum,
26  * displayName or data type
27  *
28  * @author Stefano Fornari @ Funambol
29  *
30  * @version $Id: ContentTypeParameter.java,v 1.3 2005/03/02 20:57:37 harrie Exp $
31  */

32 public final class ContentTypeParameter
33 implements java.io.Serializable JavaDoc {
34     
35     // ------------------------------------------------------------ Private data
36
private String JavaDoc paramName;
37     private ArrayList valEnum = new ArrayList();
38     private String JavaDoc displayName;
39     private String JavaDoc dataType;
40     private int size;
41     
42     // ------------------------------------------------------------ Constructors
43
/** For serialization purposes */
44     private ContentTypeParameter() {}
45     
46     /**
47      * Creates a new ContentTypeParameter object with the given name, value and
48      * display name
49      *
50      * @param paramName corresponds to <ParamName> element in the SyncML
51      * specification - NOT NULL
52      * @param valEnum corresponds to <ValEnum> element in the SyncML
53      * specification
54      * @param displayName corresponds to <DisplayName> element in the SyncML
55      * specification
56      *
57      */

58     public ContentTypeParameter(final String JavaDoc paramName,
59                                 final String JavaDoc[] valEnum,
60                                 final String JavaDoc displayName) {
61         setParamName(paramName);
62         setValEnum(valEnum);
63         
64         this.displayName = displayName;
65     }
66
67     /**
68      * Creates a new ContentTypeParameter object with the given name, data type,
69      * size, display name
70      *
71      * @param paramName corresponds to <ParamName> element in the SyncML
72      * specification - NOT NULL
73      * @param dataType corresponds to <DataType> element in the SyncML
74      * specification
75      * @param size corresponds to <Size> element in the SyncML
76      * specification
77      * @param displayName corresponds to <DisplayName> element in the SyncML
78      * specification
79      *
80      */

81     public ContentTypeParameter(final String JavaDoc paramName,
82                                 final String JavaDoc dataType,
83                                 final int size,
84                                 final String JavaDoc displayName) {
85         setParamName(paramName);
86         
87         this.dataType = dataType;
88         this.size = size;
89         this.displayName = displayName;
90     }
91
92     // ---------------------------------------------------------- Public methods
93

94     /**
95      * Gets the parameter name propeties
96      *
97      * @return the parameter name propeties
98      */

99     public String JavaDoc getParamName() {
100         return paramName;
101     }
102     
103     /**
104      * Sets the param name property
105      *
106      * @param paramName the param name property
107      */

108     public void setParamName(String JavaDoc paramName) {
109         if (paramName == null){
110             throw new IllegalArgumentException JavaDoc("paramName cannot be null");
111         }
112         this.paramName = paramName;
113     }
114     
115     /**
116      * Gets the array of value for parameter
117      *
118      * @return the array of value for parameter
119      */

120     public ArrayList getValEnum() {
121         return this.valEnum;
122     }
123     
124     /**
125      * Sets the array of enumerated value property
126      *
127      * @param valEnum the array of enumerated value property
128      */

129     public void setValEnum(String JavaDoc[] valEnum) {
130         if (valEnum != null) {
131             this.valEnum.clear();
132             this.valEnum.addAll(Arrays.asList(valEnum));
133         } else {
134             this.valEnum = null;
135         }
136     }
137     
138     /**
139      * Gets the display name propeties
140      *
141      * @return the display name propeties
142      */

143     public String JavaDoc getDisplayName() {
144         return displayName;
145     }
146     
147     /**
148      * Sets the display name of a given content type parameter
149      *
150      * @param displayName the display name of a given content type parameter
151      *
152      */

153     public void setDisplayName(String JavaDoc displayName) {
154         this.displayName = displayName;
155     }
156     
157     /**
158      * Gets the data type propeties
159      *
160      * @return the data type propeties
161      */

162     public String JavaDoc getDataType() {
163         return dataType;
164     }
165     
166     /**
167      * Sets the data type of a given content type parameter
168      *
169      * @param dataType the data type of a given content type parameter
170      *
171      */

172     public void setDataType(String JavaDoc dataType) {
173         this.dataType = dataType;
174     }
175     
176     /**
177      * Gets the size propeties
178      *
179      * @return the size propeties
180      */

181     public int getSize() {
182         return size;
183     }
184     
185     /**
186      * Sets the size of a given content type parameter
187      *
188      * @param size the size of a given content type parameter
189      *
190      */

191     public void setSize(int size) {
192         this.size = size;
193     }
194 }
Popular Tags