You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2013/07/07 18:47:03 UTC

svn commit: r1500476 - /commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ValueTransformer.java

Author: oheger
Date: Sun Jul  7 16:47:02 2013
New Revision: 1500476

URL: http://svn.apache.org/r1500476
Log:
Added ValueTransformer interface.

As becomes obvious, collaboration between a Configuration and a
ListDelimiterHandler can be complex when the configuration performs an
additional encoding of values before they are written to disk. This interface
allows the delimiter handler to perform this encoding on behalf of the
configuration.

Added:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ValueTransformer.java

Added: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ValueTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ValueTransformer.java?rev=1500476&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ValueTransformer.java (added)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ValueTransformer.java Sun Jul  7 16:47:02 2013
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.configuration;
+
+/**
+ * <p>
+ * Definition of an interface used by {@link ListDelimiterHandler} to perform
+ * additional transformations on behalf of a configuration when a property value
+ * is escaped.
+ * </p>
+ * <p>
+ * Some {@code Configuration} implementations require a special encoding of
+ * their property values before they get written on disk. In some
+ * constellations, e.g. when a property with multiple values is to be forced on
+ * a single line, this encoding has to be done together with the escaping of
+ * list delimiter characters - which is in the responsibility of
+ * {@link ListDelimiterHandler}.
+ * </p>
+ * <p>
+ * In order to allow a proper collaboration between the parties involved, this
+ * interface was introduced. A configuration object provides an implementation
+ * of {@code ValueTransformer} and passes it to the {@code ListDelimiterHandler}
+ * when escaping of properties is needed. The delimiter handler can then call
+ * back to perform the additional encoding as its pleasure.
+ * </p>
+ *
+ * @version $Id: $
+ * @since 2.0
+ */
+public interface ValueTransformer
+{
+    /**
+     * Performs an arbitrary encoding of the passed in value object. This method
+     * is called by a {@link ListDelimiterHandler} implementation before or
+     * after list delimiters have been escaped.
+     *
+     * @param value the property value to be transformed
+     * @return the transformed property value
+     */
+    Object transformValue(Object value);
+}