XrefInputStream.java revision 1384
0N/A * The contents of this file are subject to the terms of the 0N/A * Common Development and Distribution License (the "License"). 0N/A * You may not use this file except in compliance with the License. 0N/A * language governing permissions and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL HEADER in each 0N/A * If applicable, add the following below this CDDL HEADER, with the 0N/A * fields enclosed by brackets "[]" replaced with your own identifying 0N/A * information: Portions Copyright [yyyy] [name of copyright owner] 388N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 388N/A * Portions Copyright 2012 Jens Elkner. 0N/A * A {@link FilterInputStream} for Opengrok crossfiles. 0N/A * It uses a {@link BufferedInputStream} or {@link GZIPInputStream} as 0N/A * underlying stream to provide the required functionality. 0N/A * @see BufferedInputStream 0N/A * @see GZIPInputStream 0N/A * @author Jens Elkner 0N/A * @version $Revision$ 0N/A * Create a new InputStream from the given crossfile. The header gets read 0N/A * automatically and thus internal cursor points to the start of the data 0N/A * section of the crossfile, when this method returns. 0N/A * @param file file to read. 0N/A * @param uncompress if {@code true} crossfile data gets uncompressed on 344N/A * the fly if they are compressed. 421N/A * @throws IOException on read error or if the given file is not a crossfile 0N/A * Get the header of the crossfile beeing read. 0N/A * @return the crossfile header 0N/A * Convinience method to check, whether the wrapped crossfile contains 0N/A * @return {@code true} if data section is compressed. 0N/A * @see XrefHeader#isCompressed() 0N/A * Convinience method to get the Genre of data provided by this stream. 0N/A * @return the data's genre. 0N/A * @see XrefHeader#getGenre() 0N/A * Get the file from which this stream has been created. 388N/A * @return the origin of this stream 0N/A * Dump all data not yet read to the given output stream. 0N/A * @param out where to dump remaining data. 0N/A * @throws IOException 14N/A * Dump all data not yet read to the given writer. The constructor for this 14N/A * instance should have been called with on-the-fly uncompression enabled. 345N/A * If not and the data of the stream are compressed, it is tried to switch 338N/A * over to on-the-fly uncompression, but obviously this will fail with an 338N/A * IOException, if any data have been read from this stream already. 338N/A * @param out where to write data. 338N/A * @throws IOException on read error 338N/A * @see XrefInputStream#XrefInputStream(File, boolean) 345N/A +
file +
" (wasn't specified in constructor)");
0N/A char[]
buf =
new char[
4096];
// underlying buffers are suffient 0N/A canClose =
false;
// avoid that isr.close() closes in as well 0N/A * Convinience method to dump a crossfile to the given writer.. 0N/A * @param file crossfile to dump. 0N/A * @param out dump destination. 0N/A * @param script if {@code true} the javascript snippet 0N/A * {@code O.lines=$num; O.createLinenums();} gets emitted to the writer 0N/A * @return {@code true} on success. 0N/A * Dump an opengrok cross file. 0N/A * @param args opengrok crossfile name