01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: 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: package org.apache.poi.poifs.storage;
19:
20: /**
21: * Abstract base class of all POIFS block storage classes. All
22: * extensions of BigBlock should write 512 bytes of data when
23: * requested to write their data.
24: *
25: * This class has package scope, as there is no reason at this time to
26: * make the class public.
27: *
28: * @author Marc Johnson (mjohnson at apache dot org)
29: */
30:
31: import java.io.IOException;
32: import java.io.OutputStream;
33:
34: abstract class BigBlock implements BlockWritable {
35:
36: /**
37: * Default implementation of write for extending classes that
38: * contain their data in a simple array of bytes.
39: *
40: * @param stream the OutputStream to which the data should be
41: * written.
42: * @param data the byte array of to be written.
43: *
44: * @exception IOException on problems writing to the specified
45: * stream.
46: */
47:
48: protected void doWriteData(final OutputStream stream,
49: final byte[] data) throws IOException {
50: stream.write(data);
51: }
52:
53: /**
54: * Write the block's data to an OutputStream
55: *
56: * @param stream the OutputStream to which the stored data should
57: * be written
58: *
59: * @exception IOException on problems writing to the specified
60: * stream
61: */
62:
63: abstract void writeData(final OutputStream stream)
64: throws IOException;
65:
66: /* ********** START implementation of BlockWritable ********** */
67:
68: /**
69: * Write the storage to an OutputStream
70: *
71: * @param stream the OutputStream to which the stored data should
72: * be written
73: *
74: * @exception IOException on problems writing to the specified
75: * stream
76: */
77:
78: public void writeBlocks(final OutputStream stream)
79: throws IOException {
80: writeData(stream);
81: }
82:
83: /* ********** END implementation of BlockWritable ********** */
84: } // end abstract class BigBlock
|