diff options
author | Brian Jones <cbj@gnu.org> | 2002-03-13 13:05:22 +0000 |
---|---|---|
committer | Brian Jones <cbj@gnu.org> | 2002-03-13 13:05:22 +0000 |
commit | 62f93952c1fbfa02bd9a204a85cf5df41adace86 (patch) | |
tree | a15ab8ee6538dfaf926b4901698842e50c0fd6ac /java/nio/ByteBuffer.java | |
parent | f0a25669f4c9be51680ffefe5967c0c47fbc7704 (diff) | |
download | classpath-62f93952c1fbfa02bd9a204a85cf5df41adace86.tar.gz |
* lib/gen_nio.sh.in: new file is renamed gen_nio.sh plus fixes
to make it work when building outside of the classpath directory
* lib/gen_nio.sh: removed file
* lib/.cvsignore: ignore gen_nio.sh
* configure.in: generate gen_nio.sh and nio related Makefiles
in OUTPUT. Revert comment out of check for libart_lgpl
* lib/Makefile.am: give gen_nio.sh some idea of the top_builddir
and make it a separate target, gennio, that must be manually
executed; the generated files will be part of CVS since they change
only when the source .cpp changes rather than due to a configuration
change
* java/nio/Makefile.am: new file
* java/nio/.cvsignore: new file
* java/nio/charset/Makefile.am: new file
* java/nio/charset/.cvsignore: new file
* java/nio/channels/Makefile.am: new file
* java/nio/channels/.cvsignore: new file
* java/nio/channels/spi/Makefile.am: new file
* java/nio/channels/spi/.cvsignore: new file
* gnu/java/nio/Makefile.am: new file
* gnu/java/nio/.cvsignore: new file
* java/nio/ShortBuffer.java: generated file
* java/nio/ByteBuffer.java: generated file
* java/nio/LongBuffer.java: generated file
* java/nio/IntBuffer.java: generated file
* java/nio/FloatBuffer.java: generated file
* java/nio/DoubleBuffer.java: generated file
* java/nio/CharBuffer.java: generated file
* gnu/java/nio/ShortBufferImpl.java: generated file
* gnu/java/nio/MappedShortFileBuffer.java: generated file
* gnu/java/nio/MappedLongFileBuffer.java: generated file
* gnu/java/nio/MappedIntFileBuffer.java: generated file
* gnu/java/nio/MappedFloatFileBuffer.java: generated file
* gnu/java/nio/MappedDoubleFileBuffer.java: generated file
* gnu/java/nio/MappedCharFileBuffer.java: generated file
* gnu/java/nio/MappedByteFileBuffer.java: generated file
* gnu/java/nio/LongBufferImpl.java: generated file
* gnu/java/nio/IntBufferImpl.java: generated file
* gnu/java/nio/FloatBufferImpl.java: generated file
* gnu/java/nio/DoubleBufferImpl.java: generated file
* gnu/java/nio/CharBufferImpl.java: generated file
* gnu/java/nio/ByteBufferImpl.java: generated file
Diffstat (limited to 'java/nio/ByteBuffer.java')
-rw-r--r-- | java/nio/ByteBuffer.java | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/java/nio/ByteBuffer.java b/java/nio/ByteBuffer.java new file mode 100644 index 000000000..7590b6f3c --- /dev/null +++ b/java/nio/ByteBuffer.java @@ -0,0 +1,157 @@ +package java.nio; +public abstract class ByteBuffer extends Buffer +{ + private ByteOrder endian = ByteOrder.BIG_ENDIAN; + public static ByteBuffer allocateDirect(int capacity) + { + ByteBuffer b = new gnu.java.nio. ByteBufferImpl(capacity, 0, capacity); + return b; + } + public static ByteBuffer allocate(int capacity) + { + ByteBuffer b = new gnu.java.nio. ByteBufferImpl(capacity, 0, capacity); + return b; + } + final public static ByteBuffer wrap(byte[] array, + int offset, + int length) + { + gnu.java.nio.ByteBufferImpl b = new gnu.java.nio. ByteBufferImpl(array, offset, length); + return b; + } + final public static ByteBuffer wrap(String a) + { + return wrap(a.getBytes(), 0, a.length()); + } + final public static ByteBuffer wrap(byte[] array) + { + return wrap(array, 0, array.length); + } + final public ByteBuffer get(byte[] dst, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + { + dst[i] = get(); + } + return this; + } + final public ByteBuffer get(byte[] dst) + { + return get(dst, 0, dst.length); + } + final public ByteBuffer put(ByteBuffer src) + { + while (src.hasRemaining()) + put(src.get()); + return this; + } + final public ByteBuffer put(byte[] src, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + put(src[i]); + return this; + } +public final ByteBuffer put(byte[] src) + { + return put(src, 0, src.length); + } +public final boolean hasArray() + { + return false; + } + public final byte[] array() + { + return null; + } + public final int arrayOffset() + { + return 0; + } + public int hashCode() + { + return super.hashCode(); + } + public boolean equals(Object obj) + { + if (obj instanceof ByteBuffer) + { + return compareTo(obj) == 0; + } + return false; + } + public int compareTo(Object ob) + { + ByteBuffer a = (ByteBuffer) ob; + if (a.remaining() != remaining()) + return 1; + if (! hasArray() || + ! a.hasArray()) + { + return 1; + } + int r = remaining(); + int i1 = pos; + int i2 = a.pos; + for (int i=0;i<r;i++) + { + int t = (int) (get(i1)- a.get(i2)); + if (t != 0) + { + return (int) t; + } + } + return 0; + } + public final ByteOrder order() + { + return endian; + } + public final ByteBuffer order(ByteOrder bo) + { + endian = bo; + return this; + } + public abstract byte get(); + public abstract java.nio. ByteBuffer put(byte b); + public abstract byte get(int index); + public abstract java.nio. ByteBuffer put(int index, byte b); + public abstract ByteBuffer compact(); + public abstract boolean isDirect(); + public abstract ByteBuffer slice(); + public abstract ByteBuffer duplicate(); + public abstract ByteBuffer asReadOnlyBuffer(); + public abstract ShortBuffer asShortBuffer(); + public abstract CharBuffer asCharBuffer(); + public abstract IntBuffer asIntBuffer(); + public abstract LongBuffer asLongBuffer(); + public abstract FloatBuffer asFloatBuffer(); + public abstract DoubleBuffer asDoubleBuffer(); + public abstract char getChar(); + public abstract ByteBuffer putChar(char value); + public abstract char getChar(int index); + public abstract ByteBuffer putChar(int index, char value); + public abstract short getShort(); + public abstract ByteBuffer putShort(short value); + public abstract short getShort(int index); + public abstract ByteBuffer putShort(int index, short value); + public abstract int getInt(); + public abstract ByteBuffer putInt(int value); + public abstract int getInt(int index); + public abstract ByteBuffer putInt(int index, int value); + public abstract long getLong(); + public abstract ByteBuffer putLong(long value); + public abstract long getLong(int index); + public abstract ByteBuffer putLong(int index, long value); + public abstract float getFloat(); + public abstract ByteBuffer putFloat(float value); + public abstract float getFloat(int index); + public abstract ByteBuffer putFloat(int index, float value); + public abstract double getDouble(); + public abstract ByteBuffer putDouble(double value); + public abstract double getDouble(int index); + public abstract ByteBuffer putDouble(int index, double value); +} |