org.jruby.util
Class ByteList

java.lang.Object
  extended by org.jruby.util.ByteList
All Implemented Interfaces:
java.io.Serializable, java.lang.CharSequence, java.lang.Comparable

public final class ByteList
extends java.lang.Object
implements java.lang.Comparable, java.lang.CharSequence, java.io.Serializable

Author:
headius
See Also:
Serialized Form

Field Summary
 int begin
           
 byte[] bytes
           
static ByteList EMPTY_BYTELIST
           
static byte[] NULL_ARRAY
           
 int realSize
           
 
Constructor Summary
ByteList()
          Creates a new instance of ByteList
ByteList(byte[] wrap)
           
ByteList(byte[] wrap, boolean copy)
           
ByteList(byte[] wrap, int index, int len)
           
ByteList(byte[] wrap, int index, int len, boolean copy)
           
ByteList(ByteList wrap)
           
ByteList(ByteList wrap, int index, int len)
           
ByteList(int size)
           
 
Method Summary
 ByteList append(byte b)
           
 void append(byte[] moreBytes)
           
 void append(byte[] moreBytes, int start, int len)
           
 void append(ByteList moreBytes)
           
 void append(ByteList moreBytes, int index, int len)
           
 ByteList append(int b)
           
 int begin()
           
 byte[] bytes()
           
 char charAt(int ix)
           
 java.lang.Object clone()
           
 int cmp(ByteList other)
           
 int compareTo(java.lang.Object other)
          This comparison matches MRI comparison of Strings (rb_str_cmp).
static ByteList create(java.lang.CharSequence s)
           
 void delete(int start, int len)
           
 ByteList dup()
           
 ByteList dup(int length)
           
 boolean equal(ByteList other)
           
 boolean equals(java.lang.Object other)
           
 int get(int index)
           
 int hashCode()
           
 int indexOf(ByteList find)
           
 int indexOf(ByteList find, int i)
           
 int indexOf(int c)
           
 int indexOf(int c, int pos)
           
 void insert(int index, int b)
           
 void invalidate()
           
 int lastIndexOf(ByteList find)
           
 int lastIndexOf(ByteList find, int pos)
           
 int lastIndexOf(int c)
           
 int lastIndexOf(int c, int pos)
           
 int length()
           
 void length(int newLength)
           
 ByteList makeShared(int index, int len)
           
static char[] plain(byte[] b)
           
static char[] plain(byte[] b, int start, int length)
           
static byte[] plain(char[] s)
           
static byte[] plain(java.lang.CharSequence s)
           
 void prepend(byte b)
           
 void realloc(int length)
           
 void replace(byte[] newBytes)
           
 void replace(int beg, int len, byte[] buf)
           
 void replace(int beg, int len, byte[] nbytes, int index, int count)
           
 void replace(int beg, int len, ByteList nbytes)
           
 boolean sample_equals(java.lang.Object other)
           
 void set(int index, int b)
           
 java.lang.CharSequence subSequence(int start, int end)
           
 java.lang.String toString()
          Remembers toString value, which is expensive for StringBuffer.
 java.lang.String toString(java.lang.String encoding)
           
 java.lang.String toUtf8String()
           
 byte[] unsafeBytes()
          Returns the internal byte array.
 void unsafeReplace(int beg, int len, byte[] buf)
          Unsafe version of replace(int,int,byte[]).
 void unsafeReplace(int beg, int len, byte[] nbytes, int index, int count)
          Unsafe version of replace(int,int,byte[],int,int).
 void unsafeReplace(int beg, int len, ByteList nbytes)
          Unsafe version of replace(int,int,ByteList).
 void unshare()
           
 void unshare(int length)
           
 void view(int index, int len)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL_ARRAY

public static final byte[] NULL_ARRAY

EMPTY_BYTELIST

public static final ByteList EMPTY_BYTELIST

bytes

public byte[] bytes

begin

public int begin

realSize

public int realSize
Constructor Detail

ByteList

public ByteList()
Creates a new instance of ByteList


ByteList

public ByteList(int size)

ByteList

public ByteList(byte[] wrap)

ByteList

