jdk/src/share/classes/java/nio/Heap-X-Buffer.java.template
author ohair
Wed, 28 Oct 2009 12:54:37 -0700
changeset 4115 e09be02771b6
parent 2593 jdk/src/share/classes/java/nio/Heap-X-Buffer.java@76032557be03
child 5506 202f599c92aa
permissions -rw-r--r--
6888701: Change all template java source files to a .java-template file suffix Reviewed-by: jjg, alanb, mr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1247
b4c26443dee5 6754988: Update copyright year
xdono
parents: 1224
diff changeset
     2
 * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#warn This file is preprocessed before being compiled
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
package java.nio;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * A read/write Heap$Type$Buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * A read-only Heap$Type$Buffer.  This class extends the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * read/write class, overriding the mutation methods to throw a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * ReadOnlyBufferException} and overriding the view-buffer methods to return an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * instance of this class rather than of the superclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
class Heap$Type$Buffer$RW$
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    extends {#if[ro]?Heap}$Type$Buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    // For speed these fields are actually declared in X-Buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    // these declarations are here as documentation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    protected final $type$[] hb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    protected final int offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    Heap$Type$Buffer$RW$(int cap, int lim) {            // package-private
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        super(-1, 0, lim, cap, new $type$[cap], 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        hb = new $type$[cap];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        offset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        super(cap, lim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        this.isReadOnly = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    Heap$Type$Buffer$RW$($type$[] buf, int off, int len) { // package-private
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        super(-1, off, off + len, buf.length, buf, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        hb = buf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        offset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        super(buf, off, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        this.isReadOnly = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    protected Heap$Type$Buffer$RW$($type$[] buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                                   int mark, int pos, int lim, int cap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                                   int off)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        super(mark, pos, lim, cap, buf, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        hb = buf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        offset = off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        super(buf, mark, pos, lim, cap, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        this.isReadOnly = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public $Type$Buffer slice() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        return new Heap$Type$Buffer$RW$(hb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                                        -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                                        0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                                        this.remaining(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                                        this.remaining(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                                        this.position() + offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public $Type$Buffer duplicate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return new Heap$Type$Buffer$RW$(hb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                        this.markValue(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                        this.position(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                                        this.limit(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                                        this.capacity(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                                        offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public $Type$Buffer asReadOnlyBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        return new Heap$Type$BufferR(hb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                                     this.markValue(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                                     this.position(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                                     this.limit(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                                     this.capacity(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                                     offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        return duplicate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    protected int ix(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        return i + offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public $type$ get() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        return hb[ix(nextGetIndex())];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public $type$ get(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        return hb[ix(checkIndex(i))];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public $Type$Buffer get($type$[] dst, int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        checkBounds(offset, length, dst.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (length > remaining())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            throw new BufferUnderflowException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        System.arraycopy(hb, ix(position()), dst, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        position(position() + length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public boolean isDirect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public boolean isReadOnly() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        return {#if[rw]?false:true};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public $Type$Buffer put($type$ x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        hb[ix(nextPutIndex())] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public $Type$Buffer put(int i, $type$ x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        hb[ix(checkIndex(i))] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public $Type$Buffer put($type$[] src, int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        checkBounds(offset, length, src.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        if (length > remaining())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            throw new BufferOverflowException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        System.arraycopy(src, offset, hb, ix(position()), length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        position(position() + length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    public $Type$Buffer put($Type$Buffer src) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (src instanceof Heap$Type$Buffer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            if (src == this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            Heap$Type$Buffer sb = (Heap$Type$Buffer)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            int n = sb.remaining();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            if (n > remaining())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                throw new BufferOverflowException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            System.arraycopy(sb.hb, sb.ix(sb.position()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                             hb, ix(position()), n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            sb.position(sb.position() + n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            position(position() + n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        } else if (src.isDirect()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            int n = src.remaining();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            if (n > remaining())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                throw new BufferOverflowException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            src.get(hb, ix(position()), n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            position(position() + n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            super.put(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public $Type$Buffer compact() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        System.arraycopy(hb, ix(position()), hb, ix(0), remaining());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        position(remaining());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        limit(capacity());
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 1247
diff changeset
   225
        discardMark();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
#if[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    byte _get(int i) {                          // package-private
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        return hb[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    void _put(int i, byte b) {                  // package-private
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        hb[i] = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    // char
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public char getChar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        return Bits.getChar(this, ix(nextGetIndex(2)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public char getChar(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        return Bits.getChar(this, ix(checkIndex(i, 2)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public $Type$Buffer putChar(char x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        Bits.putChar(this, ix(nextPutIndex(2)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public $Type$Buffer putChar(int i, char x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        Bits.putChar(this, ix(checkIndex(i, 2)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public CharBuffer asCharBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        int size = this.remaining() >> 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        int off = offset + position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        return (bigEndian
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                ? (CharBuffer)(new ByteBufferAsCharBuffer$RW$B(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                                                               -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                                                               0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                                                               size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                                                               size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                                                               off))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                : (CharBuffer)(new ByteBufferAsCharBuffer$RW$L(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                                                               -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                                                               0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                                                               size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                                                               size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                                                               off)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    // short
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    public short getShort() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        return Bits.getShort(this, ix(nextGetIndex(2)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    public short getShort(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        return Bits.getShort(this, ix(checkIndex(i, 2)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    public $Type$Buffer putShort(short x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        Bits.putShort(this, ix(nextPutIndex(2)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    public $Type$Buffer putShort(int i, short x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        Bits.putShort(this, ix(checkIndex(i, 2)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    public ShortBuffer asShortBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        int size = this.remaining() >> 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        int off = offset + position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        return (bigEndian
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                ? (ShortBuffer)(new ByteBufferAsShortBuffer$RW$B(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                                                                 -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                                                                 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                                                                 size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                                                                 size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                                                                 off))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                : (ShortBuffer)(new ByteBufferAsShortBuffer$RW$L(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                                                                 -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                                                                 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                                                                 size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                                                                 size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                                                                 off)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    // int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    public int getInt() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        return Bits.getInt(this, ix(nextGetIndex(4)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    public int getInt(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        return Bits.getInt(this, ix(checkIndex(i, 4)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public $Type$Buffer putInt(int x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        Bits.putInt(this, ix(nextPutIndex(4)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    public $Type$Buffer putInt(int i, int x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        Bits.putInt(this, ix(checkIndex(i, 4)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public IntBuffer asIntBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        int size = this.remaining() >> 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        int off = offset + position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        return (bigEndian
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                ? (IntBuffer)(new ByteBufferAsIntBuffer$RW$B(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                                                             -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                                                             0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                                                             size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                                                             size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                                                             off))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                : (IntBuffer)(new ByteBufferAsIntBuffer$RW$L(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                                                             -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                                                             0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                                                             size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                                                             size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                                                             off)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    // long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    public long getLong() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        return Bits.getLong(this, ix(nextGetIndex(8)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    public long getLong(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        return Bits.getLong(this, ix(checkIndex(i, 8)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    public $Type$Buffer putLong(long x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        Bits.putLong(this, ix(nextPutIndex(8)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public $Type$Buffer putLong(int i, long x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        Bits.putLong(this, ix(checkIndex(i, 8)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    public LongBuffer asLongBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        int size = this.remaining() >> 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        int off = offset + position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        return (bigEndian
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                ? (LongBuffer)(new ByteBufferAsLongBuffer$RW$B(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                                                               -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                                                               0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                                                               size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                                                               size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                                                               off))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                : (LongBuffer)(new ByteBufferAsLongBuffer$RW$L(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                                                               -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                                                               0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                                                               size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                                                               size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                                                               off)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    // float
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    public float getFloat() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        return Bits.getFloat(this, ix(nextGetIndex(4)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    public float getFloat(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        return Bits.getFloat(this, ix(checkIndex(i, 4)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    public $Type$Buffer putFloat(float x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        Bits.putFloat(this, ix(nextPutIndex(4)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    public $Type$Buffer putFloat(int i, float x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        Bits.putFloat(this, ix(checkIndex(i, 4)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    public FloatBuffer asFloatBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        int size = this.remaining() >> 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        int off = offset + position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        return (bigEndian
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                ? (FloatBuffer)(new ByteBufferAsFloatBuffer$RW$B(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                                                                 -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                                                                 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                                                                 size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                                                                 size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                                                                 off))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                : (FloatBuffer)(new ByteBufferAsFloatBuffer$RW$L(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                                                                 -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                                                                 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                                                                 size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                                                                 size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                                                                 off)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    // double
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    public double getDouble() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return Bits.getDouble(this, ix(nextGetIndex(8)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    public double getDouble(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        return Bits.getDouble(this, ix(checkIndex(i, 8)), bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    public $Type$Buffer putDouble(double x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        Bits.putDouble(this, ix(nextPutIndex(8)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    public $Type$Buffer putDouble(int i, double x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        Bits.putDouble(this, ix(checkIndex(i, 8)), x, bigEndian);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    public DoubleBuffer asDoubleBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        int size = this.remaining() >> 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        int off = offset + position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        return (bigEndian
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                ? (DoubleBuffer)(new ByteBufferAsDoubleBuffer$RW$B(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                                                                   -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                                                                   0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                                                                   size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                                                                   size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                                                                   off))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                : (DoubleBuffer)(new ByteBufferAsDoubleBuffer$RW$L(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                                                                   -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                                                                   0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                                                                   size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                                                                   size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                                                                   off)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
#end[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
#if[char]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    String toString(int start, int end) {               // package-private
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            return new String(hb, start + offset, end - start);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        } catch (StringIndexOutOfBoundsException x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            throw new IndexOutOfBoundsException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    // --- Methods to support CharSequence ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
1224
8c1bc7c5dd00 6733145: (bf) CharBuffer.subSequence can be updated to take advantage of covariant returns
martin
parents: 2
diff changeset
   570
    public CharBuffer subSequence(int start, int end) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        if ((start < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            || (end > length())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            || (start > end))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            throw new IndexOutOfBoundsException();
2593
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   575
        int pos = position();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        return new HeapCharBuffer$RW$(hb,
2593
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   577
                                      -1,
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   578
                                      pos + start,
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   579
                                      pos + end,
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   580
                                      capacity(),
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   581
                                      offset);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
#end[char]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
#if[!byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    public ByteOrder order() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        return ByteOrder.nativeOrder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
#end[!byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
}