This mapping has 5 multi-map groups: several pairings are equally correct there. The code view shows one arbitrary valid pairing, not the only one.

Before

1/*
2 * $Id: RandomAccessFileOrArray.java,v 1.48 2005/09/11 08:38:18 blowagie Exp $
3 * $Name: $
4 *
5 * Copyright 2001, 2002 Paulo Soares
6 *
7 *
8 * The Original Code is 'iText, a free JAVA-PDF library'.
9 *
10 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
11 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
12 * All Rights Reserved.
13 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
14 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
15 * Co-Developer of the code is Sid Steward. Portions created by the Co-Developer
16 * are Copyright (C) 2013 by Sid Steward. All Rights Reserved.
17 *
18 * Contributor(s): all the names of the contributors are added in the source code
19 * where applicable.
20 *
21 *
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Library General Public
24 * License as published by the Free Software Foundation; either
25 * version 2 of the License, or (at your option) any later version.
26 *
27 * This library is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 * Library General Public License for more details.
31 *
32 * You should have received a copy of the GNU Library General Public
33 * License along with this library; if not, write to the
34 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
35 * Boston, MA 02110-1301, USA.
36 *
37 *
38 * This library is free software; you can redistribute it and/or
39 * modify it under the terms of the GNU Library General Public
40 * License as published by the Free Software Foundation; either
41 * version 2 of the License, or (at your option) any later version.
42 *
43 * This library is distributed in the hope that it will be useful,
44 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
46 * Library General Public License for more details.
47 *
48 * You should have received a copy of the GNU Library General Public
49 * License along with this library; if not, write to the
50 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
51 * Boston, MA 02110-1301, USA.
52 *
53 *
54 * If you didn't download this code from the following link, you should check if
55 * you aren't using an obsolete version:
56 * http://www.lowagie.com/iText/
57 */
58
59package com.gitlab.pdftk_java.com.lowagie.text.pdf;
60
61import java.io.DataInputStream;
62import java.io.DataInput;
63import java.io.FileInputStream;
64import java.io.IOException;
65import java.io.EOFException;
66import java.io.RandomAccessFile;
67import java.io.File;
68import java.io.InputStream;
69import java.io.ByteArrayOutputStream;
70import java.net.URL;
71/** An implementation of a RandomAccessFile for input only
72 * that accepts a file or a byte array as data source.
73 *
74 * @author Paulo Soares (psoares@consiste.pt)
75 */
76public class RandomAccessFileOrArray implements DataInput {
77
78 ////
79 // uses either rf or arrayIn, but not both
80
81 String filename = null; // set only if we expect to use rf (not arrayIn)
82 RandomAccessFile rf = null; // may be null even if filename is set
83
84 byte arrayIn[] = null; // set only if we aren't using filename/rf
85 int arrayInPtr = 0;
86
87 private byte back = 0;
88 private boolean isBack = false;
89
90 private int startOffset = 0;
91
92 ////
93 //
94
95 //
96 public RandomAccessFileOrArray(String filename) throws IOException {
97 this(filename, false);
98 }
99
100 //
101 public RandomAccessFileOrArray(String filename, boolean forceRead) throws IOException {
102 if (filename == null)
103 throw new IllegalArgumentException
104 ("null filename passed into RandomAccessFileOrArray()");
105
106 File file = new File(filename);
107
108 if (!file.canRead()) {
109 if (filename.startsWith("file:/") || filename.startsWith("http://") ||
110 filename.startsWith("https://") || filename.startsWith("jar:"))
111 {
112 // copied from RandomAccessFileOrArray(URL):
113 InputStream is = new URL(filename).openStream();
114 try {
115 this.inputStreamToArray(is);
116 }
117 finally {
118 try { is.close(); } catch (IOException ioe) {}
119 }
120 }
121 else {
122 InputStream is = BaseFont.getResourceStream(filename);
123 if (is == null)
124 throw new IOException(filename + " not found as file or resource.");
125 try {
126 this.inputStreamToArray(is);
127 }
128 finally {
129 try { is.close(); } catch (IOException ioe) {}
130 }
131 }
132 }
133 else if (forceRead) {
134 InputStream is = null;
135 try {
136 is = new FileInputStream(file);
137 this.inputStreamToArray(is);
138 }
139 finally {
140 try { if (is != null) { is.close(); } } catch (Exception e) {}
141 }
142 }
143 else {
144 rf = new RandomAccessFile(file, "r");
145 if (rf == null)
146 throw new IOException("Unable to open: " + filename);
147
148 this.filename = filename; // set only if we're using rf
149 }
150 }
151
152 public RandomAccessFileOrArray(URL url) throws IOException {
153 if (url == null)
154 throw new IllegalArgumentException
155 ("null url passed into RandomAccessFileOrArray()");
156
157 InputStream is = url.openStream();
158 try {
159 this.inputStreamToArray(is);
160 }
161 finally {
162 try { is.close(); } catch (IOException ioe) {}
163 }
164 }
165
166 public RandomAccessFileOrArray(InputStream is) throws IOException {
167 this.inputStreamToArray(is);
168 }
169
170 public RandomAccessFileOrArray(byte arrayIn[]) {
171 this.arrayIn = arrayIn;
172 }
173
174 // copy constructor
175 public RandomAccessFileOrArray(RandomAccessFileOrArray file) throws IOException {
176 if (file == null)
177 throw new IllegalArgumentException
178 ("null file passed into RandomAccessFileOrArray() copy constructor");
179
180 if( file.filename != null ) {
181 this.filename = file.filename;
182 this.rf = null;
183 }
184 else if( file.arrayIn != null ) {
185 this.arrayIn = file.arrayIn;
186 this.arrayInPtr = 0;
187 }
188
189 this.startOffset = file.startOffset;
190 }
191
192 ////
193 //
194
195 //
196 private void inputStreamToArray(InputStream is) throws IOException {
197 byte bb[] = new byte[8192];
198 ByteArrayOutputStream out = new ByteArrayOutputStream();
199 int len = 0;
200 while ( 1< (len = is.read(bb)) ) {
201 out.write(bb, 0, len);
202 }
203 this.arrayIn = out.toByteArray(); // allocates a new byte array
204 this.arrayInPtr = 0;
205 }
206
207 // added pushBack isBack test since we hold only one byte
208 public void pushBack(byte b) throws IOException {
209 if (isBack)
210 throw new IOException("Tried to pushBack a byte when isBack is true.");
…lines 211–230 unchanged (20 lines)
231 back = 0;
232 isBack = false;
233 }
234
235 // reads one byte
236 public int read() throws IOException {
237 int retVal = -1;
238 if (isBack) {
239 retVal = getBack();
240 clearBack();
241 }
242 else if (rf != null) {
243 retVal = rf.read();
244 }
245 else if (arrayIn != null &&
246 0<= arrayInPtr && arrayInPtr< arrayIn.length) {
247 retVal = arrayIn[arrayInPtr++] & 0xff;
248 }
249 return retVal;
250 }
251
252 // bb: buffer to read into
253 // off: index of b where to begin
254 // len: max number of bytes to copy
255 // return: number of bytes read, or -1 on end
256 public int read( byte[] bb, int off, int len ) throws IOException {
257 if( bb== null )
258 throw new IllegalArgumentException("read() argument bb is null.");
259
260 if( len== 0 || bb.length== 0 )
261 return 0; // nothing read; test before (bb.length<= off)
262
263 if( len< 0 || off< 0 || bb.length<= off || bb.length< off+ len )
264 throw new IllegalArgumentException
265 ("read() arguments are out of bounds: len: "+ len+
266 " off: "+ off+ " bb.length: "+ bb.length);
267
268 int retVal= -1; // default: end of data
269
270 // test for pushed-back byte
271 if( isBack ) { // prepend byte; reset later
272 bb[ off++ ]= back;
273 --len;
274 }
275
276 if( rf!= null ) { // use rf
277 retVal= rf.read( bb, off, len ); // could return -1
278 }
279
280 else if( arrayIn!= null ) { // use array
281 if( 0<= arrayInPtr && arrayInPtr< arrayIn.length ) {
282
283 if( arrayIn.length< arrayInPtr+ len )
284 len= arrayIn.length- arrayInPtr; // take only what's left
285
286 if( 0< len ) {
287 System.arraycopy( arrayIn, arrayInPtr, bb, off, len );
288 arrayInPtr+= len;
289 retVal= len;
290 }
291 // else end of array data
292 }
293 // else end of array data
…lines 294–299 unchanged (6 lines)
300 retVal+= 1;
301 clearBack();
302
303 return retVal;
304 }
305
306 //
307 public int read(byte b[]) throws IOException {
308 return read(b, 0, b.length);
309 }
310
311 //
312 public void readFully( byte bb[], int off, int len ) throws IOException {
313 int bytesRead= 0;
314 int nn= 0;
315 while( bytesRead< len ) { // len may be 0
316 nn= this.read( bb, off+ bytesRead, len- bytesRead );
317 if( nn< 0 )
318 throw new EOFException();
319 bytesRead+= nn;
320 }
321 }
322 public void readFully( byte bb[] ) throws IOException {
323 readFully( bb, 0, bb.length );
324 }
325
326 // calls clearBack()
327 public void reOpen() throws IOException {
328 if (filename != null && rf == null) {
329 rf = new RandomAccessFile(filename, "r");
330 if (rf == null) {
331 throw new IOException("Unable to reOpen: " + filename);
332 }
333 }
334 this.seek(0); // calls clearBack()
335 }
336
337 // might call clearBack()
338 protected void insureOpen() throws IOException {
339 if (filename != null && rf == null) {
340 reOpen();
341 }
342 }
343
344 //
345 public boolean isOpen() {
346 return (filename == null || rf != null);
347 }
348
349 //
350 public void close() throws IOException {
351 if (rf != null) {
352 rf.close();
353 rf = null;
354 }
355 // preserves this.filename and this.arrayIn
356
357 clearBack();
358 }
359
360 //
361 public int length() throws IOException {
362 if (filename != null) {
363 insureOpen();
364 return (int)rf.length() - startOffset;
365 }
366 else if (arrayIn != null) {
367 return arrayIn.length - startOffset;
368 }
369 return 0;
370 }
371
372 //
373 public int getFilePointer() throws IOException {
374 insureOpen(); // might call clearBack(), so call first
375 int nn = isBack ? 1 : 0;
376 if (filename != null) {
377 return (int)rf.getFilePointer() - nn - startOffset;
378 }
379 else if (arrayIn != null) {
380 return arrayInPtr - nn - startOffset;
381 }
382 return 0; // no data -- shouldn't happen
383 }
384
385 //
386 public void seek(int pos) throws IOException {
387 pos += startOffset;
388
389 clearBack();
390
391 if (filename != null) {
392 // not calling insureOpen() b/c it calls reOpen() which calls this.seek(0)
393 if (rf == null) {
394 rf = new RandomAccessFile(filename, "r");
395 if (rf == null) {
396 throw new IOException("Unable to open: " + filename + " in seek()");
397 }
398 }
399 rf.seek(pos);
400 }
401 else if (arrayIn != null) {
402 arrayInPtr = pos;
403 }
404 }
405
406 //
407 public void seek(long pos) throws IOException {
408 seek((int)pos);
409 }
410
411 //
412 public int skipBytes(int nn) throws IOException {
413 if (nn <= 0) {
414 return 0;
415 }
416 if (nn == 1 && isBack) {
417 clearBack();
418 return 1;
419 }
420 // no need for additional isBack logic b/c helper functions already consider it
421
422 int pos = this.getFilePointer(); // considers isBack and startOffset
423 int len = this.length(); // considers startOffset
424 int newpos = pos + nn;
425 if (newpos > len) {
426 newpos = len; // seek(len) ensures that next read() returns -1
427 }
428 this.seek(newpos); // considers startOffset
429
430 return newpos - pos;
431 }
432
433 //
434 public long skip(long n) throws IOException {
435 return skipBytes((int)n);
436 }
437
438 //
439 public int getStartOffset() {
440 return this.startOffset;
441 }
442 public void setStartOffset(int startOffset) throws IOException {
443 this.startOffset = startOffset;
444 this.seek(0);
445 }
446
447 ////
448 //
449
450 public boolean readBoolean() throws IOException {
451 int ch = this.read();
452 if (ch < 0)
453 throw new EOFException();
454 return (ch != 0);
…lines 455–714 unchanged (260 lines)
715 return input.toString();
716 }
717
718 public String readUTF() throws IOException {
719 return DataInputStream.readUTF(this);
720 }
721
722}
723

After

1/*
2 * $Id: RandomAccessFileOrArray.java 4065 2009-09-16 23:09:11Z psoares33 $
3 *
4 * Copyright 2001, 2002 Paulo Soares
5 *
6 *
7 * The Original Code is 'iText, a free JAVA-PDF library'.
8 *
9 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
10 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
11 * All Rights Reserved.
12 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
13 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
14 * Co-Developer of the code is Sid Steward. Portions created by the Co-Developer
15 * are Copyright (C) 2013 by Sid Steward. All Rights Reserved.
16 *
17 * Contributor(s): all the names of the contributors are added in the source code
18 * where applicable.
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Library General Public
22 * License as published by the Free Software Foundation; either
23 * version 2 of the License, or (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Library General Public License for more details.
29 *
30 * You should have received a copy of the GNU Library General Public
31 * License along with this library; if not, write to the
32 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
33 * Boston, MA 02110-1301, USA.
34 *
35 * If you didn't download this code from the following link, you should check if
36 * you aren't using an obsolete version:
37 * http://www.lowagie.com/iText/
38 */
39
40// pdftk-java iText base version 4.2.0
41// pdftk-java modified yes (no idea why)
42
43package com.gitlab.pdftk_java.com.lowagie.text.pdf;
44
45import com.gitlab.pdftk_java.com.lowagie.text.Document;
46import java.io.ByteArrayOutputStream;
47import java.io.DataInput;
48import java.io.DataInputStream;
49import java.io.EOFException;
50import java.io.File;
51import java.io.FileInputStream;
52import java.io.IOException;
53import java.io.InputStream;
54import java.io.RandomAccessFile;
55import java.net.URL;
56import java.nio.channels.FileChannel;
57/** An implementation of a RandomAccessFile for input only
58 * that accepts a file or a byte array as data source.
59 *
60 * @author Paulo Soares (psoares@consiste.pt)
61 */
62public class RandomAccessFileOrArray implements DataInput {
63
64 ////
65 // uses either rf or arrayIn, but not both
66
67 MappedRandomAccessFile rf = null;
68 RandomAccessFile trf = null; // may be null even if filename is set
69 boolean plainRandomAccess;
70 String filename = null; // set only if we expect to use rf (not arrayIn)
71 byte arrayIn[] = null; // set only if we aren't using filename/rf
72 int arrayInPtr = 0;
73 private byte back = 0;
74 private boolean isBack = false;
75
76 /** Holds value of property startOffset. */
77 private int startOffset = 0;
78
79 public RandomAccessFileOrArray(String filename) throws IOException {
80 this(filename, false, Document.plainRandomAccess);
81 }
82
83 public RandomAccessFileOrArray(String filename, boolean forceRead, boolean plainRandomAccess) throws IOException {
84 this.plainRandomAccess = plainRandomAccess;
85 if (filename == null)
86 throw new IllegalArgumentException
87 ("null filename passed into RandomAccessFileOrArray()");
88
89 File file = new File(filename);
90 if (!file.canRead()) {
91 if (filename.startsWith("file:/") || filename.startsWith("http://")
92 || filename.startsWith("https://") || filename.startsWith("jar:") || filename.startsWith("wsjar:")) {
93 // copied from RandomAccessFileOrArray(URL):
94 InputStream is = new URL(filename).openStream();
95 try {
96 this.arrayIn = InputStreamToArray(is);
97 return;
98 }
99 finally {
100 try { is.close(); } catch (IOException ioe) {}
101 }
102 }
103 else {
104 InputStream is = BaseFont.getResourceStream(filename);
105 if (is == null)
106 throw new IOException(filename + " not found as file or resource.");
107 try {
108 this.arrayIn = InputStreamToArray(is);
109 return;
110 }
111 finally {
112 try { is.close(); } catch (IOException ioe) {}
113 }
114 }
115 }
116 else if (forceRead) {
117 InputStream s = null;
118 try {
119 s = new FileInputStream(file);
120 this.arrayIn = InputStreamToArray(s);
121 }
122 finally {
123 try {if (s != null) {s.close();}}catch(Exception e){}
124 }
125 return;
126 }
127 this.filename = filename; // set only if we're using rf
128 if (plainRandomAccess)
129 trf = new RandomAccessFile(filename, "r");
130 else
131 rf = new MappedRandomAccessFile(filename, "r");
132 }
133
134 public RandomAccessFileOrArray(URL url) throws IOException {
135 if (url == null)
136 throw new IllegalArgumentException
137 ("null url passed into RandomAccessFileOrArray()");
138
139 InputStream is = url.openStream();
140 try {
141 this.arrayIn = InputStreamToArray(is);
142 }
143 finally {
144 try { is.close(); } catch (IOException ioe) {}
145 }
146 }
147
148 public RandomAccessFileOrArray(InputStream is) throws IOException {
149 this.arrayIn = InputStreamToArray(is);
150 }
151
152 public static byte[] InputStreamToArray(InputStream is) throws IOException {
153 byte b[] = new byte[8192];
154 ByteArrayOutputStream out = new ByteArrayOutputStream();
155 while (true) {
156 int read = is.read(b);
157 if (read < 1)
158 break;
159 out.write(b, 0, read);
160 }
161 out.close();
162 return out.toByteArray();
163 }
164
165 public RandomAccessFileOrArray(byte arrayIn[]) {
166 this.arrayIn = arrayIn;
167 }
168
169 public RandomAccessFileOrArray(RandomAccessFileOrArray file) {
170 filename = file.filename;
171 arrayIn = file.arrayIn;
172 startOffset = file.startOffset;
173 plainRandomAccess = file.plainRandomAccess;
174 }
175
176 // added pushBack isBack test since we hold only one byte
177 public void pushBack(byte b) throws IOException {
178 if (isBack)
179 throw new IOException("Tried to pushBack a byte when isBack is true.");
180 back = b;
181 isBack = true;
…lines 182–199 unchanged (18 lines)
200 back = 0;
201 isBack = false;
202 }
203
204 // reads one byte
205 public int read() throws IOException {
206 if (isBack) {
207 int retVal = getBack();
208 clearBack();
209 return retVal;
210 }
211 if (arrayIn == null)
212 return plainRandomAccess ? trf.read() : rf.read();
213 else {
214 if (arrayInPtr >= arrayIn.length)
215 return -1;
216 return arrayIn[arrayInPtr++] & 0xff;
217 }
218 }
219
220 // bb: buffer to read into
221 // off: index of b where to begin
222 // len: max number of bytes to copy
223 // return: number of bytes read, or -1 on end
224 public int read(byte[] b, int off, int len) throws IOException {
225 if( b== null )
226 throw new IllegalArgumentException("read() argument b is null.");
227
228 if( len== 0 || b.length== 0 )
229 return 0; // nothing read; test before (b.length<= off)
230
231 if( len< 0 || off< 0 || b.length<= off || b.length< off+ len )
232 throw new IllegalArgumentException
233 ("read() arguments are out of bounds: len: "+ len+
234 " off: "+ off+ " b.length: "+ b.length);
235
236 int retVal= -1; // default: end of data
237
238 // test for pushed-back byte
239 if(isBack) { // prepend byte; reset later
240 b[off++]= back;
241 --len;
242 }
243 if (arrayIn == null) {
244 retVal = (plainRandomAccess ? trf.read(b, off, len) : rf.read(b, off, len)); // could return -1
245 }
246 else {
247 if( 0<= arrayInPtr && arrayInPtr< arrayIn.length ) {
248
249 if( arrayIn.length< arrayInPtr+ len )
250 len= arrayIn.length- arrayInPtr; // take only what's left
251
252 if( 0< len ) {
253 System.arraycopy( arrayIn, arrayInPtr, b, off, len );
254 arrayInPtr+= len;
255 retVal= len;
256 }
257 // else end of array data
258 }
259 // else end of array data
…lines 260–264 unchanged (5 lines)
265 else
266 retVal+= 1;
267 clearBack();
268
269 return retVal;
270 }
271
272 public int read(byte b[]) throws IOException {
273 return read(b, 0, b.length);
274 }
275
276 public void readFully(byte b[]) throws IOException {
277 readFully(b, 0, b.length);
278 }
279
280 public void readFully(byte b[], int off, int len) throws IOException {
281 int n = 0;
282 do {
283 int count = read(b, off + n, len - n);
284 if (count < 0)
285 throw new EOFException();
286 n += count;
287 } while (n < len);
288 }
289
290 public long skip(long n) throws IOException {
291 return skipBytes((int)n);
292 }
293
294 public int skipBytes(int n) throws IOException {
295 if (n <= 0) {
296 return 0;
297 }
298 if (n == 1 && isBack) {
299 clearBack();
300 return 1;
301 }
302 // no need for additional isBack logic b/c helper functions already consider it
303
304 int pos = this.getFilePointer(); // considers isBack and startOffset
305 int len = this.length(); // considers startOffset
306 int newpos = pos + n;
307 if (newpos > len) {
308 newpos = len; // seek(len) ensures that next read() returns -1
309 }
310 seek(newpos); // considers startOffset
311
312 return newpos - pos;
313 }
314
315 // calls clearBack()
316 public void reOpen() throws IOException {
317 if (filename != null && rf == null && trf == null) {
318 if (plainRandomAccess)
319 trf = new RandomAccessFile(filename, "r");
320 else
321 rf = new MappedRandomAccessFile(filename, "r");
322 if (rf == null && trf == null) {
323 throw new IOException("Unable to reOpen: " + filename);
324 }
325 }
326 seek(0);
327 }
328
329 // might call clearBack()
330 protected void insureOpen() throws IOException {
331 if (filename != null && rf == null && trf == null) {
332 reOpen();
333 }
334 }
335
336 public boolean isOpen() {
337 return (filename == null || rf != null || trf != null);
338 }
339
340 public void close() throws IOException {
341 // preserves this.filename and this.arrayIn
342 clearBack();
343 if (rf != null) {
344 rf.close();
345 rf = null;
346 // it's very expensive to open a memory mapped file and for the usage pattern of this class
347 // in iText it's faster the next re-openings to be done as a plain random access
348 // file
349 plainRandomAccess = true;
350 }
351 else if (trf != null) {
352 trf.close();
353 trf = null;
354 }
355 }
356
357 public int length() throws IOException {
358 if (arrayIn == null) {
359 insureOpen();
360 return (int)(plainRandomAccess ? trf.length() : rf.length()) - startOffset;
361 }
362 else
363 return arrayIn.length - startOffset;
364 }
365
366 public void seek(int pos) throws IOException {
367 pos += startOffset;
368 clearBack();
369 if (arrayIn == null) {
370 insureOpen();
371 if (plainRandomAccess)
372 trf.seek(pos);
373 else
374 rf.seek(pos);
375 }
376 else
377 arrayInPtr = pos;
378 }
379
380 public void seek(long pos) throws IOException {
381 seek((int)pos);
382 }
383
384 public int getFilePointer() throws IOException {
385 insureOpen(); // might call clearBack(), so call first
386 int n = isBack ? 1 : 0;
387 if (arrayIn == null) {
388 return (int)(plainRandomAccess ? trf.getFilePointer() : rf.getFilePointer()) - n - startOffset;
389 }
390 else
391 return arrayInPtr - n - startOffset;
392 }
393
394 public boolean readBoolean() throws IOException {
395 int ch = this.read();
396 if (ch < 0)
397 throw new EOFException();
398 return (ch != 0);
…lines 399–659 unchanged (261 lines)
660 }
661
662 public String readUTF() throws IOException {
663 return DataInputStream.readUTF(this);
664 }
665
666 /** Getter for property startOffset.
667 * @return Value of property startOffset.
668 *
669 */
670 public int getStartOffset() {
671 return this.startOffset;
672 }
673
674 /** Setter for property startOffset.
675 * @param startOffset New value of property startOffset.
676 *
677 */
678 public void setStartOffset(int startOffset) throws IOException {
679 this.startOffset = startOffset;
680 this.seek(0);
681 }
682
683 /**
684 * @since 2.0.8
685 */
686 public java.nio.ByteBuffer getNioByteBuffer() throws IOException {
687 if (filename != null) {
688 FileChannel channel;
689 if (plainRandomAccess)
690 channel = trf.getChannel();
691 else
692 channel = rf.getChannel();
693 return channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
694 }
695 return java.nio.ByteBuffer.wrap(arrayIn);
696 }
697}
698

Before

program
block_comment "/*\n * $Id: RandomAccessFileOrArray.java,v 1.48 2005/09/11 08"...
package_declaration (+22 nodes collapsed)
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "DataInputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "DataInput"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "FileInputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "IOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "EOFException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "RandomAccessFile"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "File"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "InputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "ByteArrayOutputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "net"
. "."
identifier "URL"
; ";"
block_comment "/** An implementation of a RandomAccessFile for input only\n "...
class_declaration
modifiers
public "public"
class "class"
identifier "RandomAccessFileOrArray"
super_interfaces
implements "implements"
type_list
type_identifier "DataInput"
class_body
{ "{"
line_comment "////"
line_comment "// uses either rf or arrayIn, but not both"
field_declaration
type_identifier "String"
variable_declarator
identifier "filename"
= "="
null_literal "null"
; ";"
line_comment "// set only if we expect to use rf (not arrayIn)"
field_declaration
type_identifier "RandomAccessFile"
variable_declarator
identifier "rf"
= "="
null_literal "null"
; ";"
line_comment "// may be null even if filename is set"
field_declaration
integral_type
byte "byte"
variable_declarator
identifier "arrayIn"
dimensions
[ "["
] "]"
= "="
null_literal "null"
; ";"
line_comment "// set only if we aren't using filename/rf"
field_declaration
integral_type
int "int"
variable_declarator
identifier "arrayInPtr"
= "="
decimal_integer_literal "0"
; ";"
field_declaration
modifiers
private "private"
integral_type
byte "byte"
variable_declarator
identifier "back"
= "="
decimal_integer_literal "0"
; ";"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "isBack"
= "="
false "false"
; ";"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "startOffset"
= "="
decimal_integer_literal "0"
; ";"
line_comment "////"
line_comment "//"
line_comment "//"
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "filename"
) ")"
throws
throws "throws"
type_identifier "IOException"
constructor_body
{ "{"
explicit_constructor_invocation
this "this"
argument_list
( "("
identifier "filename"
, ","
false "false"
) ")"
; ";"
} "}"
line_comment "//"
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "filename"
, ","
formal_parameter
boolean_type "boolean"
identifier "forceRead"
) ")"
throws
throws "throws"
type_identifier "IOException"
constructor_body
{ "{"
if_statement (+22 nodes collapsed)
local_variable_declaration
type_identifier "File"
variable_declarator
identifier "file"
= "="
object_creation_expression
new "new"
type_identifier "File"
argument_list
( "("
identifier "filename"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
identifier "file"
. "."
identifier "canRead"
argument_list
( "("
) ")"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 3:4
binary_expression any 3:4
binary_expression any 3:4
method_invocation
identifier "filename"
. "."
identifier "startsWith"
argument_list
( "("
string_literal
" "\""
string_fragment "file:/"
" "\""
) ")"
|| "||"
method_invocation
identifier "filename"
. "."
identifier "startsWith"
argument_list
( "("
string_literal
" "\""
string_fragment "http://"
" "\""
) ")"
|| "||"
method_invocation
identifier "filename"
. "."
identifier "startsWith"
argument_list
( "("
string_literal
" "\""
string_fragment "https://"
" "\""
) ")"
|| "||"
method_invocation
identifier "filename"
. "."
identifier "startsWith"
argument_list
( "("
string_literal
" "\""
string_fragment "jar:"
" "\""
) ")"
) ")"
block
{ "{"
line_comment "// copied from RandomAccessFileOrArray(URL):"
local_variable_declaration
type_identifier "InputStream"
variable_declarator
identifier "is"
= "="
method_invocation
object_creation_expression
new "new"
type_identifier "URL"
argument_list
( "("
identifier "filename"
) ")"
. "."
identifier "openStream"
argument_list
( "("
) ")"
; ";"
try_statement
try "try"
block
{ "{"
expression_statement
method_invocation
this "this"
. "."
identifier "inputStreamToArray"
argument_list
( "("
identifier "is"
) ")"
; ";"
} "}"
finally_clause (+30 nodes collapsed)
} "}"
else "else"
block
{ "{"
local_variable_declaration
type_identifier "InputStream"
variable_declarator
identifier "is"
= "="
method_invocation
identifier "BaseFont"
. "."
identifier "getResourceStream"
argument_list
( "("
identifier "filename"
) ")"
; ";"
if_statement (+25 nodes collapsed)
try_statement
try "try"
block
{ "{"
expression_statement
method_invocation
this "this"
. "."
identifier "inputStreamToArray"
argument_list
( "("
identifier "is"
) ")"
; ";"
} "}"
finally_clause (+30 nodes collapsed)
} "}"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
identifier "forceRead"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "InputStream"
variable_declarator
identifier "is"
= "="
null_literal "null"
; ";"
try_statement
try "try"
block
{ "{"
expression_statement
assignment_expression
identifier "is"
= "="
object_creation_expression
new "new"
type_identifier "FileInputStream"
argument_list
( "("
identifier "file"
) ")"
; ";"
expression_statement
method_invocation
this "this"
. "."
identifier "inputStreamToArray"
argument_list
( "("
identifier "is"
) ")"
; ";"
} "}"
finally_clause
finally "finally"
block
{ "{"
try_statement
try "try"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "is"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "is"
. "."
identifier "close"
argument_list
( "("
) ")"
; ";"
} "}"
} "}"
catch_clause
catch "catch"
( "("
catch_formal_parameter
catch_type
type_identifier "Exception"
identifier "e"
) ")"
block
{ "{"
} "}"
} "}"
} "}"
else "else"
block
{ "{"
expression_statement
assignment_expression
identifier "rf"
= "="
object_creation_expression
new "new"
type_identifier "RandomAccessFile"
argument_list
( "("
identifier "file"
, ","
string_literal
" "\""
string_fragment "r"
" "\""
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rf"
== "=="
null_literal "null"
) ")"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IOException"
argument_list
( "("
binary_expression
string_literal
" "\""
string_fragment "Unable to open: "
" "\""
+ "+"
identifier "filename"
) ")"
; ";"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "filename"
= "="
identifier "filename"
; ";"
line_comment "// set only if we're using rf"
} "}"
} "}"
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "URL"
identifier "url"
) ")"
throws
throws "throws"
type_identifier "IOException"
constructor_body
{ "{"
if_statement (+22 nodes collapsed)
local_variable_declaration
type_identifier "InputStream"
variable_declarator
identifier "is"
= "="
method_invocation
identifier "url"
. "."
identifier "openStream"
argument_list
( "("
) ")"
; ";"
try_statement
try "try"
block
{ "{"
expression_statement
method_invocation
this "this"
. "."
identifier "inputStreamToArray"
argument_list
( "("
identifier "is"
) ")"
; ";"
} "}"
finally_clause (+30 nodes collapsed)
} "}"
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "InputStream"
identifier "is"
) ")"
throws
throws "throws"
type_identifier "IOException"
constructor_body
{ "{"
expression_statement
method_invocation
this "this"
. "."
identifier "inputStreamToArray"
argument_list
( "("
identifier "is"
) ")"
; ";"
} "}"
constructor_declaration (+26 nodes collapsed)
line_comment "// copy constructor"
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "RandomAccessFileOrArray"
identifier "file"
) ")"
throws
throws "throws"
type_identifier "IOException"
constructor_body
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "file"
== "=="
null_literal "null"
) ")"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IllegalArgumentException"
argument_list
( "("
string_literal
" "\""
string_fragment "null file passed into RandomAccessFileOrArray() copy constru"...
" "\""
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
field_access
identifier "file"
. "."
identifier "filename"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "filename"
= "="
field_access
identifier "file"
. "."
identifier "filename"
; ";"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "rf"
= "="
null_literal "null"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
field_access
identifier "file"
. "."
identifier "arrayIn"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "arrayIn"
= "="
field_access
identifier "file"
. "."
identifier "arrayIn"
; ";"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "arrayInPtr"
= "="
decimal_integer_literal "0"
; ";"
} "}"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "startOffset"
= "="
field_access
identifier "file"
. "."
identifier "startOffset"
; ";"
} "}"
line_comment "////"
line_comment "//"
line_comment "//"
method_declaration
modifiers
private "private"
void_type "void"
identifier "inputStreamToArray"
formal_parameters
( "("
formal_parameter
type_identifier "InputStream"
identifier "is"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
local_variable_declaration
integral_type
byte "byte"
variable_declarator
identifier "bb"
dimensions
[ "["
] "]"
= "="
array_creation_expression
new "new"
integral_type
byte "byte"
dimensions_expr
[ "["
decimal_integer_literal "8192"
] "]"
; ";"
local_variable_declaration
type_identifier "ByteArrayOutputStream"
variable_declarator
identifier "out"
= "="
object_creation_expression
new "new"
type_identifier "ByteArrayOutputStream"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "len"
= "="
decimal_integer_literal "0"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
decimal_integer_literal "1"
< "<"
parenthesized_expression
( "("
assignment_expression
identifier "len"
= "="
method_invocation
identifier "is"
. "."
identifier "read"
argument_list
( "("
identifier "bb"
) ")"
) ")"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "out"
. "."
identifier "write"
argument_list
( "("
identifier "bb"
, ","
decimal_integer_literal "0"
, ","
identifier "len"
) ")"
; ";"
} "}"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "arrayIn"
= "="
method_invocation
identifier "out"
. "."
identifier "toByteArray"
argument_list
( "("
) ")"
; ";"
line_comment "// allocates a new byte array"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "arrayInPtr"
= "="
decimal_integer_literal "0"
; ";"
} "}"
line_comment "// added pushBack isBack test since we hold only one byte"
method_declaration (+49 nodes collapsed)
method_declaration (+58 nodes collapsed)
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isBack"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "isBack"
; ";"
} "}"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "getBack"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "back"
& "&"
hex_integer_literal "0xff"
; ";"
} "}"
method_declaration (+23 nodes collapsed)
line_comment "// reads one byte"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "read"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "retVal"
= "="
unary_expression
- "-"
decimal_integer_literal "1"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
identifier "isBack"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "retVal"
= "="
method_invocation
identifier "getBack"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rf"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "retVal"
= "="
method_invocation
identifier "rf"
. "."
identifier "read"
argument_list
( "("
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
binary_expression
identifier "arrayIn"
!= "!="
null_literal "null"
&& "&&"
binary_expression
decimal_integer_literal "0"
<= "<="
identifier "arrayInPtr"
&& "&&"
binary_expression
identifier "arrayInPtr"
< "<"
field_access
identifier "arrayIn"
. "."
identifier "length"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "retVal"
= "="
binary_expression
array_access
identifier "arrayIn"
[ "["
update_expression
identifier "arrayInPtr"
++ "++"
] "]"
& "&"
hex_integer_literal "0xff"
; ";"
} "}"
return_statement
return "return"
identifier "retVal"
; ";"
} "}"
line_comment "// bb: buffer to read into"
line_comment "// off: index of b where to begin"
line_comment "// len: max number of bytes to copy"
line_comment "// return: number of bytes read, or -1 on end"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "read"
formal_parameters
( "("
formal_parameter
array_type
integral_type
byte "byte"
dimensions
[ "["
] "]"
identifier "bb"
, ","
formal_parameter
integral_type
int "int"
identifier "off"
, ","
formal_parameter
integral_type
int "int"
identifier "len"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "bb"
== "=="
null_literal "null"
) ")"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IllegalArgumentException"
argument_list
( "("
string_literal
" "\""
string_fragment "read() argument bb is null."
" "\""
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "len"
== "=="
decimal_integer_literal "0"
|| "||"
binary_expression
field_access
identifier "bb"
. "."
identifier "length"
== "=="
decimal_integer_literal "0"
) ")"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
line_comment "// nothing read; test before (bb.length<= off)"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
binary_expression
binary_expression
identifier "len"
< "<"
decimal_integer_literal "0"
|| "||"
binary_expression
identifier "off"
< "<"
decimal_integer_literal "0"
|| "||"
binary_expression
field_access
identifier "bb"
. "."
identifier "length"
<= "<="
identifier "off"
|| "||"
binary_expression
field_access
identifier "bb"
. "."
identifier "length"
< "<"
binary_expression
identifier "off"
+ "+"
identifier "len"
) ")"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IllegalArgumentException"
argument_list
( "("
binary_expression
binary_expression
binary_expression
binary_expression
binary_expression
string_literal
" "\""
string_fragment "read() arguments are out of bounds: len: "
" "\""
+ "+"
identifier "len"
+ "+"
string_literal
" "\""
string_fragment " off: "
" "\""
+ "+"
identifier "off"
+ "+"
string_literal
" "\""
string_fragment " bb.length: "
" "\""
+ "+"
field_access
identifier "bb"
. "."
identifier "length"
) ")"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "retVal"
= "="
unary_expression
- "-"
decimal_integer_literal "1"
; ";"
line_comment "// default: end of data"
line_comment "// test for pushed-back byte"
if_statement
if "if"
parenthesized_expression
( "("
identifier "isBack"
) ")"
block
{ "{"
line_comment "// prepend byte; reset later"
expression_statement
assignment_expression
array_access
identifier "bb"
[ "["
update_expression
identifier "off"
++ "++"
] "]"
= "="
identifier "back"
; ";"
expression_statement
update_expression
-- "--"
identifier "len"
; ";"
} "}"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rf"
!= "!="
null_literal "null"
) ")"
block
{ "{"
line_comment "// use rf"
expression_statement
assignment_expression
identifier "retVal"
= "="
method_invocation
identifier "rf"
. "."
identifier "read"
argument_list
( "("
identifier "bb"
, ","
identifier "off"
, ","
identifier "len"
) ")"
; ";"
line_comment "// could return -1"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayIn"
!= "!="
null_literal "null"
) ")"
block
{ "{"
line_comment "// use array"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
decimal_integer_literal "0"
<= "<="
identifier "arrayInPtr"
&& "&&"
binary_expression
identifier "arrayInPtr"
< "<"
field_access
identifier "arrayIn"
. "."
identifier "length"
) ")"
block
{ "{"
if_statement (+27 nodes collapsed)
line_comment "// take only what's left"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
decimal_integer_literal "0"
< "<"
identifier "len"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "System"
. "."
identifier "arraycopy"
argument_list
( "("
identifier "arrayIn"
, ","
identifier "arrayInPtr"
, ","
identifier "bb"
, ","
identifier "off"
, ","
identifier "len"
) ")"
; ";"
expression_statement
assignment_expression
identifier "arrayInPtr"
+= "+="
identifier "len"
; ";"
expression_statement
assignment_expression
identifier "retVal"
= "="
identifier "len"
; ";"
} "}"
line_comment "// else end of array data"
} "}"
line_comment "// else end of array data"
} "}"
if_statement (+30 nodes collapsed)
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
return_statement
return "return"
identifier "retVal"
; ";"
} "}"
line_comment "//"
method_declaration (+38 nodes collapsed)
line_comment "//"
method_declaration
modifiers
public "public"
void_type "void"
identifier "readFully"
formal_parameters
( "("
formal_parameter
integral_type
byte "byte"
identifier "bb"
dimensions
[ "["
] "]"
, ","
formal_parameter
integral_type
int "int"
identifier "off"
, ","
formal_parameter
integral_type
int "int"
identifier "len"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "bytesRead"
= "="
decimal_integer_literal "0"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "nn"
= "="
decimal_integer_literal "0"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
identifier "bytesRead"
< "<"
identifier "len"
) ")"
block
{ "{"
line_comment "// len may be 0"
expression_statement
assignment_expression
identifier "nn"
= "="
method_invocation
this "this"
. "."
identifier "read"
argument_list
( "("
identifier "bb"
, ","
binary_expression
identifier "off"
+ "+"
identifier "bytesRead"
, ","
binary_expression
identifier "len"
- "-"
identifier "bytesRead"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "nn"
< "<"
decimal_integer_literal "0"
) ")"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "EOFException"
argument_list
( "("
) ")"
; ";"
expression_statement
assignment_expression
identifier "bytesRead"
+= "+="
identifier "nn"
; ";"
} "}"
} "}"
method_declaration
modifiers
public "public"
void_type "void"
identifier "readFully"
formal_parameters
( "("
formal_parameter
integral_type
byte "byte"
identifier "bb"
dimensions
[ "["
] "]"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
expression_statement
method_invocation
identifier "readFully"
argument_list
( "("
identifier "bb"
, ","
decimal_integer_literal "0"
, ","
field_access
identifier "bb"
. "."
identifier "length"
) ")"
; ";"
} "}"
line_comment "// calls clearBack()"
method_declaration
modifiers
public "public"
void_type "void"
identifier "reOpen"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 2:3
binary_expression any 2:3
identifier "filename"
!= "!="
null_literal "null"
&& "&&"
binary_expression
identifier "rf"
== "=="
null_literal "null"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "rf"
= "="
object_creation_expression
new "new"
type_identifier "RandomAccessFile"
argument_list
( "("
identifier "filename"
, ","
string_literal
" "\""
string_fragment "r"
" "\""
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 1:2
identifier "rf"
== "=="
null_literal "null"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IOException"
argument_list
( "("
binary_expression
string_literal
" "\""
string_fragment "Unable to reOpen: "
" "\""
+ "+"
identifier "filename"
) ")"
; ";"
} "}"
} "}"
expression_statement
method_invocation
this "this"
. "."
identifier "seek"
argument_list
( "("
decimal_integer_literal "0"
) ")"
; ";"
line_comment "// calls clearBack()"
} "}"
line_comment "// might call clearBack()"
method_declaration
modifiers
protected "protected"
void_type "void"
identifier "insureOpen"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 2:3
binary_expression any 2:3
identifier "filename"
!= "!="
null_literal "null"
&& "&&"
binary_expression
identifier "rf"
== "=="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "reOpen"
argument_list
( "("
) ")"
; ";"
} "}"
} "}"
line_comment "//"
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isOpen"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
parenthesized_expression
( "("
binary_expression any 2:3
binary_expression any 2:3
identifier "filename"
== "=="
null_literal "null"
|| "||"
binary_expression
identifier "rf"
!= "!="
null_literal "null"
) ")"
; ";"
} "}"
line_comment "//"
method_declaration
modifiers
public "public"
void_type "void"
identifier "close"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rf"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "rf"
. "."
identifier "close"
argument_list
( "("
) ")"
; ";"
expression_statement
assignment_expression
identifier "rf"
= "="
null_literal "null"
; ";"
} "}"
line_comment "// preserves this.filename and this.arrayIn"
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
} "}"
line_comment "//"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "length"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "filename"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "insureOpen"
argument_list
( "("
) ")"
; ";"
return_statement
return "return"
binary_expression
cast_expression
( "("
integral_type
int "int"
) ")"
method_invocation
identifier "rf"
. "."
identifier "length"
argument_list
( "("
) ")"
- "-"
identifier "startOffset"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayIn"
!= "!="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
field_access
identifier "arrayIn"
. "."
identifier "length"
- "-"
identifier "startOffset"
; ";"
} "}"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
} "}"
line_comment "//"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "getFilePointer"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
expression_statement
method_invocation
identifier "insureOpen"
argument_list
( "("
) ")"
; ";"
line_comment "// might call clearBack(), so call first"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "nn"
= "="
ternary_expression
identifier "isBack"
? "?"
decimal_integer_literal "1"
: ":"
decimal_integer_literal "0"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "filename"
!= "!="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
binary_expression
cast_expression
( "("
integral_type
int "int"
) ")"
method_invocation
identifier "rf"
. "."
identifier "getFilePointer"
argument_list
( "("
) ")"
- "-"
identifier "nn"
- "-"
identifier "startOffset"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayIn"
!= "!="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
binary_expression
identifier "arrayInPtr"
- "-"
identifier "nn"
- "-"
identifier "startOffset"
; ";"
} "}"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
line_comment "// no data -- shouldn't happen"
} "}"
line_comment "//"
method_declaration
modifiers
public "public"
void_type "void"
identifier "seek"
formal_parameters
( "("
formal_parameter
integral_type
int "int"
identifier "pos"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
expression_statement
assignment_expression
identifier "pos"
+= "+="
identifier "startOffset"
; ";"
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "filename"
!= "!="
null_literal "null"
) ")"
block
{ "{"
line_comment "// not calling insureOpen() b/c it calls reOpen() which call"...
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rf"
== "=="
null_literal "null"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "rf"
= "="
object_creation_expression
new "new"
type_identifier "RandomAccessFile"
argument_list
( "("
identifier "filename"
, ","
string_literal
" "\""
string_fragment "r"
" "\""
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rf"
== "=="
null_literal "null"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IOException"
argument_list
( "("
binary_expression
binary_expression
string_literal
" "\""
string_fragment "Unable to open: "
" "\""
+ "+"
identifier "filename"
+ "+"
string_literal
" "\""
string_fragment " in seek()"
" "\""
) ")"
; ";"
} "}"
} "}"
expression_statement
method_invocation
identifier "rf"
. "."
identifier "seek"
argument_list
( "("
identifier "pos"
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayIn"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "arrayInPtr"
= "="
identifier "pos"
; ";"
} "}"
} "}"
line_comment "//"
method_declaration (+31 nodes collapsed)
line_comment "//"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "skipBytes"
formal_parameters
( "("
formal_parameter
integral_type
int "int"
identifier "nn"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "nn"
<= "<="
decimal_integer_literal "0"
) ")"
block
{ "{"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
} "}"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "nn"
== "=="
decimal_integer_literal "1"
&& "&&"
identifier "isBack"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
return_statement
return "return"
decimal_integer_literal "1"
; ";"
} "}"
line_comment "// no need for additional isBack logic b/c helper functions "...
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "pos"
= "="
method_invocation
this "this"
. "."
identifier "getFilePointer"
argument_list
( "("
) ")"
; ";"
line_comment "// considers isBack and startOffset"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "len"
= "="
method_invocation
this "this"
. "."
identifier "length"
argument_list
( "("
) ")"
; ";"
line_comment "// considers startOffset"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "newpos"
= "="
binary_expression
identifier "pos"
+ "+"
identifier "nn"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "newpos"
> ">"
identifier "len"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "newpos"
= "="
identifier "len"
; ";"
line_comment "// seek(len) ensures that next read() returns -1"
} "}"
expression_statement
method_invocation
this "this"
. "."
identifier "seek"
argument_list
( "("
identifier "newpos"
) ")"
; ";"
line_comment "// considers startOffset"
return_statement
return "return"
binary_expression
identifier "newpos"
- "-"
identifier "pos"
; ";"
} "}"
line_comment "//"
method_declaration (+33 nodes collapsed)
line_comment "//"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "getStartOffset"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
field_access
this "this"
. "."
identifier "startOffset"
; ";"
} "}"
method_declaration (+37 nodes collapsed)
line_comment "////"
line_comment "//"
method_declaration (+56 nodes collapsed)
method_declaration (+59 nodes collapsed)
method_declaration (+51 nodes collapsed)
method_declaration (+88 nodes collapsed)
block_comment "/**\n * Reads a signed 16-bit number from this stream in "...
method_declaration (+95 nodes collapsed)
method_declaration (+80 nodes collapsed)
block_comment "/**\n * Reads an unsigned 16-bit number from this stream "...
method_declaration (+87 nodes collapsed)
method_declaration (+88 nodes collapsed)
block_comment "/**\n * Reads a Unicode character from this stream in lit"...
method_declaration (+95 nodes collapsed)
method_declaration (+135 nodes collapsed)
block_comment "/**\n * Reads a signed 32-bit integer from this stream in"...
method_declaration (+142 nodes collapsed)
block_comment "/**\n * Reads an unsigned 32-bit integer from this stream"...
method_declaration (+142 nodes collapsed)
method_declaration (+142 nodes collapsed)
method_declaration (+50 nodes collapsed)
method_declaration (+64 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+31 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+31 nodes collapsed)
method_declaration (+212 nodes collapsed)
method_declaration (+25 nodes collapsed)
} "}"