public ByteList(byte[] wrap,
                boolean copy)

ByteList

public ByteList(ByteList wrap)

ByteList

public ByteList(byte[] wrap,
                int index,
                int len)

ByteList

public ByteList(byte[] wrap,
                int index,
                int len,
                boolean copy)

ByteList

public ByteList(ByteList wrap,
                int index,
                int len)
Method Detail

delete

public void delete(int start,
                   int len)

append

public ByteList append(byte b)

append

public ByteList append(int b)

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

dup

public ByteList dup()

dup

public ByteList dup(int length)

makeShared

public ByteList makeShared(int index,
                           int len)

view

public void view(int index,
                 int len)

unshare

public void unshare()

unshare

public void unshare(int length)

invalidate

public void invalidate()

prepend

public void prepend(byte b)

append

public void append(byte[] moreBytes)

append

public void append(ByteList moreBytes)

append

public void append(ByteList moreBytes,
                   int index,
                   int len)

append

public void append(byte[] moreBytes,
                   int start,
                   int len)

realloc

public void realloc(int length)

length

public int length()
Specified by:
length in interface java.lang.CharSequence

length

public void length(int newLength)

get

public int get(int index)

set

public void set(int index,
                int b)

replace

public void replace(byte[] newBytes)

unsafeReplace

public void unsafeReplace(int beg,
                          int len,
                          ByteList nbytes)
Unsafe version of replace(int,int,ByteList). The contract is that these unsafe versions will not make sure thet beg and len indices are correct.


unsafeReplace

public void unsafeReplace(int beg,
                          int len,
                          byte[] buf)
Unsafe version of replace(int,int,byte[]). The contract is that these unsafe versions will not make sure thet beg and len indices are correct.


unsafeReplace

public void unsafeReplace(int beg,
                          int len,
                          byte[] nbytes,
                          int index,
                          int count)
Unsafe version of replace(int,int,byte[],int,int). The contract is that these unsafe versions will not make sure thet beg and len indices are correct.


replace

public void replace(int beg,
                    int len,
                    ByteList nbytes)

replace

public void replace(int beg,
                    int len,
                    byte[] buf)

replace

public void replace(int beg,
                    int len,
                    byte[] nbytes,
                    int index,
                    int count)

insert

public void insert(int index,
                   int b)

indexOf

public int indexOf(int c)

indexOf

public int indexOf(int c,
                   int pos)

indexOf

public int indexOf(ByteList find)

indexOf

public int indexOf(ByteList find,
                   int i)

lastIndexOf

public int lastIndexOf(int c)

lastIndexOf

public int lastIndexOf(int c,
                       int pos)

lastIndexOf

public int lastIndexOf(ByteList find)

lastIndexOf

public int lastIndexOf(ByteList find,
                       int pos)

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

equal

public boolean equal(ByteList other)

sample_equals

public boolean sample_equals(java.lang.Object other)

compareTo

public int compareTo(java.lang.Object other)
This comparison matches MRI comparison of Strings (rb_str_cmp). I wish we had memcmp right now...

Specified by:
compareTo in interface java.lang.Comparable

cmp

public int cmp(ByteList other)

unsafeBytes

public byte[] unsafeBytes()
Returns the internal byte array. This is unsafe unless you know what you're doing. But it can improve performance for byte-array operations that won't change the array.

Returns:
the internal byte array

bytes

public byte[] bytes()

begin

public int begin()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Remembers toString value, which is expensive for StringBuffer.

Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object
Returns:
an ISO-8859-1 representation of the byte list

toUtf8String

public java.lang.String toUtf8String()

toString

public java.lang.String toString(java.lang.String encoding)
                          throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

create

public static ByteList create(java.lang.CharSequence s)

plain

public static byte[] plain(java.lang.CharSequence s)

plain

public static byte[] plain(char[] s)

plain

public static char[] plain(byte[] b,
                           int start,
                           int length)

plain

public static char[] plain(byte[] b)

charAt

public char charAt(int ix)
Specified by:
charAt in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Specified by:
subSequence in interface java.lang.CharSequence


Copyright © 2002-2007 JRuby Team. All Rights Reserved.