Package com.unascribed.ears.api
Class Slice
java.lang.Object
com.unascribed.ears.api.Slice
An immutable view into a byte array.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanequals(byte[] bys) booleanequals(byte[] bys, int ofs, int len) booleanbyteget(int idx) inthashCode()static byte[]of(byte[] arr, int ofs, int len) static SliceConvenience method to construct a Slice from a readable literal.intsize()slice(int offset) slice(int offset, int length) byte[]toString()voidwriteTo(OutputStream os)
-
Field Details
-
EMPTY
-
-
Constructor Details
-
Slice
public Slice(byte[] arr) -
Slice
public Slice(byte[] arr, int ofs, int len)
-
-
Method Details
-
get
public byte get(int idx) -
size
public int size() -
slice
-
slice
-
toByteArray
public byte[] toByteArray() -
writeTo
- Throws:
IOException
-
hashCode
public int hashCode() -
equals
-
equals
public boolean equals(byte[] bys) -
equals
public boolean equals(byte[] bys, int ofs, int len) -
toString
-
of
public static byte[] of(byte[] arr, int ofs, int len) -
parse
Convenience method to construct a Slice from a readable literal. Not intended for data parsing - no validation is performed and various errors can be thrown by this method for malformed data.The format is simple; every pair of characters is interpreted as a hex byte, and any chars between square brackets ([ and ]) have their lower 8 bits passed through as-is. For example:
89[PNG\r\n]1A[\n]
will become
89 50 4E 47 0D 0A 1A 0A | .PNG....
-