rt/emul/compact/src/main/java/java/text/Format.java
author Jaroslav Tulach <jtulach@netbeans.org>
Thu, 03 Oct 2013 15:40:35 +0200
branchjdk7-b147
changeset 1334 588d5bf7a560
permissions -rw-r--r--
Set of JDK classes needed to run javac
jtulach@1334
     1
/*
jtulach@1334
     2
 * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
jtulach@1334
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jtulach@1334
     4
 *
jtulach@1334
     5
 * This code is free software; you can redistribute it and/or modify it
jtulach@1334
     6
 * under the terms of the GNU General Public License version 2 only, as
jtulach@1334
     7
 * published by the Free Software Foundation.  Oracle designates this
jtulach@1334
     8
 * particular file as subject to the "Classpath" exception as provided
jtulach@1334
     9
 * by Oracle in the LICENSE file that accompanied this code.
jtulach@1334
    10
 *
jtulach@1334
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
jtulach@1334
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jtulach@1334
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
jtulach@1334
    14
 * version 2 for more details (a copy is included in the LICENSE file that
jtulach@1334
    15
 * accompanied this code).
jtulach@1334
    16
 *
jtulach@1334
    17
 * You should have received a copy of the GNU General Public License version
jtulach@1334
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
jtulach@1334
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jtulach@1334
    20
 *
jtulach@1334
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jtulach@1334
    22
 * or visit www.oracle.com if you need additional information or have any
jtulach@1334
    23
 * questions.
jtulach@1334
    24
 */
jtulach@1334
    25
jtulach@1334
    26
/*
jtulach@1334
    27
 * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
jtulach@1334
    28
 * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
jtulach@1334
    29
 *
jtulach@1334
    30
 *   The original version of this source code and documentation is copyrighted
jtulach@1334
    31
 * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
jtulach@1334
    32
 * materials are provided under terms of a License Agreement between Taligent
jtulach@1334
    33
 * and Sun. This technology is protected by multiple US and International
jtulach@1334
    34
 * patents. This notice and attribution to Taligent may not be removed.
jtulach@1334
    35
 *   Taligent is a registered trademark of Taligent, Inc.
jtulach@1334
    36
 *
jtulach@1334
    37
 */
jtulach@1334
    38
jtulach@1334
    39
package java.text;
jtulach@1334
    40
jtulach@1334
    41
import java.io.Serializable;
jtulach@1334
    42
jtulach@1334
    43
