001//
002// Name
003//      $RCSfile: Parameter.java,v $
004//
005// Copyright
006//  Copyright 2007-2014 Cloud Software Group, Inc. ALL RIGHTS RESERVED. 
007//  Cloud Software Group, Inc. Confidential Information
008//
009// History
010//      $Revision: 1.1.2.5 $ $Date: 2014/10/10 20:05:32 $
011//
012
013package com.kabira.platform;
014
015/**
016 *      Generic holder class for parameters.
017 *      <p>
018 *      This is the base class for input/output and output parameters.
019 */
020@SuppressWarnings("unchecked")
021@Deprecated
022public class Parameter<T>
023{
024        private T       value;
025
026        /**
027         *      Creates an empty Parameter.
028         */
029        public Parameter() 
030        {
031                this.value = null;
032        }
033        
034        /**
035         *      Creates a Parameter containing a value.
036         *
037         *      @param  value   Parameter value.
038         */
039        public Parameter(T value)
040        {
041                this.value = value;
042        }
043
044        /**
045         *      Returns the value of this Parameter.
046         *
047         *      @return The value of this Parameter.
048         */
049        public T        getValue()
050        {
051                return value;
052        }
053
054        /**
055         *      Sets the value of this Parameter.
056         *
057         *      @param  value   Parameter value to set.
058         */
059        public void     setValue(T value)
060        {
061                this.value = value;
062        }
063
064        /**
065         *      Returns a String object representing this Parameter's value.
066         *      {@inheritDoc}
067         */
068        @Override
069        public String toString()
070        {
071                return value.toString();
072        }
073
074        /**
075         *      Returns the boolean value of this Parameter.
076         *
077         *      @return boolean
078         */
079        protected boolean getBooleanValue()
080        {
081                Boolean b = (Boolean)getValue();
082                if (b != null)
083                {
084                        return b.booleanValue();
085                }
086                
087                return false;
088        }
089
090        /**
091         *      Sets the value of this Parameter to
092         *      the passed in boolean.
093         *
094         *      @param  value   boolean value.
095         */
096        protected void setBooleanValue(boolean value)
097        {
098                Boolean bValue = value;
099                setValue((T)bValue);
100        }
101
102        /**
103         *      Returns the byte value of this Parameter.
104         *
105         *      @return byte
106         */
107        protected byte getByteValue()
108        {
109                Byte b = (Byte)getValue();
110                if (b != null)
111                {
112                        return b.byteValue();
113                }
114                
115                return (byte)0;
116        }
117
118        /**
119         *      Sets the value of this Parameter to the passed in byte.
120         *
121         *      @param  value   byte value.
122         */
123        protected void setByteValue(byte value)
124        {
125                Byte bValue = value;
126                setValue((T)bValue);
127        }
128
129        /**
130         *      Returns the char value of this Parameter.
131         *
132         *      @return char
133         */
134        protected char getCharValue()
135        {
136                Character b = (Character)getValue();
137                if (b != null)
138                {
139                        return b.charValue();
140                }
141                
142                return (char)0;
143        }
144
145        /**
146         *      Sets the value of this Parameter to the passed in char.
147         *
148         *      @param  value   char value.
149         *
150         */
151        protected void setCharValue(char value)
152        {
153                Character bValue = value;
154                setValue((T)bValue);
155        }
156
157        /**
158         *      Returns the short value of this Parameter.
159         *
160         *      @return short
161         */
162        protected short getShortValue()
163        {
164                Short b = (Short)getValue();
165                if (b != null)
166                {
167                        return b.shortValue();
168                }
169                
170                return (short)0;
171        }
172
173        /**
174         *      Sets the value of this Parameter to the passed in short.
175         *
176         *      @param  value   short value.
177         *
178         */
179        protected void setShortValue(short value)
180        {
181                Short bValue = value;
182                setValue((T)bValue);
183        }
184
185        /**
186         *      Returns the int value of this Parameter.
187         *
188         *      @return int
189         */
190        protected int getIntValue()
191        {
192                Integer b = (Integer)getValue();
193                if (b != null)
194                {
195                        return b.intValue();
196                }
197                
198                return 0;
199        }
200
201        /**
202         *      Sets the value of this Parameter to the passed in int.
203         *
204         *      @param  value   int value.
205         *
206         */
207        protected void setIntValue(int value)
208        {
209                Integer bValue = value;
210                setValue((T)bValue);
211        }
212
213        /**
214         *      Returns the long value of this Parameter.
215         *
216         *      @return long
217         */
218        protected long getLongValue()
219        {
220                Long b = (Long)getValue();
221                if (b != null)
222                {
223                        return b.longValue();
224                }
225                
226                return 0L;
227        }
228
229        /**
230         *      Sets the value of this Parameter to the passed in long.
231         *
232         *      @param  value   long value.
233         */
234        protected void setLongValue(long value)
235        {
236                Long bValue = value;
237                setValue((T)bValue);
238        }
239
240        /**
241         *      Returns the float value of this Parameter.
242         *
243         *      @return float
244         */
245        protected float getFloatValue()
246        {
247                Float b = (Float)getValue();
248                if (b != null)
249                {
250                        return b.floatValue();
251                }
252                
253                return (float)0.0;
254        }
255
256        /**
257         *      Sets the value of this Parameter to the passed in float.
258         *
259         *      @param  value   float value.
260         *
261         */
262        protected void setFloatValue(float value)
263        {
264                Float bValue = value;
265                setValue((T)bValue);
266        }
267
268        /**
269         *      Returns the double value of this Parameter.
270         *
271         *      @return double
272         */
273        protected double getDoubleValue()
274        {
275                Double b = (Double)getValue();
276                if (b != null)
277                {
278                        return b.doubleValue();
279                }
280                
281                return 0.0;
282        }
283
284        /**
285         *      Set the value of this Parameter to the passed in double.
286         *
287         *      @param  value   double value.
288         *
289         */
290        protected void setDoubleValue(double value)
291        {
292                Double bValue = value;
293                setValue((T)bValue);
294        }
295
296        /**
297         *      Returns an object containing the value of this Parameter.
298         *
299         *      @return Object
300         */
301        protected Object getObjectValue()
302        {
303        if (value instanceof String)
304        {
305            if (value == null)
306            {
307                return new String();
308            }
309        }
310                
311                return value;
312        }
313
314        /**
315         *      Sets the value of this Parameter to the passed in String.
316         *
317         *      @param  value   String value.
318         *
319         */
320        protected void setObjectValue(Object value)
321        {
322                setValue((T)value);
323        }
324}