View Javadoc

1   /*
2    * $Header: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Attic/ValidatorUtil.java,v 1.14.2.1 2004/06/22 02:24:38 husted Exp $
3    * $Revision: 1.14.2.1 $
4    * $Date: 2004/06/22 02:24:38 $
5    *
6    * ====================================================================
7    * Copyright 2001-2004 The Apache Software Foundation
8    *
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   *
13   *     http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   */
21  
22  package org.apache.commons.validator;
23  
24  import org.apache.commons.collections.FastHashMap; // DEPRECATED
25  import org.apache.commons.logging.Log;
26  import org.apache.commons.logging.LogFactory;
27  
28  /***
29   * Basic utility methods.
30   *
31   * @deprecated This class has moved to the org.apache.commons.validator.util
32   * package.
33   */
34  public class ValidatorUtil {
35  
36      /***
37       * Delimiter to put around a regular expression following Perl 5 syntax.
38       * @deprecated Use "/" directly.
39       */
40      public final static String REGEXP_DELIMITER = "/";
41  
42      /***
43       * Logger.
44       * @deprecated Subclasses should use their own logging instance.
45       */
46      protected static Log log = LogFactory.getLog(ValidatorUtil.class);
47  
48      /***
49       * <p>Replace part of a <code>String</code> with another value.</p>
50       *
51       * @param    value        <code>String</code> to perform the replacement on.
52       * @param    key        The name of the constant.
53       * @param    replaceValue    The value of the constant.
54       */
55      public static String replace(
56              String value,
57              String key,
58              String replaceValue) {
59  
60          return org.apache.commons.validator.util.ValidatorUtils.replace(value, key, replaceValue);
61      }
62  
63      /***
64       * Convenience method for getting a value from a bean property as a
65       * <code>String</code>.
66       */
67      public static String getValueAsString(Object bean, String property) {
68          return org.apache.commons.validator.util.ValidatorUtils.getValueAsString(bean, property);
69      }
70  
71      /***
72       * Makes a deep copy of a <code>FastHashMap</code> if the values
73       * are <code>String</code>, <code>Msg</code>, <code>Arg</code>,
74       * or <code>Var</code>.  Otherwise it is a shallow copy.
75       *
76       * @param map <code>FastHashMap</code> to copy.
77       * @return FastHashMap A copy of the <code>FastHashMap</code> that was
78       * passed in.
79       */
80      public static FastHashMap copyFastHashMap(FastHashMap map) {
81          return org.apache.commons.validator.util.ValidatorUtils.copyFastHashMap(map);
82      }
83  
84      /***
85       * Adds a '/' on either side of the regular expression.
86       * @deprecated Use "/" directly.
87       */
88      public static String getDelimitedRegExp(String regexp) {
89          return (REGEXP_DELIMITER + regexp + REGEXP_DELIMITER);
90      }
91  
92  }