source: josm/trunk/src/com/drew/lang/BufferReader.java@ 7152

Last change on this file since 7152 was 6127, checked in by bastiK, 11 years ago

applied #8895 - Upgrade metadata-extractor to v. 2.6.4 (patch by ebourg)

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.9 KB
Line 
1/*
2 * Copyright 2002-2012 Drew Noakes
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * More information about this project is available at:
17 *
18 * http://drewnoakes.com/code/exif/
19 * http://code.google.com/p/metadata-extractor/
20 */
21
22package com.drew.lang;
23
24import com.drew.lang.annotations.NotNull;
25
26public interface BufferReader
27{
28 /**
29 * Returns the length of the buffer. This value represents the total number of bytes in the underlying source.
30 *
31 * @return The number of bytes in the buffer.
32 */
33 long getLength();
34
35 /**
36 * Sets the endianness of this reader.
37 * <ul>
38 * <li><code>true</code> for Motorola (or big) endianness</li>
39 * <li><code>false</code> for Intel (or little) endianness</li>
40 * </ul>
41 *
42 * @param motorolaByteOrder <code>true</code> for motorola/big endian, <code>false</code> for intel/little endian
43 */
44 void setMotorolaByteOrder(boolean motorolaByteOrder);
45
46 /**
47 * Gets the endianness of this reader.
48 * <ul>
49 * <li><code>true</code> for Motorola (or big) endianness</li>
50 * <li><code>false</code> for Intel (or little) endianness</li>
51 * </ul>
52 */
53 boolean isMotorolaByteOrder();
54
55 /**
56 * Returns an unsigned 8-bit int calculated from one byte of data at the specified index.
57 *
58 * @param index position within the data buffer to read byte
59 * @return the 8 bit int value, between 0 and 255
60 * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
61 */
62 short getUInt8(int index) throws BufferBoundsException;
63
64 /**
65 * Returns a signed 8-bit int calculated from one byte of data at the specified index.
66 *
67 * @param index position within the data buffer to read byte
68 * @return the 8 bit int value, between 0x00 and 0xFF
69 * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
70 */
71 byte getInt8(int index) throws BufferBoundsException;
72
73 /**
74 * Returns an unsigned 16-bit int calculated from two bytes of data at the specified index.
75 *
76 * @param index position within the data buffer to read first byte
77 * @return the 16 bit int value, between 0x0000 and 0xFFFF
78 * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
79 */
80 int getUInt16(int index) throws BufferBoundsException;
81
82 /**
83 * Returns a signed 16-bit int calculated from two bytes of data at the specified index (MSB, LSB).
84 *
85 * @param index position within the data buffer to read first byte
86 * @return the 16 bit int value, between 0x0000 and 0xFFFF
87 * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
88 */
89 short getInt16(int index) throws BufferBoundsException;
90
91 /**
92 * Get a 32-bit unsigned integer from the buffer, returning it as a long.
93 *
94 * @param index position within the data buffer to read first byte
95 * @return the unsigned 32-bit int value as a long, between 0x00000000 and 0xFFFFFFFF
96 * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
97 */
98 long getUInt32(int index) throws BufferBoundsException;
99
100 /**
101 * Returns a signed 32-bit integer from four bytes of data at the specified index the buffer.
102 *
103 * @param index position within the data buffer to read first byte
104 * @return the signed 32 bit int value, between 0x00000000 and 0xFFFFFFFF
105 * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
106 */
107 int getInt32(int index) throws BufferBoundsException;
108
109 /**
110 * Get a signed 64-bit integer from the buffer.
111 *
112 * @param index position within the data buffer to read first byte
113 * @return the 64 bit int value, between 0x0000000000000000 and 0xFFFFFFFFFFFFFFFF
114 * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
115 */
116 long getInt64(int index) throws BufferBoundsException;
117
118 float getS15Fixed16(int index) throws BufferBoundsException;
119
120 float getFloat32(int index) throws BufferBoundsException;
121
122 double getDouble64(int index) throws BufferBoundsException;
123
124 @NotNull
125 byte[] getBytes(int index, int count) throws BufferBoundsException;
126
127 @NotNull
128 String getString(int index, int bytesRequested) throws BufferBoundsException;
129
130 @NotNull
131 String getString(int index, int bytesRequested, String charset) throws BufferBoundsException;
132
133 /**
134 * Creates a String from the _data buffer starting at the specified index,
135 * and ending where <code>byte=='\0'</code> or where <code>length==maxLength</code>.
136 *
137 * @param index The index within the buffer at which to start reading the string.
138 * @param maxLengthBytes The maximum number of bytes to read. If a zero-byte is not reached within this limit,
139 * reading will stop and the string will be truncated to this length.
140 * @return The read string.
141 * @throws BufferBoundsException The buffer does not contain enough bytes to satisfy this request.
142 */
143 @NotNull
144 String getNullTerminatedString(int index, int maxLengthBytes) throws BufferBoundsException;
145}
Note: See TracBrowser for help on using the repository browser.