View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements. See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache license, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License. You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the license for the specific language governing permissions and
    15   * limitations under the license.
    16   */
    17  package org.apache.log4j.config;
    18
    19  import java.beans.PropertyDescriptor;
    20  import java.util.Properties;
    21
    22  /**
    23   *
    24   * @since 1.1
    25   */
    26  public class PropertySetter {
    27
    28      /**
    29       * Create a new PropertySetter for the specified Object. This is done
    30       * in preparation for invoking {@link #setProperty} one or more times.
    31       *
    32       * @param obj  the object for which to set properties
    33       */
    34      public PropertySetter(final Object obj) {
    35      }
    36
    37
    38      /**
    39       * Set the properties for the object that match the <code>prefix</code> passed as parameter.
    40       *
    41       * @param properties The properties
    42       * @param prefix The prefix
    43       */
    44      public void setProperties(final Properties properties, final String prefix) {
    45      }
    46
    47      /**
    48       * Set a property on this PropertySetter's Object. If successful, this
    49       * method will invoke a setter method on the underlying Object. The
    50       * setter is the one for the specified property name and the value is
    51       * determined partly from the setter argument type and partly from the
    52       * value specified in the call to this method.
    53       *
    54       * <p>If the setter expects a String no conversion is necessary.
    55       * If it expects an int, then an attempt is made to convert 'value'
    56       * to an int using new Integer(value). If the setter expects a boolean,
    57       * the conversion is by new Boolean(value).
    58       *
    59       * @param name    name of the property
    60       * @param value   String value of the property
    61       */
    62      public void setProperty(final String name, final String value) {
    63      }
    64
    65      /**
    66       * Set the named property given a {@link PropertyDescriptor}.
    67       *
    68       * @param prop A PropertyDescriptor describing the characteristics of the property to set.
    69       * @param name The named of the property to set.
    70       * @param value The value of the property.
    71       * @throws PropertySetterException (Never actually throws this exception. Kept for historical purposes.)
    72       */
    73      public void setProperty(final PropertyDescriptor prop, final String name, final String value)
    74          throws PropertySetterException {
    75      }
    76
    77      /**
    78       * Set the properties of an object passed as a parameter in one
    79       * go. The <code>properties</code> are parsed relative to a
    80       * <code>prefix</code>.
    81       *
    82       * @param obj The object to configure.
    83       * @param properties A java.util.Properties containing keys and values.
    84       * @param prefix Only keys having the specified prefix will be set.
    85       */
    86      public static void setProperties(final Object obj, final Properties properties, final String prefix) {
    87      }
    88  }