KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > poifs > storage > BigBlock


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    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
19 package org.apache.poi.poifs.storage;
20
21 /**
22  * Abstract base class of all POIFS block storage classes. All
23  * extensions of BigBlock should write 512 bytes of data when
24  * requested to write their data.
25  *
26  * This class has package scope, as there is no reason at this time to
27  * make the class public.
28  *
29  * @author Marc Johnson (mjohnson at apache dot org)
30  */

31
32 import java.io.IOException JavaDoc;
33 import java.io.OutputStream JavaDoc;
34
35 abstract class BigBlock
36     implements BlockWritable
37 {
38
39     /**
40      * Default implementation of write for extending classes that
41      * contain their data in a simple array of bytes.
42      *
43      * @param stream the OutputStream to which the data should be
44      * written.
45      * @param data the byte array of to be written.
46      *
47      * @exception IOException on problems writing to the specified
48      * stream.
49      */

50
51     protected void doWriteData(final OutputStream JavaDoc stream, final byte [] data)
52         throws IOException JavaDoc
53     {
54         stream.write(data);
55     }
56
57     /**
58      * Write the block's data to an OutputStream
59      *
60      * @param stream the OutputStream to which the stored data should
61      * be written
62      *
63      * @exception IOException on problems writing to the specified
64      * stream
65      */

66
67     abstract void writeData(final OutputStream JavaDoc stream)
68         throws IOException JavaDoc;
69
70     /* ********** START implementation of BlockWritable ********** */
71
72     /**
73      * Write the storage to an OutputStream
74      *
75      * @param stream the OutputStream to which the stored data should
76      * be written
77      *
78      * @exception IOException on problems writing to the specified
79      * stream
80      */

81
82     public void writeBlocks(final OutputStream JavaDoc stream)
83         throws IOException JavaDoc
84     {
85         writeData(stream);
86     }
87
88     /* ********** END implementation of BlockWritable ********** */
89 } // end abstract class BigBlock
90

91
Popular Tags