/**
jtulach@1334
    44
 * <code>Format</code> is an abstract base class for formatting locale-sensitive
jtulach@1334
    45
 * information such as dates, messages, and numbers.
jtulach@1334
    46
 *
jtulach@1334
    47
 * <p>
jtulach@1334
    48
 * <code>Format</code> defines the programming interface for formatting
jtulach@1334
    49
 * locale-sensitive objects into <code>String</code>s (the
jtulach@1334
    50
 * <code>format</code> method) and for parsing <code>String</code>s back
jtulach@1334
    51
 * into objects (the <code>parseObject</code> method).
jtulach@1334
    52
 *
jtulach@1334
    53
 * <p>
jtulach@1334
    54
 * Generally, a format's <code>parseObject</code> method must be able to parse
jtulach@1334
    55
 * any string formatted by its <code>format</code> method. However, there may
jtulach@1334
    56
 * be exceptional cases where this is not possible. For example, a
jtulach@1334
    57
 * <code>format</code> method might create two adjacent integer numbers with
jtulach@1334
    58
 * no separator in between, and in this case the <code>parseObject</code> could
jtulach@1334
    59
 * not tell which digits belong to which number.
jtulach@1334
    60
 *
jtulach@1334
    61
 * <h4>Subclassing</h4>
jtulach@1334
    62
 *
jtulach@1334
    63
 * <p>
jtulach@1334
    64
 * The Java Platform provides three specialized subclasses of <code>Format</code>--
jtulach@1334
    65
 * <code>DateFormat</code>, <code>MessageFormat</code>, and
jtulach@1334
    66
 * <code>NumberFormat</code>--for formatting dates, messages, and numbers,
jtulach@1334
    67
 * respectively.
jtulach@1334
    68
 * <p>
jtulach@1334
    69
 * Concrete subclasses must implement three methods:
jtulach@1334
    70
 * <ol>
jtulach@1334
    71
 * <li> <code>format(Object obj, StringBuffer toAppendTo, FieldPosition pos)</code>
jtulach@1334
    72
 * <li> <code>formatToCharacterIterator(Object obj)</code>
jtulach@1334
    73
 * <li> <code>parseObject(String source, ParsePosition pos)</code>
jtulach@1334
    74
 * </ol>
jtulach@1334
    75
 * These general methods allow polymorphic parsing and formatting of objects
jtulach@1334
    76
 * and are used, for example, by <code>MessageFormat</code>.
jtulach@1334
    77
 * Subclasses often also provide additional <code>format</code> methods for
jtulach@1334
    78
 * specific input types as well as <code>parse</code> methods for specific
jtulach@1334
    79
 * result types. Any <code>parse</code> method that does not take a
jtulach@1334
    80
 * <code>ParsePosition</code> argument should throw <code>ParseException</code>
jtulach@1334
    81
 * when no text in the required format is at the beginning of the input text.
jtulach@1334
    82
 *
jtulach@1334
    83
 * <p>
jtulach@1334
    84
 * Most subclasses will also implement the following factory methods:
jtulach@1334
    85
 * <ol>
jtulach@1334
    86
 * <li>
jtulach@1334
    87
 * <code>getInstance</code> for getting a useful format object appropriate
jtulach@1334
    88
 * for the current locale
jtulach@1334
    89
 * <li>
jtulach@1334
    90
 * <code>getInstance(Locale)</code> for getting a useful format
jtulach@1334
    91
 * object appropriate for the specified locale
jtulach@1334
    92
 * </ol>
jtulach@1334
    93
 * In addition, some subclasses may also implement other
jtulach@1334
    94
 * <code>getXxxxInstance</code> methods for more specialized control. For
jtulach@1334
    95
 * example, the <code>NumberFormat</code> class provides
jtulach@1334
    96
 * <code>getPercentInstance</code> and <code>getCurrencyInstance</code>
jtulach@1334
    97
 * methods for getting specialized number formatters.
jtulach@1334
    98
 *
jtulach@1334
    99
 * <p>
jtulach@1334
   100
 * Subclasses of <code>Format</code> that allow programmers to create objects
jtulach@1334
   101
 * for locales (with <code>getInstance(Locale)</code> for example)
jtulach@1334
   102
 * must also implement the following class method:
jtulach@1334
   103
 * <blockquote>
jtulach@1334
   104
 * <pre>
jtulach@1334
   105
 * public static Locale[] getAvailableLocales()
jtulach@1334
   106
 * </pre>
jtulach@1334
   107
 * </blockquote>
jtulach@1334
   108
 *
jtulach@1334
   109
 * <p>
jtulach@1334
   110
 * And finally subclasses may define a set of constants to identify the various
jtulach@1334
   111
 * fields in the formatted output. These constants are used to create a FieldPosition
jtulach@1334
   112
 * object which identifies what information is contained in the field and its
jtulach@1334
   113
 * position in the formatted result. These constants should be named
jtulach@1334
   114
 * <code><em>item</em>_FIELD</code> where <code><em>item</em></code> identifies
jtulach@1334
   115
 * the field. For examples of these constants, see <code>ERA_FIELD</code> and its
jtulach@1334
   116
 * friends in {@link DateFormat}.
jtulach@1334
   117
 *
jtulach@1334
   118
 * <h4><a name="synchronization">Synchronization</a></h4>
jtulach@1334
   119
 *
jtulach@1334
   120
 * <p>
jtulach@1334
   121
 * Formats are generally not synchronized.
jtulach@1334
   122
 * It is recommended to create separate format instances for each thread.
jtulach@1334
   123
 * If multiple threads access a format concurrently, it must be synchronized
jtulach@1334
   124
 * externally.
jtulach@1334
   125
 *
jtulach@1334
   126
 * @see          java.text.ParsePosition
jtulach@1334
   127
 * @see          java.text.FieldPosition
jtulach@1334
   128
 * @see          java.text.NumberFormat
jtulach@1334
   129
 * @see          java.text.DateFormat
jtulach@1334
   130
 * @see          java.text.MessageFormat
jtulach@1334
   131
 * @author       Mark Davis
jtulach@1334
   132
 */
