Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Official ZPE/YASS documentationByteList

Introduction

The ByteList object provides a wrapper around a native byte array.

It is typically used internally by ZPE when working with binary data (for example, file input/output or network streams), but it can also be used directly to inspect or retrieve individual byte values.

The object stores raw bytes internally and exposes simple methods for:

  • Retrieving the length of the byte array
  • Accessing a specific byte by index
  • Converting the internal byte array into a standard YASS list

All functions exposed by this object require a permission level of 0.

ByteList object functions

The following is a list of internal functions the ByteList object exposes. All functions are ZPEObjectNativeFunctions therefore run in native code.

Returns the internal byte array as a standard YASS list of numbers. Each element in the returned list represents one byte.
length() ⇒ number
Returns the number of bytes stored in the object.
get(number index) ⇒ number
Returns the byte value at the specified index. The index must be within bounds of the internal array.

Examples

In most cases, ByteList objects are created internally (for example by file or network operations). Once obtained, you can inspect the data as follows:

YASS
# Assume $bytes is a ByteList returned from a file read operation

print("Length: " + $bytes->length())

# Get first byte
print($bytes->get(0))

# Convert to standard YASS list
$list = $bytes->print_list()

print($list)

Notes:

  • Indexing: Indexing is zero-based.
  • Signed bytes: Java bytes are signed (-128 to 127). If you are working with raw binary formats, be aware of this when interpreting values.
  • Internal use: The ByteList object is primarily designed as a bridge between Java byte arrays and YASS list structures.
Comments

There are no comments on this page.

New comment

Comments are welcome and encouraged, including disagreement and critique. However, this is not a space for abuse. Disagreement is welcome; personal attacks, harassment, or hate will be removed instantly. This site reflects personal opinions, not universal truths. If you can’t distinguish between the two, this probably isn’t the place for you. The system temporarily stores IP addresses and browser user agents for the purposes of spam prevention, moderation, and safeguarding. This data is automatically removed after fourteen days. Your email address is stored so that replies can be sent to your email address.

Comments powered by BalfComment

Feedback 👍
Comments are sent via email to me.