aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java/nio/PipeImpl.java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2004-03-11 08:49:29 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2004-03-11 08:49:29 +0000
commit5ea438861cb646ef0c53fc0dddabe7e54570b30f (patch)
treebefaa48b2acf3cd009315ce55f2ad54e64f92b71 /libjava/gnu/java/nio/PipeImpl.java
parent9a282e8e59e3ee125288b87a914ad0f68b48e024 (diff)
downloadgcc-5ea438861cb646ef0c53fc0dddabe7e54570b30f.zip
gcc-5ea438861cb646ef0c53fc0dddabe7e54570b30f.tar.gz
gcc-5ea438861cb646ef0c53fc0dddabe7e54570b30f.tar.bz2
2004-03-11 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/PipeImpl.java (SourceChannelImpl): Made final. (read): Implemented. (SinkChannelImpl): Made final. (write): Implemented. From-SVN: r79315
Diffstat (limited to 'libjava/gnu/java/nio/PipeImpl.java')
-rw-r--r--libjava/gnu/java/nio/PipeImpl.java41
1 files changed, 32 insertions, 9 deletions
diff --git a/libjava/gnu/java/nio/PipeImpl.java b/libjava/gnu/java/nio/PipeImpl.java
index da608d2..b9a343c 100644
--- a/libjava/gnu/java/nio/PipeImpl.java
+++ b/libjava/gnu/java/nio/PipeImpl.java
@@ -1,5 +1,5 @@
/* PipeImpl.java --
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,7 @@ import java.nio.channels.spi.SelectorProvider;
class PipeImpl extends Pipe
{
- public final class SourceChannelImpl extends Pipe.SourceChannel
+ public static final class SourceChannelImpl extends Pipe.SourceChannel
{
private int native_fd;
@@ -79,10 +79,22 @@ class PipeImpl extends Pipe
return read (srcs, 0, srcs.length);
}
- public final long read (ByteBuffer[] srcs, int offset, int len)
+ public synchronized final long read (ByteBuffer[] srcs, int offset, int len)
throws IOException
{
- throw new Error ("Not implemented");
+ if (offset < 0
+ || offset > srcs.length
+ || len < 0
+ || len > srcs.length - offset)
+ throw new IndexOutOfBoundsException();
+
+ long bytesRead = 0;
+
+ for (int index = 0; index < len; index++)
+ bytesRead += read (srcs [offset + index]);
+
+ return bytesRead;
+
}
public final int getNativeFD()
@@ -91,7 +103,7 @@ class PipeImpl extends Pipe
}
}
- public final class SinkChannelImpl extends Pipe.SinkChannel
+ public static final class SinkChannelImpl extends Pipe.SinkChannel
{
private int native_fd;
@@ -120,16 +132,27 @@ class PipeImpl extends Pipe
throw new Error ("Not implemented");
}
- public final long write (ByteBuffer[] dsts)
+ public final long write (ByteBuffer[] srcs)
throws IOException
{
- return write (dsts, 0, dsts.length);
+ return write (srcs, 0, srcs.length);
}
- public final long write (ByteBuffer[] dsts, int offset, int len)
+ public synchronized final long write (ByteBuffer[] srcs, int offset, int len)
throws IOException
{
- throw new Error ("Not implemented");
+ if (offset < 0
+ || offset > srcs.length
+ || len < 0
+ || len > srcs.length - offset)
+ throw new IndexOutOfBoundsException();
+
+ long bytesWritten = 0;
+
+ for (int index = 0; index < len; index++)
+ bytesWritten += write (srcs [offset + index]);
+
+ return bytesWritten;
}
public final int getNativeFD()