View Javadoc

1   /***
2    * @(#)ServiceConfiguration.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.config;
26  
27  import java.util.Vector;
28  
29  import org.exolab.castor.xml.Marshaller;
30  import org.exolab.castor.xml.Unmarshaller;
31  
32  /***
33   * Class ServiceConfiguration.
34   * 
35   * @version $Revision: 1.5 $ $Date: 2005/05/22 06:47:43 $
36   */
37  public class ServiceConfiguration implements java.io.Serializable {
38  
39      /***
40       * Field _configurationEntryList
41       */
42      private java.util.Vector _configurationEntryList;
43  
44      public ServiceConfiguration() {
45          super();
46          _configurationEntryList = new Vector();
47      }
48  
49      /***
50       * Method addConfigurationEntry
51       * 
52       * @param vConfigurationEntry
53       */
54      public void addConfigurationEntry(
55              org.huihoo.jfox.soaf.schema.config.ConfigurationEntry vConfigurationEntry)
56              throws java.lang.IndexOutOfBoundsException {
57          _configurationEntryList.addElement(vConfigurationEntry);
58      }
59  
60      /***
61       * Method addConfigurationEntry
62       * 
63       * @param index
64       * @param vConfigurationEntry
65       */
66      public void addConfigurationEntry(
67              int index,
68              org.huihoo.jfox.soaf.schema.config.ConfigurationEntry vConfigurationEntry)
69              throws java.lang.IndexOutOfBoundsException {
70          _configurationEntryList.insertElementAt(vConfigurationEntry, index);
71      }
72  
73      /***
74       * Method enumerateConfigurationEntry
75       */
76      public java.util.Enumeration enumerateConfigurationEntry() {
77          return _configurationEntryList.elements();
78      }
79  
80      /***
81       * Method getConfigurationEntry
82       * 
83       * @param index
84       */
85      public org.huihoo.jfox.soaf.schema.config.ConfigurationEntry getConfigurationEntry(
86              int index) throws java.lang.IndexOutOfBoundsException {
87          //-- check bounds for index
88          if ((index < 0) || (index > _configurationEntryList.size())) {
89              throw new IndexOutOfBoundsException();
90          }
91  
92          return (org.huihoo.jfox.soaf.schema.config.ConfigurationEntry) _configurationEntryList
93                  .elementAt(index);
94      }
95  
96      /***
97       * Method getConfigurationEntry
98       */
99      public org.huihoo.jfox.soaf.schema.config.ConfigurationEntry[] getConfigurationEntry() {
100         int size = _configurationEntryList.size();
101         org.huihoo.jfox.soaf.schema.config.ConfigurationEntry[] mArray = new org.huihoo.jfox.soaf.schema.config.ConfigurationEntry[size];
102         for (int index = 0; index < size; index++) {
103             mArray[index] = (org.huihoo.jfox.soaf.schema.config.ConfigurationEntry) _configurationEntryList
104                     .elementAt(index);
105         }
106         return mArray;
107     }
108 
109     /***
110      * Method getConfigurationEntryCount
111      */
112     public int getConfigurationEntryCount() {
113         return _configurationEntryList.size();
114     }
115 
116     /***
117      * Method isValid
118      */
119     public boolean isValid() {
120         try {
121             validate();
122         } catch (org.exolab.castor.xml.ValidationException vex) {
123             return false;
124         }
125         return true;
126     }
127 
128     /***
129      * Method marshal
130      * 
131      * @param out
132      */
133     public void marshal(java.io.Writer out)
134             throws org.exolab.castor.xml.MarshalException,
135             org.exolab.castor.xml.ValidationException {
136 
137         Marshaller.marshal(this, out);
138     }
139 
140     /***
141      * Method marshal
142      * 
143      * @param handler
144      */
145     public void marshal(org.xml.sax.ContentHandler handler)
146             throws java.io.IOException, org.exolab.castor.xml.MarshalException,
147             org.exolab.castor.xml.ValidationException {
148 
149         Marshaller.marshal(this, handler);
150     }
151 
152     /***
153      * Method removeAllConfigurationEntry
154      */
155     public void removeAllConfigurationEntry() {
156         _configurationEntryList.removeAllElements();
157     }
158 
159     /***
160      * Method removeConfigurationEntry
161      * 
162      * @param index
163      */
164     public org.huihoo.jfox.soaf.schema.config.ConfigurationEntry removeConfigurationEntry(
165             int index) {
166         java.lang.Object obj = _configurationEntryList.elementAt(index);
167         _configurationEntryList.removeElementAt(index);
168         return (org.huihoo.jfox.soaf.schema.config.ConfigurationEntry) obj;
169     }
170 
171     /***
172      * Method setConfigurationEntry
173      * 
174      * @param index
175      * @param vConfigurationEntry
176      */
177     public void setConfigurationEntry(
178             int index,
179             org.huihoo.jfox.soaf.schema.config.ConfigurationEntry vConfigurationEntry)
180             throws java.lang.IndexOutOfBoundsException {
181         //-- check bounds for index
182         if ((index < 0) || (index > _configurationEntryList.size())) {
183             throw new IndexOutOfBoundsException();
184         }
185         _configurationEntryList.setElementAt(vConfigurationEntry, index);
186     }
187 
188     /***
189      * Method setConfigurationEntry
190      * 
191      * @param configurationEntryArray
192      */
193     public void setConfigurationEntry(
194             org.huihoo.jfox.soaf.schema.config.ConfigurationEntry[] configurationEntryArray) {
195         //-- copy array
196         _configurationEntryList.removeAllElements();
197         for (int i = 0; i < configurationEntryArray.length; i++) {
198             _configurationEntryList.addElement(configurationEntryArray[i]);
199         }
200     }
201 
202     /***
203      * Method unmarshal
204      * 
205      * @param reader
206      */
207     public static org.huihoo.jfox.soaf.schema.config.ServiceConfiguration unmarshal(
208             java.io.Reader reader)
209             throws org.exolab.castor.xml.MarshalException,
210             org.exolab.castor.xml.ValidationException {
211         return (org.huihoo.jfox.soaf.schema.config.ServiceConfiguration) Unmarshaller
212                 .unmarshal(
213                         org.huihoo.jfox.soaf.schema.config.ServiceConfiguration.class,
214                         reader);
215     }
216 
217     /***
218      * Method validate
219      */
220     public void validate() throws org.exolab.castor.xml.ValidationException {
221         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
222         validator.validate(this);
223     }
224 
225 }