01: /* Licensed to the Apache Software Foundation (ASF) under one or more
02: * contributor license agreements. See the NOTICE file distributed with
03: * this work for additional information regarding copyright ownership.
04: * The ASF licenses this file to You under the Apache License, Version 2.0
05: * (the "License"); you may not use this file except in compliance with
06: * the License. You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package java.util;
18:
19: /**
20: * Any class that need to perform customer formatting by transferring converter
21: * specifier 's' to Formatter should implement the Formattable interface. Basic
22: * format is allowed by the interface to format arbitrary objects.
23: */
24:
25: public interface Formattable {
26:
27: /**
28: * Formats the object using the specified formatter.
29: *
30: * @param formatter
31: * The formatter to use in the formatTo.
32: * @param flags
33: * The flags applied to the output format, which is a bitmask
34: * that is any combination of FormattableFlags.LEFT_JUSTIFY,
35: * FormattableFlags.UPPERCASE, and FormattableFlags.ALTERNATE. If
36: * no such flag is set, the output is formatted by the default
37: * formatting of the implementation of the interface.
38: * @param width
39: * The minimum number of characters that should be written to the
40: * output. Additional space ' ' is added to the output if the
41: * length of the converted value is less than the width until the
42: * length equals the width. These spaces are added at the
43: * beginning by default unless the flag
44: * FormattableFlags.LEFT_JUSTIFY is set, which denotes that
45: * padding should be added at the end. If width is -1, then no
46: * minimum requirement.
47: * @param precision
48: * The maximum number of characters that can be written to the
49: * output. The procedure to trunk the output according to the
50: * precision is invoked before that of padding to width. If the
51: * precision is -1, then no maximum requirement.
52: * @throws IllegalFormatException
53: * If any of the parameters is not supported.
54: */
55: void formatTo(Formatter formatter, int flags, int width,
56: int precision) throws IllegalFormatException;
57: }
|