From f994c98c39c4bea8d8ccfa20c935c06e611b0946 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Wed, 6 Jul 2005 20:33:21 +0000 Subject: [PATCH] Renamed VariableFormat to VariableFormatter since it is not a subclass of java.text.Format. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@209509 13f79535-47bb-0310-9956-ffa450edef68 --- ...ableFormat.java => VariableFormatter.java} | 14 ++++---- .../commons/lang/text/TextTestSuite.java | 2 +- ...atTest.java => VariableFormatterTest.java} | 34 +++++++++---------- 3 files changed, 25 insertions(+), 25 deletions(-) rename src/java/org/apache/commons/lang/text/{VariableFormat.java => VariableFormatter.java} (97%) rename src/test/org/apache/commons/lang/text/{VariableFormatTest.java => VariableFormatterTest.java} (86%) diff --git a/src/java/org/apache/commons/lang/text/VariableFormat.java b/src/java/org/apache/commons/lang/text/VariableFormatter.java similarity index 97% rename from src/java/org/apache/commons/lang/text/VariableFormat.java rename to src/java/org/apache/commons/lang/text/VariableFormatter.java index cbea9d564..6e3041bd8 100644 --- a/src/java/org/apache/commons/lang/text/VariableFormat.java +++ b/src/java/org/apache/commons/lang/text/VariableFormatter.java @@ -95,7 +95,7 @@ * @version $Id$ * @since 2.2 */ -public class VariableFormat { +public class VariableFormatter { /** Constant for the default variable prefix. */ static final String DEFAULT_PREFIX = "${"; @@ -131,7 +131,7 @@ public class VariableFormat { * @throws IllegalArgumentException * if the map is undefined */ - public VariableFormat(Map valueMap, String prefix, String suffix, char escape) { + public VariableFormatter(Map valueMap, String prefix, String suffix, char escape) { setValueMap(valueMap); setVariablePrefix(prefix); setVariableSuffix(suffix); @@ -150,7 +150,7 @@ public VariableFormat(Map valueMap, String prefix, String suffix, char escape) { * @throws IllegalArgumentException * if the map is undefined */ - public VariableFormat(Map valueMap, String prefix, String suffix) { + public VariableFormatter(Map valueMap, String prefix, String suffix) { this(valueMap, prefix, suffix, DEFAULT_ESCAPE); } @@ -163,7 +163,7 @@ public VariableFormat(Map valueMap, String prefix, String suffix) { * @throws IllegalArgumentException * if the map is undefined */ - public VariableFormat(Map valueMap) { + public VariableFormatter(Map valueMap) { this(valueMap, DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE); } @@ -298,7 +298,7 @@ public String replace(Object source) { * @return the result of the replace operation */ public static String replace(Map valueMap, Object source) { - return new VariableFormat(valueMap).replace(source); + return new VariableFormatter(valueMap).replace(source); } /** @@ -316,7 +316,7 @@ public static String replace(Map valueMap, Object source) { * @return the result of the replace operation */ public static String replace(Map valueMap, String prefix, String suffix, Object source) { - return new VariableFormat(valueMap, prefix, suffix).replace(source); + return new VariableFormatter(valueMap, prefix, suffix).replace(source); } /** @@ -327,7 +327,7 @@ public static String replace(Map valueMap, String prefix, String suffix, Object * @return the result of the replace operation */ public static String replaceSystemProperties(Object source) { - return new VariableFormat(System.getProperties()).replace(source); + return new VariableFormatter(System.getProperties()).replace(source); } /** diff --git a/src/test/org/apache/commons/lang/text/TextTestSuite.java b/src/test/org/apache/commons/lang/text/TextTestSuite.java index 5f55010a8..c6d629a58 100644 --- a/src/test/org/apache/commons/lang/text/TextTestSuite.java +++ b/src/test/org/apache/commons/lang/text/TextTestSuite.java @@ -51,7 +51,7 @@ public static Test suite() { suite.addTest(InterpolationTest.suite()); suite.addTest(StrBuilderTest.suite()); suite.addTest(StrTokenizerTest.suite()); - suite.addTestSuite(VariableFormatTest.class); + suite.addTestSuite(VariableFormatterTest.class); return suite; } diff --git a/src/test/org/apache/commons/lang/text/VariableFormatTest.java b/src/test/org/apache/commons/lang/text/VariableFormatterTest.java similarity index 86% rename from src/test/org/apache/commons/lang/text/VariableFormatTest.java rename to src/test/org/apache/commons/lang/text/VariableFormatterTest.java index 9dc88d4e6..2bbf62eee 100644 --- a/src/test/org/apache/commons/lang/text/VariableFormatTest.java +++ b/src/test/org/apache/commons/lang/text/VariableFormatterTest.java @@ -22,15 +22,15 @@ import junit.framework.TestCase; /** - * Test class for VariableResolver. + * Test class for VariableFormatter. * * @author Oliver Heger * @version $Id$ */ -public class VariableFormatTest extends TestCase { +public class VariableFormatterTest extends TestCase { static final String REPLACE_TEMPLATE = "The ${animal} jumps over the ${target}."; - private VariableFormat format; + private VariableFormatter format; private Map values; @@ -40,7 +40,7 @@ protected void setUp() throws Exception { map.put("animal", "quick brown fox"); map.put("target", "lazy dog"); setValues(map); - setFormat(new VariableFormat(map)); + setFormat(new VariableFormatter(map)); } /** @@ -48,31 +48,31 @@ protected void setUp() throws Exception { */ public void testInitialize() { assertNotNull(format.getValueMap()); - assertEquals(VariableFormat.DEFAULT_PREFIX, format.getVariablePrefix()); - assertEquals(VariableFormat.DEFAULT_SUFFIX, format.getVariableSuffix()); - assertEquals(VariableFormat.DEFAULT_ESCAPE, format.getEscapeCharacter()); + assertEquals(VariableFormatter.DEFAULT_PREFIX, format.getVariablePrefix()); + assertEquals(VariableFormatter.DEFAULT_SUFFIX, format.getVariableSuffix()); + assertEquals(VariableFormatter.DEFAULT_ESCAPE, format.getEscapeCharacter()); - format = new VariableFormat(values, "<<", ">>", '\\'); + format = new VariableFormatter(values, "<<", ">>", '\\'); assertEquals("<<", format.getVariablePrefix()); assertEquals(">>", format.getVariableSuffix()); assertEquals('\\', format.getEscapeCharacter()); try { - format = new VariableFormat(null); + format = new VariableFormatter(null); fail("Could create format object with null map!"); } catch (IllegalArgumentException iex) { // ok } try { - format = new VariableFormat(values, "${", null); + format = new VariableFormatter(values, "${", null); fail("Could create format object with undefined suffix!"); } catch (IllegalArgumentException iex) { // ok } try { - format = new VariableFormat(values, null, "]"); + format = new VariableFormatter(values, null, "]"); fail("Could create format object with undefined prefix!"); } catch (IllegalArgumentException iex) { // ok @@ -163,7 +163,7 @@ public void testReplaceObject() { * Tests chaning variable prefix and suffix and the escaping character. */ public void testNonDefaultTokens() { - format = new VariableFormat(values, "<<", ">>", '\\'); + format = new VariableFormatter(values, "<<", ">>", '\\'); assertEquals("The quick brown fox jumps over the lazy dog.", format .replace("The <> jumps over the <>.")); assertEquals("The quick brown fox jumps over the <>.", format @@ -174,10 +174,10 @@ public void testNonDefaultTokens() { * Tests invoking the static convenience methods. */ public void testNonInstanceMethods() { - assertEquals("The quick brown fox jumps over the lazy dog.", VariableFormat.replace(values, REPLACE_TEMPLATE)); + assertEquals("The quick brown fox jumps over the lazy dog.", VariableFormatter.replace(values, REPLACE_TEMPLATE)); values.put("animal", "cow"); values.put("target", "moon"); - assertEquals("The cow jumps over the moon.", VariableFormat.replace(values, "&", ";", + assertEquals("The cow jumps over the moon.", VariableFormatter.replace(values, "&", ";", "The &animal; jumps over the ⌖.")); } @@ -191,7 +191,7 @@ public void testReplaceSystemProperties() { buf.append(System.getProperty("os.name")); buf.append(", your home directory is "); buf.append(System.getProperty("user.home")).append('.'); - assertEquals(buf.toString(), VariableFormat.replaceSystemProperties("Hi ${user.name}, you are " + assertEquals(buf.toString(), VariableFormatter.replaceSystemProperties("Hi ${user.name}, you are " + "working with ${os.name}, your home " + "directory is ${user.home}.")); } @@ -204,11 +204,11 @@ void setValues(Map values) { this.values = values; } - VariableFormat getFormat() { + VariableFormatter getFormat() { return this.format; } - void setFormat(VariableFormat format) { + void setFormat(VariableFormatter format) { this.format = format; } }