File tree 5 files changed +75
-3
lines changed
src/main/java/com/github/jinahya/bit/io
5 files changed +75
-3
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ if [ $# -lt 3 ]; then
3
+ echo " Usage: $0 <tag> <phases...>, e.g. $0 3-jdk-11-openj9 clean install"
4
+ echo " See https://hub.docker.com/_/maven for available tags"
5
+ exit 1
6
+ fi
7
+ groupId=$( mvn help:evaluate -Dexpression=project.groupId | grep -v ' \[' )
8
+ artifactId=$( mvn help:evaluate -Dexpression=project.artifactId | grep -v ' \[' )
9
+ version=$( mvn help:evaluate -Dexpression=project.version | grep -v ' \[' )
10
+ echo $groupId :$artifactId :$version
11
+ tag=" $1 "
12
+ shift
13
+ echo run -it --rm \
14
+ --name $artifactId \
15
+ -v " $HOME /.m2" :/root/.m2 \
16
+ -v " $( pwd) " :/usr/src/" $groupId " /" $artifactId " /" $version " \
17
+ -w /usr/src/" $groupId " /" $artifactId " /" $version " \
18
+ maven:" $tag " mvn " $@ "
19
+ docker run -it --rm \
20
+ --name $artifactId \
21
+ -v " $HOME /.m2" :/root/.m2 \
22
+ -v " $( pwd) " :/usr/src/" $groupId " /" $artifactId " /" $version " \
23
+ -w /usr/src/" $groupId " /" $artifactId " /" $version " \
24
+ maven:" $tag " mvn " $@ "
Original file line number Diff line number Diff line change @@ -249,18 +249,34 @@ public char readChar16() throws IOException {
249
249
}
250
250
251
251
// -----------------------------------------------------------------------------------------------------------------
252
+ @ Override
253
+ public void skip (final int bits ) throws IOException {
254
+ if (bits <= 0 ) {
255
+ throw new IllegalArgumentException ("bits(" + bits + ") <= 0" );
256
+ }
257
+ final int q = bits / Byte .SIZE ;
258
+ for (int i = 0 ; i < q ; i ++) {
259
+ readInt (true , Byte .SIZE );
260
+ }
261
+ final int r = bits % Byte .SIZE ;
262
+ for (int i = 0 ; i < r ; i ++) {
263
+ readBoolean ();
264
+ }
265
+ }
266
+
252
267
@ Override
253
268
public long align (final int bytes ) throws IOException {
254
269
if (bytes <= 0 ) {
255
270
throw new IllegalArgumentException ("bytes(" + bytes + ") <= 0" );
256
271
}
257
- long bits = 0 ; // number of bits discarded
272
+ // TODO: 2020/02/14 Use skip()!!!
273
+ long bits = 0 ; // number of bits to discard
258
274
if (available > 0 ) {
259
275
bits += available ;
260
276
readInt (true , available );
261
277
}
262
278
assert available == 0 ;
263
- for (; count % bytes > 0L ; bits += Byte .SIZE ) {
279
+ for (; ( count % bytes ) > 0L ; bits += Byte .SIZE ) {
264
280
readInt (true , Byte .SIZE );
265
281
}
266
282
assert count % bytes == 0L ;
Original file line number Diff line number Diff line change @@ -239,12 +239,28 @@ public void writeChar16(final char value) throws IOException {
239
239
}
240
240
241
241
// -----------------------------------------------------------------------------------------------------------------
242
+ @ Override
243
+ public void skip (final int bits ) throws IOException {
244
+ if (bits <= 0 ) {
245
+ throw new IllegalArgumentException ("bits(" + bits + ") <= 0" );
246
+ }
247
+ final int q = bits / Byte .SIZE ;
248
+ for (int i = 0 ; i < q ; i ++) {
249
+ writeInt (true , Byte .SIZE , 0 );
250
+ }
251
+ final int r = bits % Byte .SIZE ;
252
+ for (int i = 0 ; i < r ; i ++) {
253
+ writeBoolean (false );
254
+ }
255
+ }
256
+
242
257
@ Override
243
258
public long align (final int bytes ) throws IOException {
244
259
if (bytes <= 0 ) {
245
260
throw new IllegalArgumentException ("bytes(" + bytes + ") <= 0" );
246
261
}
247
- long bits = 0 ; // the number of bits padded
262
+ // TODO: 2020/02/14 Use skip()!!!
263
+ long bits = 0 ; // the number of bits to pad
248
264
if (available < Byte .SIZE ) {
249
265
bits += available ;
250
266
writeInt (true , available , 0x00 );
Original file line number Diff line number Diff line change @@ -184,6 +184,14 @@ public interface BitInput {
184
184
185
185
// -----------------------------------------------------------------------------------------------------------------
186
186
187
+ /**
188
+ * Skips specified number of bits by discarding bits.
189
+ *
190
+ * @param bits the number of bit to skip; must be positive.
191
+ * @throws IOException if an I/O error occurs.
192
+ */
193
+ void skip (int bits ) throws IOException ;
194
+
187
195
/**
188
196
* Aligns to specified number of bytes by discarding bits.
189
197
*
Original file line number Diff line number Diff line change @@ -186,6 +186,14 @@ public interface BitOutput {
186
186
187
187
// -----------------------------------------------------------------------------------------------------------------
188
188
189
+ /**
190
+ * Skips specified number of bits by padding zero bits.
191
+ *
192
+ * @param bits the number of bit to skip; must be positive.
193
+ * @throws IOException if an I/O error occurs.
194
+ */
195
+ void skip (int bits ) throws IOException ;
196
+
189
197
/**
190
198
* Aligns to specified number of bytes by padding zero bits.
191
199
*
You can’t perform that action at this time.
0 commit comments