From 20d5b0101b75ce5d14e772639c143700d51598d9 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Tue, 26 Feb 2008 15:36:55 +0000 Subject: [PATCH] improve documentation git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@631256 13f79535-47bb-0310-9956-ffa450edef68 --- .../lang/text/ExtendedMessageFormat.java | 40 +++++++++++++++---- .../commons/lang/text/FormatFactory.java | 4 +- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java b/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java index cf0a9b151..e576a92b6 100644 --- a/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java +++ b/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java @@ -28,11 +28,35 @@ import org.apache.commons.lang.Validate; /** - * Extends MessageFormat to allow pluggable/additional formatting - * options for embedded format elements; requires elaboration. + * Extends java.text.MessageFormat to allow pluggable/additional formatting + * options for embedded format elements. Client code should specify a registry + * of FormatFactory instances associated with String + * format names. This registry will be consulted when the format elements are + * parsed from the message pattern. In this way custom patterns can be specified, + * and the formats supported by java.text.MessageFormat can be overridden + * at the format and/or format style level (@see MessageFormat). A "format element" + * embedded in the message pattern is specified (()? signifies optionality):
+ *
+ * {argument-number
+ * (
+ *     ,format-name
+ *     (,format-style)?
+ * )?
+ * }
+ * 
* - * Note that the mutator methods for the replacement Formats are to be considered - * unnecessary and thus have been disabled (UnsupportedOperationException). + * format-name and format-style values are trimmed of surrounding whitespace + * in the manner of java.text.MessageFormat. If format-name denotes + * FormatFactory formatFactoryInstance in registry, a Format + * matching format-name and format-style is requested from + * formatFactoryInstance. If this is successful, the Format + * found is used for this format element. + * + *

NOTICE: The various subformat mutator methods are considered unnecessary; they exist on the parent + * class to allow the type of customization which it is the job of this class to provide in + * a configurable fashion. These methods have thus been disabled and will throw + * UnsupportedOperationExceptions if called.

* * @author Matt Benson * @author Niall Pemberton @@ -175,7 +199,7 @@ public final void applyPattern(String pattern) { /** * {@inheritDoc} - * UNSUPPORTED + * @throws UnsupportedOperationException */ public void setFormat(int formatElementIndex, Format newFormat) { throw new UnsupportedOperationException(); @@ -183,7 +207,7 @@ public void setFormat(int formatElementIndex, Format newFormat) { /** * {@inheritDoc} - * UNSUPPORTED + * @throws UnsupportedOperationException */ public void setFormatByArgumentIndex(int argumentIndex, Format newFormat) { throw new UnsupportedOperationException(); @@ -191,7 +215,7 @@ public void setFormatByArgumentIndex(int argumentIndex, Format newFormat) { /** * {@inheritDoc} - * UNSUPPORTED + * @throws UnsupportedOperationException */ public void setFormats(Format[] newFormats) { throw new UnsupportedOperationException(); @@ -199,7 +223,7 @@ public void setFormats(Format[] newFormats) { /** * {@inheritDoc} - * UNSUPPORTED + * @throws UnsupportedOperationException */ public void setFormatsByArgumentIndex(Format[] newFormats) { throw new UnsupportedOperationException(); diff --git a/src/java/org/apache/commons/lang/text/FormatFactory.java b/src/java/org/apache/commons/lang/text/FormatFactory.java index b0ae7447d..369a4eb9d 100644 --- a/src/java/org/apache/commons/lang/text/FormatFactory.java +++ b/src/java/org/apache/commons/lang/text/FormatFactory.java @@ -15,7 +15,9 @@ public interface FormatFactory { * Create or retrieve a format instance. * * @param name The format type name - * @param arguments Arguments used to create the format instance + * @param arguments Arguments used to create the format instance. This allows the + * FormatFactory to implement the "format style" + * concept from java.text.MessageFormat. * @param locale The locale, may be null * @return The format instance */