KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > pdf > StreamCache


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: StreamCache.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.pdf;
21
22 import java.io.OutputStream JavaDoc;
23 import java.io.IOException JavaDoc;
24
25 /**
26  * Interface used to store the bytes for a PDFStream. It's actually a generic
27  * cached byte array. There's a factory that returns either an
28  * in-memory or tempfile based implementation based on a
29  * cacheToFile setting.
30  */

31 public interface StreamCache {
32
33     /**
34      * Get the current OutputStream. Do not store it - it may change
35      * from call to call.
36      *
37      * @return an output stream for this cache
38      * @throws IOException if there is an IO error
39      */

40     OutputStream JavaDoc getOutputStream() throws IOException JavaDoc;
41
42     /**
43      * Convenience method for writing data to the stream cache.
44      * @param data byte array to write
45      * @throws IOException if there is an IO error
46      */

47     void write(byte[] data) throws IOException JavaDoc;
48
49     /**
50      * Outputs the cached bytes to the given stream.
51      *
52      * @param out the stream to write to
53      * @return the number of bytes written
54      * @throws IOException if there is an IO error
55      */

56     int outputContents(OutputStream JavaDoc out) throws IOException JavaDoc;
57
58     /**
59      * Returns the current size of the stream.
60      *
61      * @return the size of the cache
62      * @throws IOException if there is an IO error
63      */

64     int getSize() throws IOException JavaDoc;
65
66     /**
67      * Clears and resets the cache.
68      *
69      * @throws IOException if there is an IO error
70      */

71     void clear() throws IOException JavaDoc;
72 }
73
74
Popular Tags