]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/icu/impl/ByteBuffer.java
go
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / icu / impl / ByteBuffer.java
1 //##header J2SE15
2 //#if defined(FOUNDATION10) || defined(J2SE13) || defined(ECLIPSE_FRAGMENT)
3 //##/*
4 //## * *****************************************************************************
5 //## * Copyright (C) 2006-2009, International Business Machines
6 //## * Corporation and others. All Rights Reserved.
7 //## * *****************************************************************************
8 //## */
9 //##// dlf13 internal 1.3 compatibility only
10 //##
11 //##package com.ibm.icu.impl;
12 //##
13 //##/**
14 //## * @internal
15 //## */
16 //##public final class ByteBuffer {
17 //##    private byte[] data;
18 //##
19 //##    private int pos;
20 //##
21 //##    private int limit;
22 //##
23 //##    private ByteBuffer() {
24 //##    }
25 //##
26 //##    public byte[] array() {
27 //##        byte[] result = new byte[limit];
28 //##        for (int i = 0; i < limit; ++i) {
29 //##            result[i] = data[i];
30 //##        }
31 //##        return result;
32 //##    }
33 //##
34 //##    public static ByteBuffer wrap(byte[] data) {
35 //##        if (data == null)
36 //##            throw new NullPointerException();
37 //##        ByteBuffer result = new ByteBuffer();
38 //##        result.data = data;
39 //##        result.pos = 0;
40 //##        result.limit = data.length;
41 //##        return result;
42 //##    }
43 //##
44 //##    public int limit() {
45 //##        return limit;
46 //##    }
47 //##
48 //##    public int position() {
49 //##        return pos;
50 //##    }
51 //##
52 //##    public int remaining() {
53 //##        return limit - pos;
54 //##    }
55 //##
56 //##    public byte get() {
57 //##        if (pos < limit)
58 //##            return data[pos++];
59 //##        throw new IndexOutOfBoundsException();
60 //##    }
61 //##
62 //##    public void get(byte[] dst, int offset, int length) {
63 //##        if (offset < 0 || offset + length > dst.length || pos + length > limit) {
64 //##            throw new IndexOutOfBoundsException();
65 //##        }
66 //##        for (int i = 0; i < length; ++i) {
67 //##            dst[offset++] = data[pos++];
68 //##        }
69 //##    }
70 //##
71 //##    public void put(byte b) {
72 //##        if (pos < limit) {
73 //##            data[pos++] = b;
74 //##        } else {
75 //##            throw new IndexOutOfBoundsException();
76 //##        }
77 //##    }
78 //##
79 //##    public void put(byte[] src, int offset, int length) {
80 //##        if (offset < 0 || offset + length > src.length || pos + length > limit) {
81 //##            throw new IndexOutOfBoundsException();
82 //##        }
83 //##        for (int i = offset; i < offset + length; i++) {
84 //##            put(src[i]);
85 //##        }
86 //##    }
87 //##
88 //##    public void put(byte[] src) {
89 //##        put(src, 0, src.length);
90 //##    }
91 //##
92 //##    public static final ByteBuffer allocate(int size){
93 //##        ByteBuffer ret = new ByteBuffer();
94 //##        ret.data = new byte[size];
95 //##        ret.pos = 0;
96 //##        ret.limit = size;
97 //##        return ret;
98 //##    }
99 //##}
100 //#endif