View Javadoc

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