Beatmup Java package
Beatmup.Utils.ChunkCollection Class Reference

A key-value pair set storing pieces of arbitrary data (chunks) under string keys. More...

Inheritance diagram for Beatmup.Utils.ChunkCollection:
Beatmup.Object Beatmup.Utils.ChunkAsset Beatmup.Utils.ChunkFile

Public Member Functions

void open () throws IOError
 Opens the collection to read chunks from it. More...
 
void close ()
 Closes the collection after a reading session. More...
 
long size ()
 
boolean chunkExists (String id)
 Check if a specific chunk exists. More...
 
long chunkSize (String id)
 Retrieves size of a specific chunk. More...
 
String read (String id)
 Reads a chunk with a specific id and returns it as a string. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Beatmup.Object
synchronized void dispose ()
 Destroys the native object. More...
 
- Protected Attributes inherited from Beatmup.Object
long handle
 pointer to the native object More...
 

Detailed Description

A key-value pair set storing pieces of arbitrary data (chunks) under string keys.

A chunk is a header and a piece of data packed in memory like this: (idLength[4], id[idLength], size[sizeof(chunksize_t)], data[size]) ChunkCollection defines an interface to retrieve chunks by their ids.

Definition at line 30 of file ChunkCollection.java.

Member Function Documentation

◆ open()

void Beatmup.Utils.ChunkCollection.open ( ) throws IOError
inline

Opens the collection to read chunks from it.

Definition at line 46 of file ChunkCollection.java.

46  {
47  open(handle);
48  }
long handle
pointer to the native object
Definition: Object.java:25
void open()
Opens the collection to read chunks from it.

◆ close()

void Beatmup.Utils.ChunkCollection.close ( )
inline

Closes the collection after a reading session.

Definition at line 53 of file ChunkCollection.java.

53  {
54  close(handle);
55  }
void close()
Closes the collection after a reading session.

◆ size()

long Beatmup.Utils.ChunkCollection.size ( )
inline
Returns
number of chunks in the collection.

Definition at line 60 of file ChunkCollection.java.

60  {
61  return size(handle);
62  }

◆ chunkExists()

boolean Beatmup.Utils.ChunkCollection.chunkExists ( String  id)
inline

Check if a specific chunk exists.

Parameters
idThe chunk id
Returns
true if the chunk exists in the collection.

Definition at line 69 of file ChunkCollection.java.

69  {
70  return chunkExists(handle, id);
71  }

◆ chunkSize()

long Beatmup.Utils.ChunkCollection.chunkSize ( String  id)
inline

Retrieves size of a specific chunk.

Parameters
idThe chunk id
Returns
size of the chunk in bytes, 0 if not found.

Definition at line 78 of file ChunkCollection.java.

78  {
79  return chunkSize(handle, id);
80  }

◆ read()

String Beatmup.Utils.ChunkCollection.read ( String  id)
inline

Reads a chunk with a specific id and returns it as a string.

If there is no chunk with the given id, returns an empty string.

Parameters
idThe chunk id
Returns
the chunk content as string.

Definition at line 88 of file ChunkCollection.java.

88  {
89  return read(handle, id);
90  }

The documentation for this class was generated from the following file: