This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / libjava / gnu / java / text / FormatBuffer.java
blobaddfcbe5c1cda9ee918ac13e1999e34a14d5fb92
1 /* FormatBuffer.java -- General interface to build attributed strings.
2 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
37 package gnu.java.text;
39 import java.text.AttributedCharacterIterator;
40 import java.util.HashMap;
42 /**
43 * This interface describes a modifiable buffer which contains attributed
44 * characters. The implementation may or may not implements attributes. It
45 * aims to greatly simplify and clarify the implementation of java.text
46 * formatters. The buffer may be appended or have its tail cut. It may also
47 * be completely cleant up.
49 * @author Guilhem Lavaux <guilhem@kaffe.org>
50 * @date April 10, 2004
52 public interface FormatBuffer
54 /**
55 * This method appends a simple string to the buffer. This part of
56 * the buffer will be attributed using the default attribute.
58 * @param s The string to append to the buffer.
60 public void append(String s);
62 /**
63 * This method appends a simple string to the buffer. This part of
64 * the buffer will have the specified attribute (and only this one).
65 * The default attribute may be changed after calling this method.
67 * @param s The string to append to the buffer.
68 * @param attr Attribute to use for the string in the buffer.
70 public void append(String s, AttributedCharacterIterator.Attribute attr);
72 /**
73 * This method appends a simple string to the buffer. This part of
74 * the buffer will be attributed using the specified ranges and attributes.
75 * To have an example on how to specify ranges see {@link gnu.java.text.FormatCharacterIterator}.
77 * @param s The string to append to the buffer.
78 * @param ranges The ranges describing how the attributes should be applied
79 * to the string.
80 * @param attrs The attributes of the string in the buffer.
82 public void append(String s, int[] ranges, HashMap[] attrs);
84 /**
85 * This method appends a simple char to the buffer. This part of
86 * the buffer will be attributed using the default attribute.
88 * @param c The character to append to the buffer.
90 public void append(char c);
92 /**
93 * This method appends a simple character to the buffer. This part of
94 * the buffer will have the specified attribute (and only this one).
95 * The default attribute may be changed after calling this method.
97 * @param c The character to append to the buffer.
98 * @param attr Attribute to use for the character in the buffer.
100 public void append(char c, AttributedCharacterIterator.Attribute attr);
103 * This method changes the current default attribute for the next string
104 * or character which will be appended to the buffer.
106 * @param attr The attribute which will be used by default.
108 public void setDefaultAttribute(AttributedCharacterIterator.Attribute attr);
111 * This method returns the current default attribute for the buffer.
113 * @return The default attribute for the buffer.
115 public AttributedCharacterIterator.Attribute getDefaultAttribute();
118 * This method cuts the last characters of the buffer. The number of
119 * characters to cut is given by "length".
121 * @param length Number of characters to cut at the end of the buffer.
123 public void cutTail(int length);
126 * This method resets completely the buffer.
128 public void clear();
131 * This method returns the number of character in the buffer.
133 * @return The number of character in the buffer.
135 public int length();