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.util;
19:
20: import org.apache.poi.util.LittleEndian.BufferUnderrunException;
21:
22: import java.io.*;
23:
24: /**
25: * behavior of a field at a fixed location within a byte array
26: *
27: * @author Marc Johnson (mjohnson at apache dot org
28: */
29:
30: public interface FixedField {
31:
32: /**
33: * set the value from its offset into an array of bytes
34: *
35: * @param data the byte array from which the value is to be read
36: *
37: * @exception ArrayIndexOutOfBoundsException if the offset is out
38: * of the array's valid index range
39: */
40:
41: public void readFromBytes(byte[] data)
42: throws ArrayIndexOutOfBoundsException;
43:
44: /**
45: * set the value from an InputStream
46: *
47: * @param stream the InputStream from which the value is to be
48: * read
49: *
50: * @exception BufferUnderrunException if there is not enough data
51: * available from the InputStream
52: * @exception IOException if an IOException is thrown from reading
53: * the InputStream
54: */
55:
56: public void readFromStream(InputStream stream) throws IOException,
57: BufferUnderrunException;
58:
59: /**
60: * write the value out to an array of bytes at the appropriate
61: * offset
62: *
63: * @param data the array of bytes to which the value is to be
64: * written
65: *
66: * @exception ArrayIndexOutOfBoundsException if the offset is out
67: * of the array's valid index range
68: */
69:
70: public void writeToBytes(byte[] data)
71: throws ArrayIndexOutOfBoundsException;
72:
73: /**
74: * return the value as a String
75: *
76: * @return the value as a String
77: */
78:
79: public String toString();
80: } // end public interface FixedField
|