commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r825413 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io: Reader.java Stream.java Streamable.java Syncable.java Writer.java
Date Thu, 15 Oct 2009 07:02:08 GMT
Author: mturk
Date: Thu Oct 15 07:02:07 2009
New Revision: 825413

URL: http://svn.apache.org/viewvc?rev=825413&view=rev
Log:
Add generic stream interfaces

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java
  (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java
  (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java
  (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java?rev=825413&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java
Thu Oct 15 07:02:07 2009
@@ -0,0 +1,260 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.commons.runtime.io;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import org.apache.commons.runtime.NioByteBuffer;
+import org.apache.commons.runtime.Pointer;
+import org.apache.commons.runtime.exception.ClosedDescriptorException;
+import org.apache.commons.runtime.exception.AsyncClosedDescriptorException;
+import org.apache.commons.runtime.exception.InvalidDescriptorException;
+import org.apache.commons.runtime.exception.TimeoutException;
+
+/**
+ * Reader interface.
+ */
+public interface Reader
+{
+
+    /**
+     * Returns the number of bytes that are available before this stream will
+     * block.
+     *
+     * @return the number of bytes available before blocking.
+     * @throws IOException
+     *             if an error occurs in this stream.
+     */
+    public int available()
+        throws IOException;
+
+    /**
+     * Reads a single byte from the current position in this stream and returns
+     * it as an integer in the range from 0 to 255. Returns {@code -1} if the
+     * end of the stream has been reached. If the stream is in blocking mode,
+     * it blocks until one byte has been read, the end of the stream is
+     * detected or an exception is thrown.
+     *
+     * @return The byte read or {@code -1} if the end of the stream has
+     *         been reached.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the read
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If read operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int read()
+        throws IOException;
+
+    /**
+     * Reads bytes from the current position in this stream and stores them
+     * in the byte array {@code buffer}.
+     * The maximum number of bytes read corresponds
+     * to the size of {@code buffer}. Blocks until at least one byte has been
+     * read if the stream is in blocking mode.
+     *
+     * @param buffer
+     *            The byte array in which to store the bytes read.
+     * @return The number of bytes actually read or {@code -1} if the end of
+     *         the stream has been reached.
+     *
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the read
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If read operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int read(byte[] buffer)
+        throws IOException;
+
+    /**
+     * Reads at most {@code count} bytes from the current position in this
+     * stream and stores them in the byte array {@code buffer} starting at
+     * {@code offset}. Blocks until {@code count} bytes have been read,
+     * the end of the stream is reached or an exception is thrown.
+     *
+     * @param buffer
+     *          The array in which to store the bytes read from this stream.
+     * @param offset
+     *          The initial position in {@code buffer} to store the bytes read
+     *          from this stream.
+     * @param count
+     *          The maximum number of bytes to store in {@code buffer}.
+     * @return The number of bytes actually read or {@code -1} if the end of
+     *         the stream has been reached.
+     *
+     * @throws IndexOutOfBoundsException
+     *          If {@code offset < 0} or {@code count < 0}, or if
+     *          {@code offset + count} is greater than the size of
+     *          {@code buffer}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the read
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If read operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int read(byte[] buffer, int offset, int count)
+        throws IndexOutOfBoundsException, IOException;
+
+    /**
+     * Reads bytes from the current position in this stream and stores them
+     * in the {@link Pointer} {@code pointer}.
+     * The maximum number of bytes read corresponds
+     * to the size of {@code pointer}. Blocks until at least one byte has been
+     * read if the stream is in blocking mode.
+     *
+     * @param pointer
+     *          The {@code Pointer} in which to store the bytes read.
+     * @return The number of bytes actually read or {@code -1} if the end of
+     *         the stream has been reached.
+     *
+     * @throws NullPointerException
+     *          If {@code pointer} is {@code null}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the read
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If read operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public long read(Pointer pointer)
+        throws NullPointerException, IOException;
+
+    /**
+     * Reads at most {@code count} bytes from the current position in
+     * this stream and stores them in the {@link Pointer} {@code pointer}
+     * starting at {@code offset}. Blocks until {@code count} bytes have
+     * been read, the end of the stream is reached or an exception is thrown.
+     *
+     * @param pointer
+     *          The {@code Pointer} in which to store the bytes read from
+     *          this file.
+     * @param offset
+     *          The initial position in {@code pointer} to store the bytes read
+     *          from this stream.
+     * @param count
+     *          The maximum number of bytes to store in {@code pointer}.
+     *
+     * @return The number of bytes actually read or {@code -1} if the end of
+     *         the stream has been reached.
+     *
+     * @throws NullPointerException
+     *          If {@code pointer} is {@code null}.
+     * @throws IndexOutOfBoundsException
+     *          If {@code offset < 0} or {@code count < 0}, or if
+     *          {@code offset + count} is greater than the size of
+     *          {@code buffer}.
+     * @throws ClosedDescriptorException
+     *          If this file is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the read
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If read operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public long read(Pointer pointer, long offset, long count)
+        throws NullPointerException, IndexOutOfBoundsException, IOException;
+
+    /**
+     * Reads bytes from the current position in this stream and stores them
+     * in the {@code ByteBuffer} {@code buffer}. The maximum number of bytes
+     * read corresponds to the size of {@code buffer}.
+     * Blocks until at least one byte has been read if the stream is in
+     * blocking mode.
+     * <p>
+     * {@code ByteBuffer} must be allocated using {@code allocatedirect()}
+     * or obtained from {@link NioByteBuffer}.
+     * </p>
+     *
+     * @param buffer
+     *          The {@code ByteBuffer} in which to store the bytes read.
+     * @return The number of bytes actually read or {@code -1} if the end of
+     *         the stream has been reached.
+     *
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the read
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If read operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int read(ByteBuffer buffer)
+        throws IOException;
+
+    /**
+     * Reads at most {@code count} bytes from the current position in this
+     * stream and stores them in the {@code ByteBuffer} {@code buffer}
+     * starting at {@code offset}.
+     * Blocks until {@code count} bytes have been read, the end of the stream
+     * is reached or an exception is thrown.
+     * <p>
+     * {@code ByteBuffer} must be allocated using {@code allocatedirect()}
+     * or obtained from {@link NioByteBuffer}.
+     * </p>
+     *
+     * @param buffer
+     *          The {@code ByteBuffer} in which to store the bytes read from
+     *          this stream.
+     * @param offset
+     *          The initial position in {@code buffer} to store the bytes read
+     *          from this stream.
+     * @param count
+     *          The maximum number of bytes to store in {@code buffer}.
+     *
+     * @return The number of bytes actually read or {@code -1} if the end of
+     *         the stream has been reached.
+     *
+     * @throws IndexOutOfBoundsException
+     *          If {@code offset < 0} or {@code count < 0}, or if
+     *          {@code offset + count} is greater than the size of
+     *          {@code buffer}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the read
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If read operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int read(ByteBuffer buffer, int offset, int count)
+        throws IndexOutOfBoundsException, IOException;
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java?rev=825413&r1=825412&r2=825413&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java
Thu Oct 15 07:02:07 2009
@@ -22,11 +22,20 @@
 import java.io.Flushable;
 import java.io.IOException;
 import java.io.SyncFailedException;
+import java.nio.ByteBuffer;
+import org.apache.commons.runtime.Descriptor;
+import org.apache.commons.runtime.Pointer;
+import org.apache.commons.runtime.exception.ClosedDescriptorException;
+import org.apache.commons.runtime.exception.AsyncClosedDescriptorException;
+import org.apache.commons.runtime.exception.InvalidDescriptorException;
+import org.apache.commons.runtime.exception.OverlappingFileLockException;
+import org.apache.commons.runtime.exception.TimeoutException;
 
 /**
- * I/O Stream interface.
+ * Bidirectional Stream.
  */
-public abstract class Stream implements Closeable, Flushable, Syncable
+public abstract class Stream
+    implements Streamable, Reader, Writer
 {
 
     /**
@@ -114,8 +123,9 @@
     /**
      * Reads a single byte from the current position in this stream and returns
      * it as an integer in the range from 0 to 255. Returns {@code -1} if the
-     * end of the file has been reached. Blocks until one byte has been read,
-     * the end of the file is detected or an exception is thrown.
+     * end of the stream has been reached. If the stream is in blocking mode,
+     * it blocks until one byte has been read, the end of the stream is
+     * detected or an exception is thrown.
      *
      * @return The byte read or {@code -1} if the end of the stream has
      *         been reached.

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java?rev=825413&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java
Thu Oct 15 07:02:07 2009
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.commons.runtime.io;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * The base class for bidirectional streams.
+ */
+public interface Streamable extends Closeable
+{
+
+    /**
+     * Test the end-of-stream indicator.
+     *
+     * @return {@code true} if end-of-stream was reached.
+     *
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public boolean eof()
+        throws IOException;
+
+    /**
+     * Test if {@code this} stream is valid.
+     *
+     * @return {@code true} if the stream represents a valid,
+     *         open file, socket, or other I/O object; {@code false} otherwise.
+     *
+     */
+    public boolean valid();
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java?rev=825413&r1=825412&r2=825413&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java
Thu Oct 15 07:02:07 2009
@@ -18,6 +18,7 @@
 
 package org.apache.commons.runtime.io;
 
+import java.io.Flushable;
 import java.io.IOException;
 import java.io.SyncFailedException;
 
@@ -30,17 +31,39 @@
  * is usually used for flushing object's metadata to the output device.
  *
  */
-public interface Syncable
+public interface Syncable extends Flushable
 {
 
     /**
-     * Ensures that data which is buffered within the underlying implementation
-     * is written out to the appropriate device before returning.
+     * Flush the underlying stream metadata.
+     * <p>
+     * {@code flush} transfers  all modified metadata of the stream object
+     * referred to by {@code this} stream to the disk device
+     * (or other storage device)  where  that  object resides.
+     * The call blocks until the device reports that the transfer has
+     * completed.
+     * </p>
      *
-     * @throws SyncFailedException
-     *              when the object cannot be flushed.
-     * @throws IOException
-     *              if an I/O error occurs.
+     * @throws SyncFailedException when the object cannot be flushed.
+     * @throws IOException if an I/O error occurs.
+     */
+    public void flush()
+        throws SyncFailedException, IOException;
+
+
+    /**
+     * Sync the underlying stream by writing any buffered data.
+     * <p>
+     * {@code sync} transfers  all  modified in-core data of the stream object
+     * referred to by {@code this} stream to the disk device
+     * (or other storage device)  where  that  object resides.
+     * The call blocks until the device reports that the transfer has
+     * completed.  It also flushes  metadata information associated with
+     * {@code this} Descriptor.
+     * </p>
+     *
+     * @throws SyncFailedException when the object cannot be synced.
+     * @throws IOException if an I/O error occurs.
      */
     public void sync()
         throws SyncFailedException, IOException;

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java?rev=825413&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java
Thu Oct 15 07:02:07 2009
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.commons.runtime.io;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import org.apache.commons.runtime.NioByteBuffer;
+import org.apache.commons.runtime.Pointer;
+import org.apache.commons.runtime.exception.ClosedDescriptorException;
+import org.apache.commons.runtime.exception.AsyncClosedDescriptorException;
+import org.apache.commons.runtime.exception.InvalidDescriptorException;
+import org.apache.commons.runtime.exception.OverlappingFileLockException;
+import org.apache.commons.runtime.exception.TimeoutException;
+
+/**
+ * Writer
+ */
+public interface Writer extends Syncable
+{
+
+    /**
+     * Writes a byte to this stream, starting at the current file pointer.
+     * Only the least significant byte of the integer {@code b} is written.
+     *
+     * @param b
+     *          the byte to write to this stream.
+     *
+     * @return The number of bytes actually written.
+     *
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the read
+     *             operation is in progress.
+     * @throws TimeoutException
+     *          If write operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int write(int b)
+        throws IOException;
+
+    /**
+     * Writes {@code count} bytes from the byte array {@code buffer} to this
+     * stream, starting at the current file pointer and using {@code offset}
+     * as the first position within {@code buffer} to get bytes.
+     *
+     * @param buffer
+     *          The buffer to write to this stream.
+     * @param offset
+     *          The index of the first byte in {@code buffer} to write.
+     * @param count
+     *            The number of bytes from {@code buffer} to write.
+     * @return The number of bytes actually written.
+     *
+     * @throws IndexOutOfBoundsException
+     *          If {@code offset < 0} or {@code count < 0}, or if
+     *          {@code offset + count} is greater than the size of
+     *          {@code buffer}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the write
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If write operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int write(byte[] buffer, int offset, int count)
+        throws IndexOutOfBoundsException, IOException;
+
+    /**
+     * Writes the entire contents of the {@link Pointer} {@code pointer} to
+     * this stream, starting at the current stream position.
+     *
+     * @param pointer
+     *          The {@link Pointer} to write.
+     * @return The number of bytes actually written.
+     *
+     * @throws NullPointerException
+     *          If {@code pointer} is {@code null}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this sream while the write
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If write operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public long write(Pointer pointer)
+        throws NullPointerException, IOException;
+
+    /**
+     * Writes {@code count} bytes from the {@link Pointer} {@code pointer}
+     * to this stream, starting at the current stream position and
+     * using {@code offset} as the first position within
+     * {@code pointer} to get bytes.
+     *
+     * @param pointer
+     *          The {@code Pointer} to write to this stream.
+     * @param offset
+     *          The index of the first byte in {@code pointer} to write.
+     * @param count
+     *            The number of bytes from {@code pointer} to write.
+     * @return The number of bytes actually written.
+     *
+     * @throws NullPointerException
+     *          If {@code pointer} is {@code null}.
+     * @throws IndexOutOfBoundsException
+     *          If {@code offset < 0} or {@code count < 0}, or if
+     *          {@code offset + count} is greater than the size of
+     *          {@code pointer}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the write
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If write operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public long write(Pointer pointer, int offset, int count)
+        throws IndexOutOfBoundsException, IOException;
+
+    /**
+     * Writes the entire contents of the {@code ByteBuffer} {@code buffer}
+     * to this stream, starting at the current stream position.
+     * <p>
+     * {@code ByteBuffer} must be allocated using {@code allocatedirect()}
+     * or obtained from {@link NioByteBuffer}.
+     * </p>
+     *
+     * @param buffer
+     *          The {@code ByteBuffer} to write.
+     * @return The number of bytes actually written.
+     *
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the write
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If write operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int write(ByteBuffer buffer)
+        throws IOException;
+
+    /**
+     * Writes {@code count} bytes from the {@code ByteBuffer} {@code buffer}
+     * to this stream, starting at the current stream position and
+     * using {@code offset} as the first position within {@code buffer}
+     * to get bytes.
+     * <p>
+     * {@code ByteBuffer} must be allocated using {@code allocatedirect()}
+     * or obtained from {@link NioByteBuffer}.
+     * </p>
+     *
+     * @param buffer
+     *          The {@code ByteBuffer} to write to this stream.
+     * @param offset
+     *          The index of the first byte in {@code buffer} to write.
+     * @param count
+     *          The number of bytes from {@code buffer} to write.
+     * @return The number of bytes actually written.
+     *
+     * @throws IndexOutOfBoundsException
+     *          If {@code offset < 0} or {@code count < 0}, or if
+     *          {@code offset + count} is greater than the size of
+     *          {@code buffer}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the write
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If write operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int write(ByteBuffer buffer, int offset, int count)
+        throws IndexOutOfBoundsException, IOException;
+
+    /**
+     * Writes {@code count} arrays from the array of byte arrays {@code array}
+     * to this stream, starting at the current stream pointer and using
+     * {@code offset} as the first position within {@code array} to get bytes.
+     *
+     * @param array
+     *          The array of buffer arrays to write to this stream.
+     * @param offset
+     *          The index of the first array in {@code array} to write.
+     * @param count
+     *          The number of arrays from {@code array} to write.
+     *
+     * @throws IndexOutOfBoundsException
+     *          if {@code count < 0}, {@code offset < 0} or
+     *          {@code count + offset} is greater than the size of
+     *          {@code array}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the write
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If write operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public long write(byte[][] array, int offset, int count)
+        throws IndexOutOfBoundsException, IOException;
+
+    /**
+     * Writes {@code count} arrays from the {@code ByteBuffer} {@code array}
+     * to this stream, starting at the current stream position and using
+     * {@code offset} as the first position within {@code array} to get bytes.
+     *
+     * @param array
+     *          The {@code ByteBuffer} array to write to this stream.
+     * @param offset
+     *          The index of the first array in {@code array} to write.
+     * @param count
+     *          The number of arrays from {@code array} to write.
+     * @throws IndexOutOfBoundsException
+     *          if {@code count < 0}, {@code offset < 0} or
+     *          {@code count + offset} is greater than the size of
+     *          {@code array}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws AsyncClosedDescriptorException
+     *          If another thread closes this stream while the write
+     *          operation is in progress.
+     * @throws TimeoutException
+     *          If write operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public long write(ByteBuffer[] array, int offset, int count)
+        throws IndexOutOfBoundsException, IOException;
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message