View Javadoc

1   /**
2    * $Id: BaseExceptionDefImpl.java 58 2006-11-08 14:52:38Z maldito_orco $
3    *
4    * =========================================================================
5    *
6    * Copyright 2005 Tubo
7    *
8    *  Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
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  package org.tubo.configuration.def.baseimpl;
21  
22  //log
23  import org.apache.commons.logging.Log;
24  import org.apache.commons.logging.LogFactory;
25  //tubo-configuration
26  import org.tubo.configuration.def.ExceptionDef;
27  //util
28  import java.util.List;
29  import java.util.ArrayList;
30  
31  /**
32   * <p></p>
33   * <p>
34   * Created: Jun 27, 2005 6:59:40 PM <br>
35   * Last Modification Date: $Date: 2006-11-08 11:52:38 -0300 (Wed, 08 Nov 2006) $
36   * </p>
37   *
38   * @author maldito_orco (maldito_orco@users.sourceforge.net)
39   * @version $Revision: 58 $
40   */
41  public class BaseExceptionDefImpl extends BaseReferenceableItemDefImpl implements ExceptionDef  {
42      public static final String RCS_ID = "$Id: BaseExceptionDefImpl.java 58 2006-11-08 14:52:38Z maldito_orco $";
43      private static Log log = LogFactory.getLog(BaseExceptionDefImpl.class);
44  
45      private String exceptionClassname = null;
46      private List rankErrorCodesList = new ArrayList();
47  
48      public String getExceptionClassname() { return exceptionClassname; }
49      public void setExceptionClassname(String exceptionClassname) {
50          this.exceptionClassname = exceptionClassname;
51      }
52  
53      public List getRankErrorCodesList() {
54          return rankErrorCodesList;
55      }
56      public void addErrorCode(String strErrorCode) {
57          //
58          // convert error code to string (TODO: ver que hacer con la exception)
59          int errorCode = Integer.parseInt(strErrorCode.trim());
60          //
61          // add error code like a rank of one element
62          int[] rank = new int[] {errorCode,errorCode};
63          addRankToList(rank);
64      }
65      public void addRankErrorCodes(String strRankErrorCodes) {
66          //
67          // split rank into limits
68          String[] limits = strRankErrorCodes.split("[-,;:/|]");
69          //
70          // convert limits to string (TODO: ver que hacer con la exception [malformed y limits.length!=2])
71          int upperLimit = Integer.parseInt(limits[0]);
72          int lowerLimit = Integer.parseInt(limits[1]);
73          //
74          // add rank to list
75          int[] rank = new int[] {upperLimit,lowerLimit};
76          addRankToList(rank);
77      }
78  
79      private void addRankToList(int[] rank) {
80          rankErrorCodesList.add(rank);
81      }
82  
83  }