RegisterSign In

API Documentation: Class JavaByteArray

Package: com.mckoi.data
implements com.mckoi.data.ByteArray

A ByteArray implementation backed by a Java byte array. In this implementation the 'compareTo' and 'equals' method use a lexicographic comparison.

Constructors Summary

JavaByteArray(byte[] buf, int offset, int len)
JavaByteArray(byte[] buf)

Methods Summary

byte getByteAt(int p)
int length()
DataInputStream getDataInputStream()
int compareTo(ByteArray o)
boolean equals(Object o)
String toString()

Constructor Details

JavaByteArray(byte[] buf, int offset, int len)

Constructs a JavaByteArray over a section of the given array. Note that the array is not copied in this constructor so care should be taken not to modify the array if it's not desirable that the content of this object is changed.

JavaByteArray(byte[] buf)

Constructs a JavaByteArray over the given array. Note that the array is not copied in this constructor so care should be taken not to modify the array if it's not desirable that the content of this object is changed.

Method Details

byte getByteAt(int p)

Returns the byte at position p.

int length()

Returns the size of the byte array.

DataInputStream getDataInputStream()

Returns a DataInputStream for reading the content of the array from the beginning.

int compareTo(ByteArray o)

Compares this byte array to the given byte array. This implementation is a lexicographic comparison that is implemented as follows; Start at byte index 0. If the byte in this array is greater than the byte in 'dest' then return 1. If it's less then return -1. If it's the same, repeat the test for the next byte. If there are no more bytes left to read in one of the arrays, return the length of this array minus the length of the array in 'dest'.

boolean equals(Object o)

See the 'compareTo' method for a description of the method used to check equality.

String toString()

Returns a string representation of this byte array as a list of byte values.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Oracle and/or its affiliates.
Mckoi is Copyright © 2000 - 2020 Diehl and Associates, Inc. All rights reserved.