org.apache.fop.util.text

## Class AdvancedMessageFormat

- java.lang.Object
- - org.apache.fop.util.text.AdvancedMessageFormat

-     public class AdvancedMessageFormat
      extends java.lang.Object

  Formats messages based on a template and with a set of named parameters. This is similar to `MessageFormat` but uses named parameters and supports conditional sub-groups.

  Example:

  `Missing field "{fieldName}"[ at location: {location}]!`

  - Curly brackets ("{}") are used for fields.
  - Square brackets ("[]") are used to delimit conditional sub-groups. A sub-group is conditional when all fields inside the sub-group have a null value. In the case, everything between the brackets is skipped.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `AdvancedMessageFormat.Function` Implementations of this interface do some computation based on the message parameters given to it.
    `static interface` | `AdvancedMessageFormat.ObjectFormatter` Implementations of this interface format certain objects to strings.
    `static interface` | `AdvancedMessageFormat.Part` Represents a message template part.
    `static interface` | `AdvancedMessageFormat.PartFactory` Implementations of this interface parse a field part and return message parts.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AdvancedMessageFormat(java.lang.CharSequence pattern)` Construct a new message format.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `format(java.util.Map<java.lang.String,java.lang.Object> params)` Formats a message with the given parameters.
    `void` | `format(java.util.Map<java.lang.String,java.lang.Object> params, java.lang.StringBuffer target)` Formats a message with the given parameters.
    `static void` | `formatObject(java.lang.Object obj, java.lang.StringBuffer target)` Formats an object to a string and writes the result to a string buffer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AdvancedMessageFormat

          public AdvancedMessageFormat(java.lang.CharSequence pattern)

      Construct a new message format.
      Parameters:
        `pattern` - the message format pattern.

  - ### Method Detail

    - #### format

          public java.lang.String format(java.util.Map<java.lang.String,java.lang.Object> params)

      Formats a message with the given parameters.
      Parameters:
        `params` - a Map of named parameters (Contents: )
      Returns:
        the formatted message

    - #### format

          public void format(java.util.Map<java.lang.String,java.lang.Object> params,
                             java.lang.StringBuffer target)

      Formats a message with the given parameters.
      Parameters:
        `params` - a Map of named parameters (Contents: )
        `target` - the target StringBuffer to write the formatted message to

    - #### formatObject

          public static void formatObject(java.lang.Object obj,
                                          java.lang.StringBuffer target)

      Formats an object to a string and writes the result to a string buffer. This method usually uses the object's `toString()` method unless there is an `AdvancedMessageFormat.ObjectFormatter` that supports the object. `AdvancedMessageFormat.ObjectFormatter`s are registered through the service provider mechanism defined by the JAR specification.
      Parameters:
        `obj` - the object to be formatted
        `target` - the target string buffer

Copyright 1999-2015 The Apache Software Foundation. All Rights Reserved.