View Javadoc

1   /***
2    * JFoxSOAF, Service-Oriented Application Framework
3    * 
4    * Copyright (C) www.huihoo.org
5    * 
6    * Distributable under GNU LGPL For more information, please visit:
7    * http://www.huihoo.org/jfox/jfoxsoaf
8    */
9   
10  package org.huihoo.jfox.soaf.schema.service;
11  
12  import java.util.Vector;
13  
14  import org.exolab.castor.xml.Marshaller;
15  import org.exolab.castor.xml.Unmarshaller;
16  
17  /***
18   * <p>
19   * Class Service.
20   * </p>
21   * 
22   * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>*
23   * @version $Revision: 1.4 $ $Date: 2004/10/18 10:21:49 $
24   * @version Revision: 1.0
25   */
26  
27  public class Service implements java.io.Serializable {
28  
29      /***
30       * Field _serviceEntryList
31       */
32      private java.util.Vector _serviceEntryList;
33  
34      public Service() {
35          super();
36          _serviceEntryList = new Vector();
37      }
38  
39      /***
40       * Method addServiceEntry
41       * 
42       * @param vServiceEntry
43       */
44      public void addServiceEntry(
45              org.huihoo.jfox.soaf.schema.service.ServiceEntry vServiceEntry)
46              throws java.lang.IndexOutOfBoundsException {
47          _serviceEntryList.addElement(vServiceEntry);
48      }
49  
50      /***
51       * Method addServiceEntry
52       * 
53       * @param index
54       * @param vServiceEntry
55       */
56      public void addServiceEntry(int index,
57              org.huihoo.jfox.soaf.schema.service.ServiceEntry vServiceEntry)
58              throws java.lang.IndexOutOfBoundsException {
59          _serviceEntryList.insertElementAt(vServiceEntry, index);
60      }
61  
62      /***
63       * Method enumerateServiceEntry
64       */
65      public java.util.Enumeration enumerateServiceEntry() {
66          return _serviceEntryList.elements();
67      }
68  
69      /***
70       * Method getServiceEntry
71       * 
72       * @param index
73       */
74      public org.huihoo.jfox.soaf.schema.service.ServiceEntry getServiceEntry(
75              int index) throws java.lang.IndexOutOfBoundsException {
76          //-- check bounds for index
77          if ((index < 0) || (index > _serviceEntryList.size())) {
78              throw new IndexOutOfBoundsException();
79          }
80  
81          return (org.huihoo.jfox.soaf.schema.service.ServiceEntry) _serviceEntryList
82                  .elementAt(index);
83      }
84  
85      /***
86       * Method getServiceEntry
87       */
88      public org.huihoo.jfox.soaf.schema.service.ServiceEntry[] getServiceEntry() {
89          int size = _serviceEntryList.size();
90          org.huihoo.jfox.soaf.schema.service.ServiceEntry[] mArray = new org.huihoo.jfox.soaf.schema.service.ServiceEntry[size];
91          for (int index = 0; index < size; index++) {
92              mArray[index] = (org.huihoo.jfox.soaf.schema.service.ServiceEntry) _serviceEntryList
93                      .elementAt(index);
94          }
95          return mArray;
96      }
97  
98      /***
99       * Method getServiceEntryCount
100      */
101     public int getServiceEntryCount() {
102         return _serviceEntryList.size();
103     }
104 
105     /***
106      * Method isValid
107      */
108     public boolean isValid() {
109         try {
110             validate();
111         } catch (org.exolab.castor.xml.ValidationException vex) {
112             return false;
113         }
114         return true;
115     }
116 
117     /***
118      * Method marshal
119      * 
120      * @param out
121      */
122     public void marshal(java.io.Writer out)
123             throws org.exolab.castor.xml.MarshalException,
124             org.exolab.castor.xml.ValidationException {
125 
126         Marshaller.marshal(this, out);
127     }
128 
129     /***
130      * Method marshal
131      * 
132      * @param handler
133      */
134     public void marshal(org.xml.sax.ContentHandler handler)
135             throws java.io.IOException, org.exolab.castor.xml.MarshalException,
136             org.exolab.castor.xml.ValidationException {
137 
138         Marshaller.marshal(this, handler);
139     }
140 
141     /***
142      * Method removeAllServiceEntry
143      */
144     public void removeAllServiceEntry() {
145         _serviceEntryList.removeAllElements();
146     }
147 
148     /***
149      * Method removeServiceEntry
150      * 
151      * @param index
152      */
153     public org.huihoo.jfox.soaf.schema.service.ServiceEntry removeServiceEntry(
154             int index) {
155         java.lang.Object obj = _serviceEntryList.elementAt(index);
156         _serviceEntryList.removeElementAt(index);
157         return (org.huihoo.jfox.soaf.schema.service.ServiceEntry) obj;
158     }
159 
160     /***
161      * Method setServiceEntry
162      * 
163      * @param index
164      * @param vServiceEntry
165      */
166     public void setServiceEntry(int index,
167             org.huihoo.jfox.soaf.schema.service.ServiceEntry vServiceEntry)
168             throws java.lang.IndexOutOfBoundsException {
169         //-- check bounds for index
170         if ((index < 0) || (index > _serviceEntryList.size())) {
171             throw new IndexOutOfBoundsException();
172         }
173         _serviceEntryList.setElementAt(vServiceEntry, index);
174     }
175 
176     /***
177      * Method setServiceEntry
178      * 
179      * @param serviceEntryArray
180      */
181     public void setServiceEntry(
182             org.huihoo.jfox.soaf.schema.service.ServiceEntry[] serviceEntryArray) {
183         //-- copy array
184         _serviceEntryList.removeAllElements();
185         for (int i = 0; i < serviceEntryArray.length; i++) {
186             _serviceEntryList.addElement(serviceEntryArray[i]);
187         }
188     }
189 
190     /***
191      * Method unmarshal
192      * 
193      * @param reader
194      */
195     public static org.huihoo.jfox.soaf.schema.service.Service unmarshal(
196             java.io.Reader reader)
197             throws org.exolab.castor.xml.MarshalException,
198             org.exolab.castor.xml.ValidationException {
199         return (org.huihoo.jfox.soaf.schema.service.Service) Unmarshaller
200                 .unmarshal(org.huihoo.jfox.soaf.schema.service.Service.class,
201                         reader);
202     }
203 
204     /***
205      * Method validate
206      */
207     public void validate() throws org.exolab.castor.xml.ValidationException {
208         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
209         validator.validate(this);
210     }
211 
212 }