KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > stefanochizzolini > clown > bytes > IBuffer


1 /*
2   Copyright 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
3
4   Contributors:
5     * Stefano Chizzolini (original code developer, info@stefanochizzolini.it):
6       contributed code is Copyright 2006 by Stefano Chizzolini.
7
8   This file should be part of the source code distribution of "PDF Clown library"
9   (the Program): see the accompanying README files for more info.
10
11   This Program is free software; you can redistribute it and/or modify it under
12   the terms of the GNU General Public License as published by the Free Software
13   Foundation; either version 2 of the License, or (at your option) any later version.
14
15   This Program is distributed in the hope that it will be useful, but WITHOUT ANY
16   WARRANTY, either expressed or implied; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18
19   You should have received a copy of the GNU General Public License along with this
20   Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
21
22   Redistribution and use, with or without modification, are permitted provided that such
23   redistributions retain the above copyright notice, license and disclaimer, along with
24   this list of conditions.
25 */

26
27 package it.stefanochizzolini.clown.bytes;
28
29 import it.stefanochizzolini.clown.bytes.filters.Filter;
30
31 /**
32   Buffer interface.
33   <p>Its pivotal concept is the array index.</p>
34 */

35 public interface IBuffer
36  extends IInputStream
37 {
38   /**
39     Appends a byte to the buffer.
40     @param data Byte to copy.
41   */

42   void append(
43     byte data
44     );
45
46   /**
47     Appends a byte array to the buffer.
48     @param data Byte array to copy.
49   */

50   void append(
51     byte[] data
52     );
53
54   /**
55     Appends a byte range to the buffer.
56     @param data Byte array from which the byte range has to be copied.
57     @param offset Location in the byte array at which copying begins.
58     @param length Number of bytes to copy.
59   */

60   void append(
61     byte[] data,
62     int offset,
63     int length
64     );
65
66   /**
67     Appends a string to the buffer.
68     @param data String to copy.
69   */

70   void append(
71     String JavaDoc data
72     );
73
74   /**
75     Appends an IInputStream to the buffer.
76     @param data Source data to copy.
77   */

78   void append(
79     IInputStream data
80     );
81
82   /**
83     Gets a clone of the buffer.
84     @return Deep copy of the buffer.
85   */

86   IBuffer clone(
87     );
88
89   /**
90     Applies the specified filter to decode the buffer.
91     @param filter Filter to use for decoding the buffer.
92   */

93   void decode(
94     Filter filter
95     );
96
97   /**
98     Deletes a byte chunk from the buffer.
99     @param index Location at which deletion has to begin.
100     @param length Number of bytes to delete.
101   */

102   void delete(
103     int index,
104     int length
105     );
106
107   /**
108     Applies the specified filter to encode the buffer.
109     @param filter Filter to use for encoding the buffer.
110     @return Encoded buffer.
111   */

112   byte[] encode(
113     Filter filter
114     );
115
116   /**
117     Gets the byte at a specified location.
118     @param index A location in the buffer.
119     @return Byte at the specified location.
120   */

121   int getByte(
122     int index
123     );
124
125     /**
126     Gets the byte range beginning at a specified location.
127     @param index Location at which the byte range has to begin.
128     @param length Number of bytes to copy.
129     @return Byte range beginning at the specified location.
130   */

131   byte[] getByteArray(
132     int index,
133     int length
134     );
135
136   /**
137     Gets the string beginning at a specified location.
138     @param index Location at which the string has to begin.
139     @param length Number of bytes to convert.
140     @return String beginning at the specified location.
141   */

142   String JavaDoc getString(
143     int index,
144     int length
145     );
146
147   /**
148     Gets the allocated buffer size.
149     @return Allocated buffer size.
150   */

151   int getCapacity(
152     );
153
154   /**
155     Inserts a byte array into the buffer.
156     @param index Location at which the byte array has to be inserted.
157     @param data Byte array to insert.
158   */

159   void insert(
160     int index,
161     byte[] data
162     );
163
164   /**
165     Inserts a byte range into the buffer.
166     @param index Location at which the byte range has to be inserted.
167     @param data Byte array from which the byte range has to be copied.
168     @param offset Location in the byte array at which copying begins.
169     @param length Number of bytes to copy.
170   */

171   void insert(
172     int index,
173     byte[] data,
174     int offset,
175     int length
176     );
177
178   /**
179     Inserts a string into the buffer.
180     @param index Location at which the string has to be inserted.
181     @param data String to insert.
182   */

183   void insert(
184     int index,
185     String JavaDoc data
186     );
187
188   /**
189     Inserts an IInputStream into the buffer.
190     @param index Location at which the IInputStream has to be inserted.
191     @param data Source data to copy.
192   */

193   void insert(
194     int index,
195     IInputStream data
196     );
197
198   /**
199     Replaces the buffer contents with a byte array.
200     @param index Location at which the byte array has to be copied.
201     @param data Byte array to copy.
202   */

203   void replace(
204     int index,
205     byte[] data
206     );
207
208   /**
209     Replaces the buffer contents with a byte range.
210     @param index Location at which the byte range has to be copied.
211     @param data Byte array from which the byte range has to be copied.
212     @param offset Location in the byte array at which copying begins.
213     @param length Number of bytes to copy.
214   */

215   void replace(
216     int index,
217     byte[] data,
218     int offset,
219     int length
220     );
221
222   /**
223     Replaces the buffer contents with a string.
224     @param index Location at which the string has to be copied.
225     @param data String to copy.
226   */

227   void replace(
228     int index,
229     String JavaDoc data
230     );
231
232   /**
233     Replaces the buffer contents with an IInputStream.
234     @param index Location at which the IInputStream has to be copied.
235     @param data Source data to copy.
236   */

237   void replace(
238     int index,
239     IInputStream data
240     );
241
242   /**
243     Sets the used buffer size.
244     @param value New length.
245   */

246   void setLength(
247     int value
248     );
249
250   /**
251     Writes the buffer data to a stream.
252     @param stream Target stream.
253   */

254   void writeTo(
255     IOutputStream stream
256     );
257 }
Popular Tags