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