001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.configuration2.convert;
018
019
020/**
021 * <p>
022 * Definition of an interface used by {@link ListDelimiterHandler} to perform
023 * additional transformations on behalf of a configuration when a property value
024 * is escaped.
025 * </p>
026 * <p>
027 * Some {@code Configuration} implementations require a special encoding of
028 * their property values before they get written on disk. In some
029 * constellations, e.g. when a property with multiple values is to be forced on
030 * a single line, this encoding has to be done together with the escaping of
031 * list delimiter characters - which is in the responsibility of
032 * {@link ListDelimiterHandler}.
033 * </p>
034 * <p>
035 * In order to allow a proper collaboration between the parties involved, this
036 * interface was introduced. A configuration object provides an implementation
037 * of {@code ValueTransformer} and passes it to the {@code ListDelimiterHandler}
038 * when escaping of properties is needed. The delimiter handler can then call
039 * back to perform the additional encoding as its pleasure.
040 * </p>
041 *
042 * @since 2.0
043 */
044public interface ValueTransformer
045{
046    /**
047     * Performs an arbitrary encoding of the passed in value object. This method
048     * is called by a {@link ListDelimiterHandler} implementation before or
049     * after list delimiters have been escaped.
050     *
051     * @param value the property value to be transformed
052     * @return the transformed property value
053     */
054    Object transformValue(Object value);
055}