summaryrefslogtreecommitdiff
path: root/songdbj/de/jarnbjo/util/io/BitInputStream.java
diff options
context:
space:
mode:
Diffstat (limited to 'songdbj/de/jarnbjo/util/io/BitInputStream.java')
-rw-r--r--songdbj/de/jarnbjo/util/io/BitInputStream.java185
1 files changed, 185 insertions, 0 deletions
diff --git a/songdbj/de/jarnbjo/util/io/BitInputStream.java b/songdbj/de/jarnbjo/util/io/BitInputStream.java
new file mode 100644
index 0000000000..89cadb8380
--- /dev/null
+++ b/songdbj/de/jarnbjo/util/io/BitInputStream.java
@@ -0,0 +1,185 @@
1/*
2 * $ProjectName$
3 * $ProjectRevision$
4 * -----------------------------------------------------------
5 * $Id$
6 * -----------------------------------------------------------
7 *
8 * $Author$
9 *
10 * Description:
11 *
12 * Copyright 2002-2003 Tor-Einar Jarnbjo
13 * -----------------------------------------------------------
14 *
15 * Change History
16 * -----------------------------------------------------------
17 * $Log$
18 * Revision 1.1 2005/07/11 15:42:36 hcl
19 * Songdb java version, source. only 1.5 compatible
20 *
21 * Revision 1.1.1.1 2004/04/04 22:09:12 shred
22 * First Import
23 *
24 * Revision 1.5 2003/04/10 19:48:31 jarnbjo
25 * no message
26 *
27 * Revision 1.4 2003/03/16 20:57:06 jarnbjo
28 * no message
29 *
30 * Revision 1.3 2003/03/16 20:56:56 jarnbjo
31 * no message
32 *
33 * Revision 1.2 2003/03/16 01:11:39 jarnbjo
34 * no message
35 *
36 * Revision 1.1 2003/03/03 21:02:20 jarnbjo
37 * no message
38 *
39 */
40
41package de.jarnbjo.util.io;
42
43import java.io.IOException;
44
45/**
46 * An interface with methods allowing bit-wise reading from
47 * an input stream. All methods in this interface are optional
48 * and an implementation not support a method or a specific state
49 * (e.g. endian) will throw an UnspportedOperationException if
50 * such a method is being called. This should be speicified in
51 * the implementation documentation.
52 */
53
54public interface BitInputStream {
55
56 /**
57 * constant for setting this stream's mode to little endian
58 *
59 * @see #setEndian(int)
60 */
61
62 public static final int LITTLE_ENDIAN = 0;
63
64 /**
65 * constant for setting this stream's mode to big endian
66 *
67 * @see #setEndian(int)
68 */
69
70 public static final int BIG_ENDIAN = 1;
71
72 /**
73 * reads one bit (as a boolean) from the input stream
74 *
75 * @return <code>true</code> if the next bit is 1,
76 * <code>false</code> otherwise
77 *
78 * @throws IOException if an I/O error occurs
79 * @throws UnsupportedOperationException if the method is not supported by the implementation
80 */
81
82 public boolean getBit() throws IOException;
83
84 /**
85 * reads <code>bits</code> number of bits from the input
86 * stream
87 *
88 * @return the unsigned integer value read from the stream
89 *
90 * @throws IOException if an I/O error occurs
91 * @throws UnsupportedOperationException if the method is not supported by the implementation
92 */
93
94 public int getInt(int bits) throws IOException;
95
96 /**
97 * reads <code>bits</code> number of bits from the input
98 * stream
99 *
100 * @return the signed integer value read from the stream
101 *
102 * @throws IOException if an I/O error occurs
103 * @throws UnsupportedOperationException if the method is not supported by the implementation
104 */
105
106 public int getSignedInt(int bits) throws IOException;
107
108 /**
109 * reads a huffman codeword based on the <code>root</code>
110 * parameter and returns the decoded value
111 *
112 * @param root the root of the Huffman tree used to decode the codeword
113 * @return the decoded unsigned integer value read from the stream
114 *
115 * @throws IOException if an I/O error occurs
116 * @throws UnsupportedOperationException if the method is not supported by the implementation
117 */
118
119 public int getInt(HuffmanNode root) throws IOException;
120
121 /**
122 * reads an integer encoded as "signed rice" as described in
123 * the FLAC audio format specification
124 *
125 * @param order
126 * @return the decoded integer value read from the stream
127 *
128 * @throws IOException if an I/O error occurs
129 * @throws UnsupportedOperationException if the method is not supported by the implementation
130 */
131
132 public int readSignedRice(int order) throws IOException;
133
134 /**
135 * fills the array from <code>offset</code> with <code>len</code>
136 * integers encoded as "signed rice" as described in
137 * the FLAC audio format specification
138 *
139 * @param order
140 * @param buffer
141 * @param offset
142 * @param len
143 * @return the decoded integer value read from the stream
144 *
145 * @throws IOException if an I/O error occurs
146 * @throws UnsupportedOperationException if the method is not supported by the implementation
147 */
148
149 public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
150
151 /**
152 * reads <code>bits</code> number of bits from the input
153 * stream
154 *
155 * @return the unsigned long value read from the stream
156 *
157 * @throws IOException if an I/O error occurs
158 * @throws UnsupportedOperationException if the method is not supported by the implementation
159 */
160
161 public long getLong(int bits) throws IOException;
162
163 /**
164 * causes the read pointer to be moved to the beginning
165 * of the next byte, remaining bits in the current byte
166 * are discarded
167 *
168 * @throws UnsupportedOperationException if the method is not supported by the implementation
169 */
170
171 public void align();
172
173 /**
174 * changes the endian mode used when reading bit-wise from
175 * the stream, changing the mode mid-stream will cause the
176 * read cursor to move to the beginning of the next byte
177 * (as if calling the <code>allign</code> method
178 *
179 * @see #align()
180 *
181 * @throws UnsupportedOperationException if the method is not supported by the implementation
182 */
183
184 public void setEndian(int endian);
185} \ No newline at end of file