FileDocCategorySizeDatePackage
UnsafeByteSequence.javaAPI DocAndroid 5.1 API2479Thu Mar 12 22:22:44 GMT 2015com.android.tools.layoutlib.java

UnsafeByteSequence

public class UnsafeByteSequence extends Object
Defines the same class as the java.lang.UnsafeByteSequence which was added in Dalvik VM. This hack, provides a replacement for that class which can't be loaded in the standard JVM since it's in the java package and standard JVM doesn't have it.

Extracted from API level 18, file: platform/libcore/luni/src/main/java/java/lang/UnsafeByteSequence.java

Fields Summary
private byte[]
bytes
private int
count
Constructors Summary
public UnsafeByteSequence(int initialCapacity)

        this.bytes = new byte[initialCapacity];
    
Methods Summary
public voidrewind()
Moves the write pointer back to the beginning of the sequence, but without resizing or reallocating the buffer.

        count = 0;
    
public intsize()

        return count;
    
public byte[]toByteArray()

        if (count == bytes.length) {
            return bytes;
        }
        byte[] result = new byte[count];
        System.arraycopy(bytes, 0, result, 0, count);
        return result;
    
public java.lang.StringtoString(java.nio.charset.Charset cs)

        return new String(bytes, 0, count, cs);
    
public voidwrite(byte[] buffer, int offset, int length)

        if (count + length >= bytes.length) {
            byte[] newBytes = new byte[(count + length) * 2];
            System.arraycopy(bytes, 0, newBytes, 0, count);
            bytes = newBytes;
        }
        System.arraycopy(buffer, offset, bytes, count, length);
        count += length;
    
public voidwrite(int b)

        if (count == bytes.length) {
            byte[] newBytes = new byte[count * 2];
            System.arraycopy(bytes, 0, newBytes, 0, count);
            bytes = newBytes;
        }
        bytes[count++] = (byte) b;