1 |
769 |
jeremybenn |
/* FormatBuffer.java -- General interface to build attributed strings.
|
2 |
|
|
Copyright (C) 2004 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is part of GNU Classpath.
|
5 |
|
|
|
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.
|
10 |
|
|
|
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.
|
15 |
|
|
|
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., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
|
|
02110-1301 USA.
|
20 |
|
|
|
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.
|
25 |
|
|
|
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;
|
38 |
|
|
|
39 |
|
|
import java.text.AttributedCharacterIterator;
|
40 |
|
|
import java.util.HashMap;
|
41 |
|
|
|
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.
|
48 |
|
|
*
|
49 |
|
|
* @author Guilhem Lavaux <guilhem@kaffe.org>
|
50 |
|
|
* @date April 10, 2004
|
51 |
|
|
*/
|
52 |
|
|
public interface FormatBuffer
|
53 |
|
|
{
|
54 |
|
|
/**
|
55 |
|
|
* This method appends a simple string to the buffer. This part of
|
56 |
|
|
* the buffer will be attributed using the default attribute.
|
57 |
|
|
*
|
58 |
|
|
* @param s The string to append to the buffer.
|
59 |
|
|
*/
|
60 |
|
|
public void append(String s);
|
61 |
|
|
|
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.
|
66 |
|
|
*
|
67 |
|
|
* @param s The string to append to the buffer.
|
68 |
|
|
* @param attr Attribute to use for the string in the buffer.
|
69 |
|
|
*/
|
70 |
|
|
public void append(String s, AttributedCharacterIterator.Attribute attr);
|
71 |
|
|
|
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}.
|
76 |
|
|
*
|
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.
|
81 |
|
|
*/
|
82 |
|
|
public void append(String s, int[] ranges, HashMap[] attrs);
|
83 |
|
|
|
84 |
|
|
/**
|
85 |
|
|
* This method appends a simple char to the buffer. This part of
|
86 |
|
|
* the buffer will be attributed using the default attribute.
|
87 |
|
|
*
|
88 |
|
|
* @param c The character to append to the buffer.
|
89 |
|
|
*/
|
90 |
|
|
public void append(char c);
|
91 |
|
|
|
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.
|
96 |
|
|
*
|
97 |
|
|
* @param c The character to append to the buffer.
|
98 |
|
|
* @param attr Attribute to use for the character in the buffer.
|
99 |
|
|
*/
|
100 |
|
|
public void append(char c, AttributedCharacterIterator.Attribute attr);
|
101 |
|
|
|
102 |
|
|
/**
|
103 |
|
|
* This method changes the current default attribute for the next string
|
104 |
|
|
* or character which will be appended to the buffer.
|
105 |
|
|
*
|
106 |
|
|
* @param attr The attribute which will be used by default.
|
107 |
|
|
*/
|
108 |
|
|
public void setDefaultAttribute(AttributedCharacterIterator.Attribute attr);
|
109 |
|
|
|
110 |
|
|
/**
|
111 |
|
|
* This method returns the current default attribute for the buffer.
|
112 |
|
|
*
|
113 |
|
|
* @return The default attribute for the buffer.
|
114 |
|
|
*/
|
115 |
|
|
public AttributedCharacterIterator.Attribute getDefaultAttribute();
|
116 |
|
|
|
117 |
|
|
/**
|
118 |
|
|
* This method cuts the last characters of the buffer. The number of
|
119 |
|
|
* characters to cut is given by "length".
|
120 |
|
|
*
|
121 |
|
|
* @param length Number of characters to cut at the end of the buffer.
|
122 |
|
|
*/
|
123 |
|
|
public void cutTail(int length);
|
124 |
|
|
|
125 |
|
|
/**
|
126 |
|
|
* This method resets completely the buffer.
|
127 |
|
|
*/
|
128 |
|
|
public void clear();
|
129 |
|
|
|
130 |
|
|
/**
|
131 |
|
|
* This method returns the number of character in the buffer.
|
132 |
|
|
*
|
133 |
|
|
* @return The number of character in the buffer.
|
134 |
|
|
*/
|
135 |
|
|
public int length();
|
136 |
|
|
}
|