/** * Pushes the current stream position onto a stack of marked positions. * Note that {@code ChannelData} maintains its own marks - the buffer's * mark is left unchanged. */ @Override public final void mark() { mark = new Mark(getStreamPosition(), (byte) getBitOffset(), mark); }
/** * Creates a new reader for the data in an existing buffer. * The data will be read from the current buffer position to the buffer limit. * * @param filename a data source name, for error messages or debugging purpose. * @param data a buffer containing the data to read. * @throws IOException should never happen. */ public HyperRectangleReader(final String filename, final Buffer data) throws IOException { reader = new MemoryDataTransfer(filename, data).reader(); origin = 0; }
/** * Reads {@code length} integers from the stream, and stores them into * {@code dest} starting at index {@code offset}. * * @param dest an array of integers to be written to. * @param offset the starting position within {@code dest} to write. * @param length the number of integers to read. * @throws IOException if an error (including EOF) occurred while reading the stream. */ public final void readFully(final int[] dest, final int offset, final int length) throws IOException { new IntsReader(dest).readFully(null, offset, length); }
/** * Moves to the given position in the stream. */ @Override public final void seek(long n) throws IOException { ChannelDataInput.this.seek(n); }
/** * Writes a single bit. This method uses only the rightmost bit of the given argument; * the upper 31 bits are ignored. * * @param bit the bit to write (rightmost bit). * @throws IOException if an error occurred while creating the data output. */ public final void writeBit(final int bit) throws IOException { writeBits(bit, 1); }
/** * Reads {@code length} short integers from the stream, and stores them into * {@code dest} starting at index {@code offset}. * * @param dest An array of short integers to be written to. * @param offset The starting position within {@code dest} to write. * @param length The number of short integers to read. * @throws IOException if an error (including EOF) occurred while reading the stream. */ public final void readFully(final short[] dest, final int offset, final int length) throws IOException { new ShortsReader(dest).readFully(null, offset, length); }
/** * Returns the storage as a path if possible, or {@code null} otherwise. * * <p>This method is one of the {@link #OPENERS} methods and should be invoked at most once per * {@code StorageConnector} instance.</p> */ private String createString() { return IOUtilities.toString(storage); }
/** * Reads {@code length} characters from the stream, and stores them into * {@code dest} starting at index {@code offset}. * * @param dest An array of characters to be written to. * @param offset The starting position within {@code dest} to write. * @param length The number of characters to read. * @throws IOException if an error (including EOF) occurred while reading the stream. */ public final void readFully(final char[] dest, final int offset, final int length) throws IOException { new CharsReader(dest).readFully(null, offset, length); }
/** * Writes the specified byte to the output stream. * * @param b the byte to write. * @throws IOException if an I/O error occurs. */ @Override public void write(final int b) throws IOException { output.write(b); }
/** * Returns the filename extension from a {@link Path}, {@link File}, {@link URL}, {@link URI} or * {@link CharSequence} instance. If no extension is found, returns an empty string. If the given * object is of unknown type, return {@code null}. * * @param path the path as an instance of one of the above-cited types, or {@code null}. * @return the extension in the given path, or an empty string if none, or {@code null} * if the given object is null or of unknown type. */ public static String extension(final Object path) { return part(path, true); }
/** * Writes a single byte to the stream at the current position. * The 24 high-order bits of {@code v} are ignored. * * @param v an integer whose lower 8 bits are to be written. * @throws IOException if some I/O exception occurs during writing. */ @Override public final void write(final int v) throws IOException { writeByte(v); }
/** * Marks the current position in this output stream. */ @Override public void mark() { output.mark(); }
/** * Returns the current byte position of the stream. * * @return the position of the stream. * @throws IOException if the position can not be obtained. */ @Override public long getStreamPosition() throws IOException { return output.getStreamPosition(); }
/** * Reads {@code length} values from the buffer and stores them into the array known to subclass, * starting at index {@code offset}. * * @param view ignored. * @param offset the starting position within {@code dest} to write. * @param length the number of values to read. */ @Override public void readFully(final Buffer view, final int offset, final int length) { reader.transfer(offset, length); }
/** * Reads a single bit from the stream. The bit to be read depends on the * {@linkplain #getBitOffset() current bit offset}. * * @return the value of the next bit from the stream. * @throws IOException if an error occurred while reading (including EOF). */ public final int readBit() throws IOException { return (int) readBits(1); }
/** * Forces any buffered output bytes to be written out. * * @throws IOException if an I/O error occurs. */ @Override public void flush() throws IOException { output.flush(); }
/** * Synonymous of {@link #isCachedMemory()} since the caching behavior of this class is uniquely determined * by the policy that we choose for {@code isCachedMemory()}. This class never creates temporary files. * * @see #isCachedMemory() * @see #isCachedFile() */ @Override public final boolean isCached() { return isCachedMemory(); }
/** * Pushes the current stream position onto a stack of marked positions. * Note that {@code ChannelData} maintains its own marks - the buffer's * mark is left unchanged. */ @Override public final void mark() { mark = new Mark(getStreamPosition(), (byte) getBitOffset(), mark); }
/** * Writes the specified bytes to the output stream. * * @param b the bytes to write. * @throws IOException if an I/O error occurs. */ @Override public void write(final byte[] b) throws IOException { output.write(b); }
/** * Returns the filename from a {@link Path}, {@link File}, {@link URL}, {@link URI} or {@link CharSequence} * instance. If the given argument is specialized type like {@code Path} or {@code File}, then this method uses * dedicated API like {@link Path#getFileName()}. Otherwise this method gets a string representation of the path * and returns the part after the last {@code '/'} or platform-dependent name separator character, if any. * * @param path the path as an instance of one of the above-cited types, or {@code null}. * @return the filename in the given path, or {@code null} if the given object is null or of unknown type. */ public static String filename(final Object path) { return part(path, false); }