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