jtulach@1334
   133
public abstract class Format implements Serializable, Cloneable {
jtulach@1334
   134
jtulach@1334
   135
    private static final long serialVersionUID = -299282585814624189L;
jtulach@1334
   136
jtulach@1334
   137
    /**
jtulach@1334
   138
     * Sole constructor.  (For invocation by subclass constructors, typically
jtulach@1334
   139
     * implicit.)
jtulach@1334
   140
     */
jtulach@1334
   141
    protected Format() {
jtulach@1334
   142
    }
jtulach@1334
   143
jtulach@1334
   144
    /**
jtulach@1334
   145
     * Formats an object to produce a string. This is equivalent to
jtulach@1334
   146
     * <blockquote>
jtulach@1334
   147
     * {@link #format(Object, StringBuffer, FieldPosition) format}<code>(obj,
jtulach@1334
   148
     *         new StringBuffer(), new FieldPosition(0)).toString();</code>
jtulach@1334
   149
     * </blockquote>
jtulach@1334
   150
     *
jtulach@1334
   151
     * @param obj    The object to format
jtulach@1334
   152
     * @return       Formatted string.
jtulach@1334
   153
     * @exception IllegalArgumentException if the Format cannot format the given
jtulach@1334
   154
     *            object
jtulach@1334
   155
     */
jtulach@1334
   156
    public final String format (Object obj) {
jtulach@1334
   157
        return format(obj, new StringBuffer(), new FieldPosition(0)).toString();
jtulach@1334
   158
    }
jtulach@1334
   159
jtulach@1334
   160
    /**
jtulach@1334
   161
     * Formats an object and appends the resulting text to a given string
jtulach@1334
   162
     * buffer.
jtulach@1334
   163
     * If the <code>pos</code> argument identifies a field used by the format,
jtulach@1334
   164
     * then its indices are set to the beginning and end of the first such
jtulach@1334
   165
     * field encountered.
jtulach@1334
   166
     *
jtulach@1334
   167
     * @param obj    The object to format
jtulach@1334
   168
     * @param toAppendTo    where the text is to be appended
jtulach@1334
   169
     * @param pos    A <code>FieldPosition</code> identifying a field
jtulach@1334
   170
     *               in the formatted text
jtulach@1334
   171
     * @return       the string buffer passed in as <code>toAppendTo</code>,
jtulach@1334
   172
     *               with formatted text appended
jtulach@1334
   173
     * @exception NullPointerException if <code>toAppendTo</code> or
jtulach@1334
   174
     *            <code>pos</code> is null
jtulach@1334
   175
     * @exception IllegalArgumentException if the Format cannot format the given
jtulach@1334
   176
     *            object
jtulach@1334
   177
     */
jtulach@1334
   178
    public abstract StringBuffer format(Object obj,
jtulach@1334
   179
                    StringBuffer toAppendTo,
jtulach@1334
   180
                    FieldPosition pos);
jtulach@1334
   181
jtulach@1334
   182
    /**
jtulach@1334
   183
     * Formats an Object producing an <code>AttributedCharacterIterator</code>.
jtulach@1334
   184
     * You can use the returned <code>AttributedCharacterIterator</code>
jtulach@1334
   185
     * to build the resulting String, as well as to determine information
jtulach@1334
   186
     * about the resulting String.
jtulach@1334
   187
     * <p>
jtulach@1334
   188
     * Each attribute key of the AttributedCharacterIterator will be of type
jtulach@1334
   189
     * <code>Field</code>. It is up to each <code>Format</code> implementation
jtulach@1334
   190
     * to define what the legal values are for each attribute in the
jtulach@1334
   191
     * <code>AttributedCharacterIterator</code>, but typically the attribute
jtulach@1334
   192
     * key is also used as the attribute value.
jtulach@1334
   193
     * <p>The default implementation creates an
jtulach@1334
   194
     * <code>AttributedCharacterIterator</code> with no attributes. Subclasses
jtulach@1334
   195
     * that support fields should override this and create an
jtulach@1334
   196
     * <code>AttributedCharacterIterator</code> with meaningful attributes.
jtulach@1334
   197
     *
jtulach@1334
   198
     * @exception NullPointerException if obj is null.
jtulach@1334
   199
     * @exception IllegalArgumentException when the Format cannot format the
jtulach@1334
   200
     *            given object.
jtulach@1334
   201
     * @param obj The object to format
jtulach@1334
   202
     * @return AttributedCharacterIterator describing the formatted value.
jtulach@1334
   203
     * @since 1.4
jtulach@1334
   204
     */
jtulach@1334
   205
    public AttributedCharacterIterator formatToCharacterIterator(Object obj) {
jtulach@1334
   206
        return createAttributedCharacterIterator(format(obj));
jtulach@1334
   207
    }
jtulach@1334
   208
jtulach@1334
   209
    /**
jtulach@1334
   210
     * Parses text from a string to produce an object.
jtulach@1334
   211
     * <p>
jtulach@1334
   212
     * The method attempts to parse text starting at the index given by
jtulach@1334
   213
     * <code>pos</code>.
jtulach@1334
   214
     * If parsing succeeds, then the index of <code>pos</code> is updated
jtulach@1334
   215
     * to the index after the last character used (parsing does not necessarily
jtulach@1334
   216
     * use all characters up to the end of the string), and the parsed
jtulach@1334
   217
     * object is returned. The updated <code>pos</code> can be used to
jtulach@1334
   218
     * indicate the starting point for the next call to this method.
jtulach@1334
   219
     * If an error occurs, then the index of <code>pos</code> is not
jtulach@1334
   220
     * changed, the error index of <code>pos</code> is set to the index of
jtulach@1334
   221
     * the character where the error occurred, and null is returned.
jtulach@1334
   222
     *
jtulach@1334
   223
     * @param source A <code>String</code>, part of which should be parsed.
jtulach@1334
   224
     * @param pos A <code>ParsePosition</code> object with index and error
jtulach@1334
   225
     *            index information as described above.
jtulach@1334
   226
     * @return An <code>Object</code> parsed from the string. In case of
jtulach@1334
   227
     *         error, returns null.
jtulach@1334
   228
     * @exception NullPointerException if <code>pos</code> is null.
jtulach@1334
   229
     */
jtulach@1334
   230
    public abstract Object parseObject (String source, ParsePosition pos);
jtulach@1334
   231
jtulach@1334
   232
    /**
jtulach@1334
   233
     * Parses text from the beginning of the given string to produce an object.
jtulach@1334
   234
     * The method may not use the entire text of the given string.
jtulach@1334
   235
     *
jtulach@1334
   236
     * @param source A <code>String</code> whose beginning should be parsed.
jtulach@1334
   237
     * @return An <code>Object</code> parsed from the string.
jtulach@1334
   238
     * @exception ParseException if the beginning of the specified string
jtulach@1334
   239
     *            cannot be parsed.
jtulach@1334
   240
     */
jtulach@1334
   241
    public Object parseObject(String source) throws ParseException {
jtulach@1334
   242
        ParsePosition pos = new ParsePosition(0);
jtulach@1334
   243
        Object result = parseObject(source, pos);
jtulach@1334
   244
        if (pos.index == 0) {
jtulach@1334
   245
            throw new ParseException("Format.parseObject(String) failed",
jtulach@1334
   246
                pos.errorIndex);
jtulach@1334
   247
        }
jtulach@1334
   248
        return result;
jtulach@1334
   249
    }
jtulach@1334
   250
jtulach@1334
   251
    /**
jtulach@1334
   252
     * Creates and returns a copy of this object.
jtulach@1334
   253
     *
jtulach@1334
   254
     * @return a clone of this instance.
jtulach@1334
   255
     */
jtulach@1334
   256
    public Object clone() {
jtulach@1334
   257
        try {
jtulach@1334
   258
            return super.clone();
jtulach@1334
   259
        } catch (CloneNotSupportedException e) {
jtulach@1334
   260
            // will never happen
jtulach@1334
   261
            return null;
jtulach@1334
   262
        }
jtulach@1334
   263
    }
jtulach@1334
   264
jtulach@1334
   265
    //
jtulach@1334
   266
    // Convenience methods for creating AttributedCharacterIterators from
jtulach@1334
   267
    // different parameters.
jtulach@1334
   268
    //
jtulach@1334
   269
jtulach@1334
   270
    /**
jtulach@1334
   271
     * Creates an <code>AttributedCharacterIterator</code> for the String
jtulach@1334
   272
     * <code>s</code>.
jtulach@1334
   273
     *
jtulach@1334
   274
     * @param s String to create AttributedCharacterIterator from
jtulach@1334
   275
     * @return AttributedCharacterIterator wrapping s
jtulach@1334
   276
     */
jtulach@1334
   277
    AttributedCharacterIterator createAttributedCharacterIterator(String s) {
jtulach@1334
   278
        AttributedString as = new AttributedString(s);
jtulach@1334
   279
jtulach@1334
   280
        return as.getIterator();
jtulach@1334
   281
    }
jtulach@1334
   282
jtulach@1334
   283
    /**
jtulach@1334
   284
     * Creates an <code>AttributedCharacterIterator</code> containg the
jtulach@1334
   285
     * concatenated contents of the passed in
jtulach@1334
   286
     * <code>AttributedCharacterIterator</code>s.
jtulach@1334
   287
     *
jtulach@1334
   288
     * @param iterators AttributedCharacterIterators used to create resulting
jtulach@1334
   289
     *                  AttributedCharacterIterators
jtulach@1334
   290
     * @return AttributedCharacterIterator wrapping passed in
jtulach@1334
   291
     *         AttributedCharacterIterators
jtulach@1334
   292
     */
jtulach@1334
   293
    AttributedCharacterIterator createAttributedCharacterIterator(
jtulach@1334
   294
                       AttributedCharacterIterator[] iterators) {
jtulach@1334
   295
        AttributedString as = new AttributedString(iterators);
jtulach@1334
   296
jtulach@1334
   297
        return as.getIterator();
jtulach@1334
   298
    }
jtulach@1334
   299
jtulach@1334
   300
    /**
jtulach@1334
   301
     * Returns an AttributedCharacterIterator with the String
jtulach@1334
   302
     * <code>string</code> and additional key/value pair <code>key</code>,
jtulach@1334
   303
     * <code>value</code>.
jtulach@1334
   304
     *
jtulach@1334
   305
     * @param string String to create AttributedCharacterIterator from
jtulach@1334
   306
     * @param key Key for AttributedCharacterIterator
jtulach@1334
   307
     * @param value Value associated with key in AttributedCharacterIterator
jtulach@1334
   308
     * @return AttributedCharacterIterator wrapping args
jtulach@1334
   309
     */
jtulach@1334
   310
    AttributedCharacterIterator createAttributedCharacterIterator(
jtulach@1334
   311
                      String string, AttributedCharacterIterator.Attribute key,
jtulach@1334
   312
                      Object value) {
jtulach@1334
   313
        AttributedString as = new AttributedString(string);
jtulach@1334
   314
jtulach@1334
   315
        as.addAttribute(key, value);
jtulach@1334
   316
        return as.getIterator();
jtulach@1334
   317
    }
jtulach@1334
   318
jtulach@1334
   319
    /**
jtulach@1334
   320
     * Creates an AttributedCharacterIterator with the contents of
jtulach@1334
   321
     * <code>iterator</code> and the additional attribute <code>key</code>
jtulach@1334
   322
     * <code>value</code>.
jtulach@1334
   323
     *
jtulach@1334
   324
     * @param iterator Initial AttributedCharacterIterator to add arg to
jtulach@1334
   325
     * @param key Key for AttributedCharacterIterator
jtulach@1334
   326
     * @param value Value associated with key in AttributedCharacterIterator
jtulach@1334
   327
     * @return AttributedCharacterIterator wrapping args
jtulach@1334
   328
     */
jtulach@1334
   329
    AttributedCharacterIterator createAttributedCharacterIterator(
jtulach@1334
   330
              AttributedCharacterIterator iterator,
jtulach@1334
   331
              AttributedCharacterIterator.Attribute key, Object value) {
jtulach@1334
   332
        AttributedString as = new AttributedString(iterator);
jtulach@1334
   333
jtulach@1334
   334
        as.addAttribute(key, value);
jtulach@1334
   335
        return as.getIterator();
jtulach@1334
   336
    }
jtulach@1334
   337
jtulach@1334
   338
jtulach@1334
   339
    /**
jtulach@1334
   340
     * Defines constants that are used as attribute keys in the
jtulach@1334
   341
     * <code>AttributedCharacterIterator</code> returned
jtulach@1334
   342
     * from <code>Format.formatToCharacterIterator</code> and as
jtulach@1334
   343
     * field identifiers in <code>FieldPosition</code>.
jtulach@1334
   344
     *
jtulach@1334
   345
     * @since 1.4
jtulach@1334
   346
     */
jtulach@1334
   347
    public static class Field extends AttributedCharacterIterator.Attribute {
jtulach@1334
   348
jtulach@1334
   349
        // Proclaim serial compatibility with 1.4 FCS
jtulach@1334
   350
        private static final long serialVersionUID = 276966692217360283L;
jtulach@1334
   351
jtulach@1334
   352
        /**
jtulach@1334
   353
         * Creates a Field with the specified name.
jtulach@1334
   354
         *
jtulach@1334
   355
         * @param name Name of the attribute
jtulach@1334
   356
         */
jtulach@1334
   357
        protected Field(String name) {
jtulach@1334
   358
            super(name);
jtulach@1334
   359
        }
jtulach@1334
   360
    }
jtulach@1334
   361
jtulach@1334
   362
jtulach@1334
   363
    /**
jtulach@1334
   364
     * FieldDelegate is notified by the various <code>Format</code>
jtulach@1334
   365
     * implementations as they are formatting the Objects. This allows for
jtulach@1334
   366
     * storage of the individual sections of the formatted String for
jtulach@1334
   367
     * later use, such as in a <code>FieldPosition</code> or for an
jtulach@1334
   368
     * <code>AttributedCharacterIterator</code>.
jtulach@1334
   369
     * <p>
jtulach@1334
   370
     * Delegates should NOT assume that the <code>Format</code> will notify
jtulach@1334
   371
     * the delegate of fields in any particular order.
jtulach@1334
   372
     *
jtulach@1334
   373
     * @see FieldPosition.Delegate
jtulach@1334
   374
     * @see CharacterIteratorFieldDelegate
jtulach@1334
   375
     */
jtulach@1334
   376
    interface FieldDelegate {
jtulach@1334
   377
        /**
jtulach@1334
   378
         * Notified when a particular region of the String is formatted. This
jtulach@1334
   379
         * method will be invoked if there is no corresponding integer field id
jtulach@1334
   380
         * matching <code>attr</code>.
jtulach@1334
   381
         *
jtulach@1334
   382
         * @param attr Identifies the field matched
jtulach@1334
   383
         * @param value Value associated with the field
jtulach@1334
   384
         * @param start Beginning location of the field, will be >= 0
jtulach@1334
   385
         * @param end End of the field, will be >= start and <= buffer.length()
jtulach@1334
   386
         * @param buffer Contains current formatted value, receiver should
jtulach@1334
   387
         *        NOT modify it.
jtulach@1334
   388
         */
jtulach@1334
   389
        public void formatted(Format.Field attr, Object value, int start,
jtulach@1334
   390
                              int end, StringBuffer buffer);
jtulach@1334
   391
jtulach@1334
   392
        /**
jtulach@1334
   393
         * Notified when a particular region of the String is formatted.
jtulach@1334
   394
         *
jtulach@1334
   395
         * @param fieldID Identifies the field by integer
jtulach@1334
   396
         * @param attr Identifies the field matched
jtulach@1334
   397
         * @param value Value associated with the field
jtulach@1334
   398
         * @param start Beginning location of the field, will be >= 0
jtulach@1334
   399
         * @param end End of the field, will be >= start and <= buffer.length()
jtulach@1334
   400
         * @param buffer Contains current formatted value, receiver should
jtulach@1334
   401
         *        NOT modify it.
jtulach@1334
   402
         */
jtulach@1334
   403
        public void formatted(int fieldID, Format.Field attr, Object value,
jtulach@1334
   404
                              int start, int end, StringBuffer buffer);
jtulach@1334
   405
    }
jtulach@1334
   406
}