View Javadoc

1   /***
2    * @(#)ServiceEntry.java
3    * 
4    * JFoxSOAF, Service-Oriented Application Framework
5    * 
6    * Copyright(c) JFoxSOAF Team
7    * 
8    * Licensed under the GNU LGPL, Version 2.1 (the "License"); 
9    * you may not use this file except in compliance with the License. 
10   * You may obtain a copy of the License at  
11   * 
12   * http://www.gnu.org/copyleft/lesser.html
13   * 
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, 
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17   * See the License for the specific language governing permissions and 
18   * limitations under the License. 
19   * 
20   * For more information, please visit:
21   * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22   * http://www.huihoo.org/jfox/jfoxsoaf
23   */
24  
25  package org.huihoo.jfox.soaf.schema.service;
26  
27  import java.util.Vector;
28  
29  import org.exolab.castor.xml.Marshaller;
30  import org.exolab.castor.xml.Unmarshaller;
31  
32  /***
33   * <p>
34   * Class ServiceEntry.
35   * </p>
36   * 
37   * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
38   * @version $Revision: 1.7 $ $Date: 2005/05/22 06:48:07 $
39   * @version Revision: 1.0
40   */
41  
42  public class ServiceEntry implements java.io.Serializable,
43          org.huihoo.jfox.soaf.container.ServiceEntry {
44  
45      /***
46       * Field _id
47       */
48      private java.lang.String _id;
49  
50      /***
51       * Field _description
52       */
53      private java.lang.String _description;
54  
55      /***
56       * Field _manageable
57       */
58      private java.lang.String _manageable;
59  
60      /***
61       * Field _interface
62       */
63      private java.lang.String _interface;
64  
65      /***
66       * Field _implementation
67       */
68      private java.lang.String _implementation;
69  
70      /***
71       * Field _parameterList
72       */
73      private java.util.Vector _parameterList;
74  
75      public ServiceEntry() {
76          super();
77          _parameterList = new Vector();
78      }
79  
80      /***
81       * Method addParameter
82       * 
83       * @param vParameter
84       */
85      public void addParameter(
86              org.huihoo.jfox.soaf.schema.service.Parameter vParameter)
87              throws java.lang.IndexOutOfBoundsException {
88          _parameterList.addElement(vParameter);
89      }
90  
91      /***
92       * Method addParameter
93       * 
94       * @param index
95       * @param vParameter
96       */
97      public void addParameter(int index,
98              org.huihoo.jfox.soaf.schema.service.Parameter vParameter)
99              throws java.lang.IndexOutOfBoundsException {
100         _parameterList.insertElementAt(vParameter, index);
101     }
102 
103     /***
104      * Method enumerateParameter
105      */
106     public java.util.Enumeration enumerateParameter() {
107         return _parameterList.elements();
108     }
109 
110     /***
111      * Method getDescriptionReturns the value of field 'description'.
112      * 
113      * @return the value of field 'description'.
114      */
115     public java.lang.String getDescription() {
116         return this._description;
117     }
118 
119     /***
120      * Method getIdReturns the value of field 'id'.
121      * 
122      * @return the value of field 'id'.
123      */
124     public java.lang.String getId() {
125         return this._id;
126     }
127 
128     /***
129      * Method getImplementationReturns the value of field 'implementation'.
130      * 
131      * @return the value of field 'implementation'.
132      */
133     public java.lang.String getImplementation() {
134         return this._implementation;
135     }
136 
137     /***
138      * Method getInterfaceReturns the value of field 'interface'.
139      * 
140      * @return the value of field 'interface'.
141      */
142     public java.lang.String getInterface() {
143         return this._interface;
144     }
145 
146     /***
147      * Method getManageableReturns the value of field 'manageable'.
148      * 
149      * @return the value of field 'manageable'.
150      */
151     public java.lang.String getManageable() {
152         return this._manageable;
153     }
154 
155     /***
156      * Method getParameter
157      * 
158      * @param index
159      */
160     public org.huihoo.jfox.soaf.schema.service.Parameter getParameter(int index)
161             throws java.lang.IndexOutOfBoundsException {
162         //-- check bounds for index
163         if ((index < 0) || (index > _parameterList.size())) {
164             throw new IndexOutOfBoundsException();
165         }
166 
167         return (org.huihoo.jfox.soaf.schema.service.Parameter) _parameterList
168                 .elementAt(index);
169     }
170 
171     /***
172      * Method getParameter
173      */
174     public org.huihoo.jfox.soaf.schema.service.Parameter[] getParameter() {
175         int size = _parameterList.size();
176         org.huihoo.jfox.soaf.schema.service.Parameter[] mArray = new org.huihoo.jfox.soaf.schema.service.Parameter[size];
177         for (int index = 0; index < size; index++) {
178             mArray[index] = (org.huihoo.jfox.soaf.schema.service.Parameter) _parameterList
179                     .elementAt(index);
180         }
181         return mArray;
182     }
183 
184     /***
185      * Method getParameterCount
186      */
187     public int getParameterCount() {
188         return _parameterList.size();
189     }
190 
191     /***
192      * Method isValid
193      */
194     public boolean isValid() {
195         try {
196             validate();
197         } catch (org.exolab.castor.xml.ValidationException vex) {
198             return false;
199         }
200         return true;
201     }
202 
203     /***
204      * Method marshal
205      * 
206      * @param out
207      */
208     public void marshal(java.io.Writer out)
209             throws org.exolab.castor.xml.MarshalException,
210             org.exolab.castor.xml.ValidationException {
211 
212         Marshaller.marshal(this, out);
213     }
214 
215     /***
216      * Method marshal
217      * 
218      * @param handler
219      */
220     public void marshal(org.xml.sax.ContentHandler handler)
221             throws java.io.IOException, org.exolab.castor.xml.MarshalException,
222             org.exolab.castor.xml.ValidationException {
223 
224         Marshaller.marshal(this, handler);
225     }
226 
227     /***
228      * Method removeAllParameter
229      */
230     public void removeAllParameter() {
231         _parameterList.removeAllElements();
232     }
233 
234     /***
235      * Method removeParameter
236      * 
237      * @param index
238      */
239     public org.huihoo.jfox.soaf.schema.service.Parameter removeParameter(
240             int index) {
241         java.lang.Object obj = _parameterList.elementAt(index);
242         _parameterList.removeElementAt(index);
243         return (org.huihoo.jfox.soaf.schema.service.Parameter) obj;
244     }
245 
246     /***
247      * Method setDescriptionSets the value of field 'description'.
248      * 
249      * @param description the value of field 'description'.
250      */
251     public void setDescription(java.lang.String description) {
252         this._description = description;
253     }
254 
255     /***
256      * Method setIdSets the value of field 'id'.
257      * 
258      * @param id the value of field 'id'.
259      */
260     public void setId(java.lang.String id) {
261         this._id = id;
262     }
263 
264     /***
265      * Method setImplementationSets the value of field 'implementation'.
266      * 
267      * @param implementation the value of field 'implementation'.
268      */
269     public void setImplementation(java.lang.String implementation) {
270         this._implementation = implementation;
271     }
272 
273     /***
274      * Method setInterfaceSets the value of field 'interface'.
275      * 
276      * @param _interface
277      * @param interface the value of field 'interface'.
278      */
279     public void setInterface(java.lang.String _interface) {
280         this._interface = _interface;
281     }
282 
283     /***
284      * Method setManageableSets the value of field 'manageable'.
285      * 
286      * @param manageable the value of field 'manageable'.
287      */
288     public void setManageable(java.lang.String manageable) {
289         this._manageable = manageable;
290     }
291 
292     /***
293      * Method setParameter
294      * 
295      * @param index
296      * @param vParameter
297      */
298     public void setParameter(int index,
299             org.huihoo.jfox.soaf.schema.service.Parameter vParameter)
300             throws java.lang.IndexOutOfBoundsException {
301         //-- check bounds for index
302         if ((index < 0) || (index > _parameterList.size())) {
303             throw new IndexOutOfBoundsException();
304         }
305         _parameterList.setElementAt(vParameter, index);
306     }
307 
308     /***
309      * Method setParameter
310      * 
311      * @param parameterArray
312      */
313     public void setParameter(
314             org.huihoo.jfox.soaf.schema.service.Parameter[] parameterArray) {
315         //-- copy array
316         _parameterList.removeAllElements();
317         for (int i = 0; i < parameterArray.length; i++) {
318             _parameterList.addElement(parameterArray[i]);
319         }
320     }
321 
322     /***
323      * Method unmarshal
324      * 
325      * @param reader
326      */
327     public static org.huihoo.jfox.soaf.schema.service.ServiceEntry unmarshal(
328             java.io.Reader reader)
329             throws org.exolab.castor.xml.MarshalException,
330             org.exolab.castor.xml.ValidationException {
331         return (org.huihoo.jfox.soaf.schema.service.ServiceEntry) Unmarshaller
332                 .unmarshal(
333                         org.huihoo.jfox.soaf.schema.service.ServiceEntry.class,
334                         reader);
335     }
336 
337     /***
338      * Method validate
339      */
340     public void validate() throws org.exolab.castor.xml.ValidationException {
341         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
342         validator.validate(this);
343     }
344 
345 }