After

program
block_comment "/*\n * $Id: RandomAccessFileOrArray.java 4065 2009-09-16 23:0"...
line_comment "// pdftk-java iText base version 4.2.0"
line_comment "// pdftk-java modified yes (no idea why)"
package_declaration (+22 nodes collapsed)
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "gitlab"
. "."
identifier "pdftk_java"
. "."
identifier "com"
. "."
identifier "lowagie"
. "."
identifier "text"
. "."
identifier "Document"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "ByteArrayOutputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "DataInput"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "DataInputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "EOFException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "File"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "FileInputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "IOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "InputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "RandomAccessFile"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "net"
. "."
identifier "URL"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "nio"
. "."
identifier "channels"
. "."
identifier "FileChannel"
; ";"
block_comment "/** An implementation of a RandomAccessFile for input only\n "...
class_declaration
modifiers
public "public"
class "class"
identifier "RandomAccessFileOrArray"
super_interfaces
implements "implements"
type_list
type_identifier "DataInput"
class_body
{ "{"
line_comment "////"
line_comment "// uses either rf or arrayIn, but not both"
field_declaration
type_identifier "MappedRandomAccessFile"
variable_declarator
identifier "rf"
= "="
null_literal "null"
; ";"
field_declaration
type_identifier "RandomAccessFile"
variable_declarator
identifier "trf"
= "="
null_literal "null"
; ";"
line_comment "// may be null even if filename is set"
field_declaration
boolean_type "boolean"
variable_declarator
identifier "plainRandomAccess"
; ";"
field_declaration
type_identifier "String"
variable_declarator
identifier "filename"
= "="
null_literal "null"
; ";"
line_comment "// set only if we expect to use rf (not arrayIn)"
field_declaration
integral_type
byte "byte"
variable_declarator
identifier "arrayIn"
dimensions
[ "["
] "]"
= "="
null_literal "null"
; ";"
line_comment "// set only if we aren't using filename/rf"
field_declaration
integral_type
int "int"
variable_declarator
identifier "arrayInPtr"
= "="
decimal_integer_literal "0"
; ";"
field_declaration
modifiers
private "private"
integral_type
byte "byte"
variable_declarator
identifier "back"
= "="
decimal_integer_literal "0"
; ";"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "isBack"
= "="
false "false"
; ";"
block_comment "/** Holds value of property startOffset. */"
field_declaration
modifiers
private "private"
integral_type
int "int"
variable_declarator
identifier "startOffset"
= "="
decimal_integer_literal "0"
; ";"
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "filename"
) ")"
throws
throws "throws"
type_identifier "IOException"
constructor_body
{ "{"
explicit_constructor_invocation
this "this"
argument_list
( "("
identifier "filename"
, ","
false "false"
, ","
field_access
identifier "Document"
. "."
identifier "plainRandomAccess"
) ")"
; ";"
} "}"
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "filename"
, ","
formal_parameter
boolean_type "boolean"
identifier "forceRead"
, ","
formal_parameter
boolean_type "boolean"
identifier "plainRandomAccess"
) ")"
throws
throws "throws"
type_identifier "IOException"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "plainRandomAccess"
= "="
identifier "plainRandomAccess"
; ";"
if_statement (+22 nodes collapsed)
local_variable_declaration
type_identifier "File"
variable_declarator
identifier "file"
= "="
object_creation_expression
new "new"
type_identifier "File"
argument_list
( "("
identifier "filename"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
identifier "file"
. "."
identifier "canRead"
argument_list
( "("
) ")"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 3:4
binary_expression any 3:4
binary_expression any 3:4
binary_expression any 3:4
method_invocation
identifier "filename"
. "."
identifier "startsWith"
argument_list
( "("
string_literal
" "\""
string_fragment "file:/"
" "\""
) ")"
|| "||"
method_invocation
identifier "filename"
. "."
identifier "startsWith"
argument_list
( "("
string_literal
" "\""
string_fragment "http://"
" "\""
) ")"
|| "||"
method_invocation
identifier "filename"
. "."
identifier "startsWith"
argument_list
( "("
string_literal
" "\""
string_fragment "https://"
" "\""
) ")"
|| "||"
method_invocation
identifier "filename"
. "."
identifier "startsWith"
argument_list
( "("
string_literal
" "\""
string_fragment "jar:"
" "\""
) ")"
|| "||"
method_invocation
identifier "filename"
. "."
identifier "startsWith"
argument_list
( "("
string_literal
" "\""
string_fragment "wsjar:"
" "\""
) ")"
) ")"
block
{ "{"
line_comment "// copied from RandomAccessFileOrArray(URL):"
local_variable_declaration
type_identifier "InputStream"
variable_declarator
identifier "is"
= "="
method_invocation
object_creation_expression
new "new"
type_identifier "URL"
argument_list
( "("
identifier "filename"
) ")"
. "."
identifier "openStream"
argument_list
( "("
) ")"
; ";"
try_statement
try "try"
block
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "arrayIn"
= "="
method_invocation
identifier "InputStreamToArray"
argument_list
( "("
identifier "is"
) ")"
; ";"
return_statement
return "return"
; ";"
} "}"
finally_clause (+30 nodes collapsed)
} "}"
else "else"
block
{ "{"
local_variable_declaration
type_identifier "InputStream"
variable_declarator
identifier "is"
= "="
method_invocation
identifier "BaseFont"
. "."
identifier "getResourceStream"
argument_list
( "("
identifier "filename"
) ")"
; ";"
if_statement (+25 nodes collapsed)
try_statement
try "try"
block
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "arrayIn"
= "="
method_invocation
identifier "InputStreamToArray"
argument_list
( "("
identifier "is"
) ")"
; ";"
return_statement
return "return"
; ";"
} "}"
finally_clause (+30 nodes collapsed)
} "}"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
identifier "forceRead"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "InputStream"
variable_declarator
identifier "s"
= "="
null_literal "null"
; ";"
try_statement
try "try"
block
{ "{"
expression_statement
assignment_expression
identifier "s"
= "="
object_creation_expression
new "new"
type_identifier "FileInputStream"
argument_list
( "("
identifier "file"
) ")"
; ";"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "arrayIn"
= "="
method_invocation
identifier "InputStreamToArray"
argument_list
( "("
identifier "s"
) ")"
; ";"
} "}"
finally_clause
finally "finally"
block
{ "{"
try_statement
try "try"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "s"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "s"
. "."
identifier "close"
argument_list
( "("
) ")"
; ";"
} "}"
} "}"
catch_clause
catch "catch"
( "("
catch_formal_parameter
catch_type
type_identifier "Exception"
identifier "e"
) ")"
block
{ "{"
} "}"
} "}"
return_statement
return "return"
; ";"
} "}"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "filename"
= "="
identifier "filename"
; ";"
line_comment "// set only if we're using rf"
if_statement
if "if"
parenthesized_expression
( "("
identifier "plainRandomAccess"
) ")"
expression_statement
assignment_expression
identifier "trf"
= "="
object_creation_expression
new "new"
type_identifier "RandomAccessFile"
argument_list
( "("
identifier "filename"
, ","
string_literal
" "\""
string_fragment "r"
" "\""
) ")"
; ";"
else "else"
expression_statement
assignment_expression
identifier "rf"
= "="
object_creation_expression
new "new"
type_identifier "MappedRandomAccessFile"
argument_list
( "("
identifier "filename"
, ","
string_literal
" "\""
string_fragment "r"
" "\""
) ")"
; ";"
} "}"
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "URL"
identifier "url"
) ")"
throws
throws "throws"
type_identifier "IOException"
constructor_body
{ "{"
if_statement (+22 nodes collapsed)
local_variable_declaration
type_identifier "InputStream"
variable_declarator
identifier "is"
= "="
method_invocation
identifier "url"
. "."
identifier "openStream"
argument_list
( "("
) ")"
; ";"
try_statement
try "try"
block
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "arrayIn"
= "="
method_invocation
identifier "InputStreamToArray"
argument_list
( "("
identifier "is"
) ")"
; ";"
} "}"
finally_clause (+30 nodes collapsed)
} "}"
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "InputStream"
identifier "is"
) ")"
throws
throws "throws"
type_identifier "IOException"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "arrayIn"
= "="
method_invocation
identifier "InputStreamToArray"
argument_list
( "("
identifier "is"
) ")"
; ";"
} "}"
method_declaration
modifiers
public "public"
static "static"
array_type
integral_type
byte "byte"
dimensions
[ "["
] "]"
identifier "InputStreamToArray"
formal_parameters
( "("
formal_parameter
type_identifier "InputStream"
identifier "is"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
local_variable_declaration
integral_type
byte "byte"
variable_declarator
identifier "b"
dimensions
[ "["
] "]"
= "="
array_creation_expression
new "new"
integral_type
byte "byte"
dimensions_expr
[ "["
decimal_integer_literal "8192"
] "]"
; ";"
local_variable_declaration
type_identifier "ByteArrayOutputStream"
variable_declarator
identifier "out"
= "="
object_creation_expression
new "new"
type_identifier "ByteArrayOutputStream"
argument_list
( "("
) ")"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
true "true"
) ")"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "read"
= "="
method_invocation
identifier "is"
. "."
identifier "read"
argument_list
( "("
identifier "b"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "read"
< "<"
decimal_integer_literal "1"
) ")"
break_statement
break "break"
; ";"
expression_statement
method_invocation
identifier "out"
. "."
identifier "write"
argument_list
( "("
identifier "b"
, ","
decimal_integer_literal "0"
, ","
identifier "read"
) ")"
; ";"
} "}"
expression_statement
method_invocation
identifier "out"
. "."
identifier "close"
argument_list
( "("
) ")"
; ";"
return_statement
return "return"
method_invocation
identifier "out"
. "."
identifier "toByteArray"
argument_list
( "("
) ")"
; ";"
} "}"
constructor_declaration (+26 nodes collapsed)
constructor_declaration
modifiers
public "public"
identifier "RandomAccessFileOrArray"
formal_parameters
( "("
formal_parameter
type_identifier "RandomAccessFileOrArray"
identifier "file"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
identifier "filename"
= "="
field_access
identifier "file"
. "."
identifier "filename"
; ";"
expression_statement
assignment_expression
identifier "arrayIn"
= "="
field_access
identifier "file"
. "."
identifier "arrayIn"
; ";"
expression_statement
assignment_expression
identifier "startOffset"
= "="
field_access
identifier "file"
. "."
identifier "startOffset"
; ";"
expression_statement
assignment_expression
identifier "plainRandomAccess"
= "="
field_access
identifier "file"
. "."
identifier "plainRandomAccess"
; ";"
} "}"
line_comment "// added pushBack isBack test since we hold only one byte"
method_declaration (+49 nodes collapsed)
method_declaration (+58 nodes collapsed)
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isBack"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "isBack"
; ";"
} "}"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "getBack"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "back"
& "&"
hex_integer_literal "0xff"
; ";"
} "}"
method_declaration (+23 nodes collapsed)
line_comment "// reads one byte"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "read"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
identifier "isBack"
) ")"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "retVal"
= "="
method_invocation
identifier "getBack"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
return_statement
return "return"
identifier "retVal"
; ";"
} "}"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayIn"
== "=="
null_literal "null"
) ")"
return_statement
return "return"
ternary_expression
identifier "plainRandomAccess"
? "?"
method_invocation
identifier "trf"
. "."
identifier "read"
argument_list
( "("
) ")"
: ":"
method_invocation
identifier "rf"
. "."
identifier "read"
argument_list
( "("
) ")"
; ";"
else "else"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayInPtr"
>= ">="
field_access
identifier "arrayIn"
. "."
identifier "length"
) ")"
return_statement
return "return"
unary_expression
- "-"
decimal_integer_literal "1"
; ";"
return_statement
return "return"
binary_expression
array_access
identifier "arrayIn"
[ "["
update_expression
identifier "arrayInPtr"
++ "++"
] "]"
& "&"
hex_integer_literal "0xff"
; ";"
} "}"
} "}"
line_comment "// bb: buffer to read into"
line_comment "// off: index of b where to begin"
line_comment "// len: max number of bytes to copy"
line_comment "// return: number of bytes read, or -1 on end"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "read"
formal_parameters
( "("
formal_parameter
array_type
integral_type
byte "byte"
dimensions
[ "["
] "]"
identifier "b"
, ","
formal_parameter
integral_type
int "int"
identifier "off"
, ","
formal_parameter
integral_type
int "int"
identifier "len"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "b"
== "=="
null_literal "null"
) ")"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IllegalArgumentException"
argument_list
( "("
string_literal
" "\""
string_fragment "read() argument b is null."
" "\""
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "len"
== "=="
decimal_integer_literal "0"
|| "||"
binary_expression
field_access
identifier "b"
. "."
identifier "length"
== "=="
decimal_integer_literal "0"
) ")"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
line_comment "// nothing read; test before (b.length<= off)"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
binary_expression
binary_expression
identifier "len"
< "<"
decimal_integer_literal "0"
|| "||"
binary_expression
identifier "off"
< "<"
decimal_integer_literal "0"
|| "||"
binary_expression
field_access
identifier "b"
. "."
identifier "length"
<= "<="
identifier "off"
|| "||"
binary_expression
field_access
identifier "b"
. "."
identifier "length"
< "<"
binary_expression
identifier "off"
+ "+"
identifier "len"
) ")"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IllegalArgumentException"
argument_list
( "("
binary_expression
binary_expression
binary_expression
binary_expression
binary_expression
string_literal
" "\""
string_fragment "read() arguments are out of bounds: len: "
" "\""
+ "+"
identifier "len"
+ "+"
string_literal
" "\""
string_fragment " off: "
" "\""
+ "+"
identifier "off"
+ "+"
string_literal
" "\""
string_fragment " b.length: "
" "\""
+ "+"
field_access
identifier "b"
. "."
identifier "length"
) ")"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "retVal"
= "="
unary_expression
- "-"
decimal_integer_literal "1"
; ";"
line_comment "// default: end of data"
line_comment "// test for pushed-back byte"
if_statement
if "if"
parenthesized_expression
( "("
identifier "isBack"
) ")"
block
{ "{"
line_comment "// prepend byte; reset later"
expression_statement
assignment_expression
array_access
identifier "b"
[ "["
update_expression
identifier "off"
++ "++"
] "]"
= "="
identifier "back"
; ";"
expression_statement
update_expression
-- "--"
identifier "len"
; ";"
} "}"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayIn"
== "=="
null_literal "null"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "retVal"
= "="
parenthesized_expression
( "("
ternary_expression
identifier "plainRandomAccess"
? "?"
method_invocation
identifier "trf"
. "."
identifier "read"
argument_list
( "("
identifier "b"
, ","
identifier "off"
, ","
identifier "len"
) ")"
: ":"
method_invocation
identifier "rf"
. "."
identifier "read"
argument_list
( "("
identifier "b"
, ","
identifier "off"
, ","
identifier "len"
) ")"
) ")"
; ";"
line_comment "// could return -1"
} "}"
else "else"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
decimal_integer_literal "0"
<= "<="
identifier "arrayInPtr"
&& "&&"
binary_expression
identifier "arrayInPtr"
< "<"
field_access
identifier "arrayIn"
. "."
identifier "length"
) ")"
block
{ "{"
if_statement (+27 nodes collapsed)
line_comment "// take only what's left"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
decimal_integer_literal "0"
< "<"
identifier "len"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "System"
. "."
identifier "arraycopy"
argument_list
( "("
identifier "arrayIn"
, ","
identifier "arrayInPtr"
, ","
identifier "b"
, ","
identifier "off"
, ","
identifier "len"
) ")"
; ";"
expression_statement
assignment_expression
identifier "arrayInPtr"
+= "+="
identifier "len"
; ";"
expression_statement
assignment_expression
identifier "retVal"
= "="
identifier "len"
; ";"
} "}"
line_comment "// else end of array data"
} "}"
line_comment "// else end of array data"
} "}"
if_statement (+30 nodes collapsed)
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
return_statement
return "return"
identifier "retVal"
; ";"
} "}"
method_declaration (+38 nodes collapsed)
method_declaration
modifiers
public "public"
void_type "void"
identifier "readFully"
formal_parameters
( "("
formal_parameter
integral_type
byte "byte"
identifier "b"
dimensions
[ "["
] "]"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
expression_statement
method_invocation
identifier "readFully"
argument_list
( "("
identifier "b"
, ","
decimal_integer_literal "0"
, ","
field_access
identifier "b"
. "."
identifier "length"
) ")"
; ";"
} "}"
method_declaration
modifiers
public "public"
void_type "void"
identifier "readFully"
formal_parameters
( "("
formal_parameter
integral_type
byte "byte"
identifier "b"
dimensions
[ "["
] "]"
, ","
formal_parameter
integral_type
int "int"
identifier "off"
, ","
formal_parameter
integral_type
int "int"
identifier "len"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "n"
= "="
decimal_integer_literal "0"
; ";"
do_statement
do "do"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "count"
= "="
method_invocation
identifier "read"
argument_list
( "("
identifier "b"
, ","
binary_expression
identifier "off"
+ "+"
identifier "n"
, ","
binary_expression
identifier "len"
- "-"
identifier "n"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "count"
< "<"
decimal_integer_literal "0"
) ")"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "EOFException"
argument_list
( "("
) ")"
; ";"
expression_statement
assignment_expression
identifier "n"
+= "+="
identifier "count"
; ";"
} "}"
while "while"
parenthesized_expression
( "("
binary_expression
identifier "n"
< "<"
identifier "len"
) ")"
; ";"
} "}"
method_declaration (+33 nodes collapsed)
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "skipBytes"
formal_parameters
( "("
formal_parameter
integral_type
int "int"
identifier "n"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "n"
<= "<="
decimal_integer_literal "0"
) ")"
block
{ "{"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
} "}"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "n"
== "=="
decimal_integer_literal "1"
&& "&&"
identifier "isBack"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
return_statement
return "return"
decimal_integer_literal "1"
; ";"
} "}"
line_comment "// no need for additional isBack logic b/c helper functions "...
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "pos"
= "="
method_invocation
this "this"
. "."
identifier "getFilePointer"
argument_list
( "("
) ")"
; ";"
line_comment "// considers isBack and startOffset"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "len"
= "="
method_invocation
this "this"
. "."
identifier "length"
argument_list
( "("
) ")"
; ";"
line_comment "// considers startOffset"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "newpos"
= "="
binary_expression
identifier "pos"
+ "+"
identifier "n"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "newpos"
> ">"
identifier "len"
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "newpos"
= "="
identifier "len"
; ";"
line_comment "// seek(len) ensures that next read() returns -1"
} "}"
expression_statement
method_invocation
identifier "seek"
argument_list
( "("
identifier "newpos"
) ")"
; ";"
line_comment "// considers startOffset"
return_statement
return "return"
binary_expression
identifier "newpos"
- "-"
identifier "pos"
; ";"
} "}"
line_comment "// calls clearBack()"
method_declaration
modifiers
public "public"
void_type "void"
identifier "reOpen"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 2:3
binary_expression any 2:3
binary_expression any 2:3
identifier "filename"
!= "!="
null_literal "null"
&& "&&"
binary_expression
identifier "rf"
== "=="
null_literal "null"
&& "&&"
binary_expression
identifier "trf"
== "=="
null_literal "null"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
identifier "plainRandomAccess"
) ")"
expression_statement
assignment_expression
identifier "trf"
= "="
object_creation_expression
new "new"
type_identifier "RandomAccessFile"
argument_list
( "("
identifier "filename"
, ","
string_literal
" "\""
string_fragment "r"
" "\""
) ")"
; ";"
else "else"
expression_statement
assignment_expression
identifier "rf"
= "="
object_creation_expression
new "new"
type_identifier "MappedRandomAccessFile"
argument_list
( "("
identifier "filename"
, ","
string_literal
" "\""
string_fragment "r"
" "\""
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 1:2
binary_expression any 1:2
identifier "rf"
== "=="
null_literal "null"
&& "&&"
binary_expression
identifier "trf"
== "=="
null_literal "null"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IOException"
argument_list
( "("
binary_expression
string_literal
" "\""
string_fragment "Unable to reOpen: "
" "\""
+ "+"
identifier "filename"
) ")"
; ";"
} "}"
} "}"
expression_statement
method_invocation
identifier "seek"
argument_list
( "("
decimal_integer_literal "0"
) ")"
; ";"
} "}"
line_comment "// might call clearBack()"
method_declaration
modifiers
protected "protected"
void_type "void"
identifier "insureOpen"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression any 2:3
binary_expression any 2:3
binary_expression any 2:3
identifier "filename"
!= "!="
null_literal "null"
&& "&&"
binary_expression
identifier "rf"
== "=="
null_literal "null"
&& "&&"
binary_expression
identifier "trf"
== "=="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "reOpen"
argument_list
( "("
) ")"
; ";"
} "}"
} "}"
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isOpen"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
parenthesized_expression
( "("
binary_expression any 2:3
binary_expression any 2:3
binary_expression any 2:3
identifier "filename"
== "=="
null_literal "null"
|| "||"
binary_expression
identifier "rf"
!= "!="
null_literal "null"
|| "||"
binary_expression
identifier "trf"
!= "!="
null_literal "null"
) ")"
; ";"
} "}"
method_declaration
modifiers
public "public"
void_type "void"
identifier "close"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
line_comment "// preserves this.filename and this.arrayIn"
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rf"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "rf"
. "."
identifier "close"
argument_list
( "("
) ")"
; ";"
expression_statement
assignment_expression
identifier "rf"
= "="
null_literal "null"
; ";"
line_comment "// it's very expensive to open a memory mapped file and for "...
line_comment "// in iText it's faster the next re-openings to be done as a"...
line_comment "// file"
expression_statement
assignment_expression
identifier "plainRandomAccess"
= "="
true "true"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "trf"
!= "!="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "trf"
. "."
identifier "close"
argument_list
( "("
) ")"
; ";"
expression_statement
assignment_expression
identifier "trf"
= "="
null_literal "null"
; ";"
} "}"
} "}"
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "length"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayIn"
== "=="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "insureOpen"
argument_list
( "("
) ")"
; ";"
return_statement
return "return"
binary_expression
cast_expression
( "("
integral_type
int "int"
) ")"
parenthesized_expression
( "("
ternary_expression
identifier "plainRandomAccess"
? "?"
method_invocation
identifier "trf"
. "."
identifier "length"
argument_list
( "("
) ")"
: ":"
method_invocation
identifier "rf"
. "."
identifier "length"
argument_list
( "("
) ")"
) ")"
- "-"
identifier "startOffset"
; ";"
} "}"
else "else"
return_statement
return "return"
binary_expression
field_access
identifier "arrayIn"
. "."
identifier "length"
- "-"
identifier "startOffset"
; ";"
} "}"
method_declaration
modifiers
public "public"
void_type "void"
identifier "seek"
formal_parameters
( "("
formal_parameter
integral_type
int "int"
identifier "pos"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
expression_statement
assignment_expression
identifier "pos"
+= "+="
identifier "startOffset"
; ";"
expression_statement
method_invocation
identifier "clearBack"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayIn"
== "=="
null_literal "null"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "insureOpen"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
identifier "plainRandomAccess"
) ")"
expression_statement
method_invocation
identifier "trf"
. "."
identifier "seek"
argument_list
( "("
identifier "pos"
) ")"
; ";"
else "else"
expression_statement
method_invocation
identifier "rf"
. "."
identifier "seek"
argument_list
( "("
identifier "pos"
) ")"
; ";"
} "}"
else "else"
expression_statement
assignment_expression
identifier "arrayInPtr"
= "="
identifier "pos"
; ";"
} "}"
method_declaration (+31 nodes collapsed)
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "getFilePointer"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
expression_statement
method_invocation
identifier "insureOpen"
argument_list
( "("
) ")"
; ";"
line_comment "// might call clearBack(), so call first"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "n"
= "="
ternary_expression
identifier "isBack"
? "?"
decimal_integer_literal "1"
: ":"
decimal_integer_literal "0"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "arrayIn"
== "=="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
binary_expression
cast_expression
( "("
integral_type
int "int"
) ")"
parenthesized_expression
( "("
ternary_expression
identifier "plainRandomAccess"
? "?"
method_invocation
identifier "trf"
. "."
identifier "getFilePointer"
argument_list
( "("
) ")"
: ":"
method_invocation
identifier "rf"
. "."
identifier "getFilePointer"
argument_list
( "("
) ")"
) ")"
- "-"
identifier "n"
- "-"
identifier "startOffset"
; ";"
} "}"
else "else"
return_statement
return "return"
binary_expression
binary_expression
identifier "arrayInPtr"
- "-"
identifier "n"
- "-"
identifier "startOffset"
; ";"
} "}"
method_declaration (+56 nodes collapsed)
method_declaration (+59 nodes collapsed)
method_declaration (+51 nodes collapsed)
method_declaration (+88 nodes collapsed)
block_comment "/**\n * Reads a signed 16-bit number from this stream in "...
method_declaration (+95 nodes collapsed)
method_declaration (+80 nodes collapsed)
block_comment "/**\n * Reads an unsigned 16-bit number from this stream "...
method_declaration (+87 nodes collapsed)
method_declaration (+88 nodes collapsed)
block_comment "/**\n * Reads a Unicode character from this stream in lit"...
method_declaration (+95 nodes collapsed)
method_declaration (+135 nodes collapsed)
block_comment "/**\n * Reads a signed 32-bit integer from this stream in"...
method_declaration (+142 nodes collapsed)
block_comment "/**\n * Reads an unsigned 32-bit integer from this stream"...
method_declaration (+142 nodes collapsed)
method_declaration (+142 nodes collapsed)
method_declaration (+50 nodes collapsed)
method_declaration (+64 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+31 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+31 nodes collapsed)
method_declaration (+212 nodes collapsed)
method_declaration (+25 nodes collapsed)
block_comment "/** Getter for property startOffset.\n * @return Value of"...
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "getStartOffset"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
field_access
this "this"
. "."
identifier "startOffset"
; ";"
} "}"
block_comment "/** Setter for property startOffset.\n * @param startOffs"...
method_declaration (+37 nodes collapsed)
block_comment "/**\n * @since 2.0.8\n */"
method_declaration
modifiers
public "public"
scoped_type_identifier
scoped_type_identifier
type_identifier "java"
. "."
type_identifier "nio"
. "."
type_identifier "ByteBuffer"
identifier "getNioByteBuffer"
formal_parameters
( "("
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "filename"
!= "!="
null_literal "null"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "FileChannel"
variable_declarator
identifier "channel"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
identifier "plainRandomAccess"
) ")"
expression_statement
assignment_expression
identifier "channel"
= "="
method_invocation
identifier "trf"
. "."
identifier "getChannel"
argument_list
( "("
) ")"
; ";"
else "else"
expression_statement
assignment_expression
identifier "channel"
= "="
method_invocation
identifier "rf"
. "."
identifier "getChannel"
argument_list
( "("
) ")"
; ";"
return_statement
return "return"
method_invocation
identifier "channel"
. "."
identifier "map"
argument_list
( "("
field_access
field_access
identifier "FileChannel"
. "."
identifier "MapMode"
. "."
identifier "READ_ONLY"
, ","
decimal_integer_literal "0"
, ","
method_invocation
identifier "channel"
. "."
identifier "size"
argument_list
( "("
) ")"
) ")"
; ";"
} "}"
return_statement
return "return"
method_invocation
field_access
field_access
identifier "java"
. "."
identifier "nio"
. "."
identifier "ByteBuffer"
. "."
identifier "wrap"
argument_list
( "("
identifier "arrayIn"
) ")"
; ";"
} "}"
} "}"