View Javadoc

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