public final class TypeChunk extends Chunk
PackageChunk. The resource values in this chunk correspond to
the array of type strings in the enclosing PackageChunk.
A PackageChunk can have multiple of these chunks for different
(configuration, resource type) combinations.
| Modifier and Type | Class and Description |
|---|---|
static class |
TypeChunk.Entry
An
TypeChunk.Entry in a TypeChunk. |
Chunk.TypechunkSize, headerSize, METADATA_SIZE, offset, PAD_BOUNDARY| Modifier | Constructor and Description |
|---|---|
protected |
TypeChunk(java.nio.ByteBuffer buffer,
Chunk parent) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsResource(BinaryResourceIdentifier resourceId)
Returns true if this chunk contains an entry for
resourceId. |
BinaryResourceConfiguration |
getConfiguration()
Returns the resource configuration that these resource entries correspond to.
|
java.util.Map<java.lang.Integer,TypeChunk.Entry> |
getEntries()
Returns a sparse list of 0-based indices to resource entries defined by this chunk.
|
int |
getId()
Returns the (1-based) type id of the resource types that this
TypeChunk is holding. |
protected java.lang.String |
getKeyName(int index) |
PackageChunk |
getPackageChunk()
Returns the package enclosing this chunk, if any.
|
protected java.lang.String |
getString(int index) |
int |
getTotalEntryCount()
Returns the total number of entries for this type + configuration, including null entries.
|
protected Chunk.Type |
getType() |
java.lang.String |
getTypeName()
Returns the name of the type this chunk represents (e.g.
|
protected void |
init(java.nio.ByteBuffer buffer)
Finishes initialization of a chunk.
|
void |
overrideEntries(java.util.Map<java.lang.Integer,TypeChunk.Entry> entries)
Overrides the entries in this chunk at the given index:entry pairs in
entries. |
void |
overrideEntry(int index,
TypeChunk.Entry entry)
Overrides an entry at the given index.
|
void |
setConfiguration(BinaryResourceConfiguration configuration)
Sets the resource configuration that this chunk's entries correspond to.
|
protected void |
writeHeader(java.nio.ByteBuffer output)
Writes the remaining header (after the type,
headerSize, and chunkSize). |
protected void |
writePayload(java.io.DataOutput output,
java.nio.ByteBuffer header,
boolean shrink)
Writes the chunk payload.
|
getHeaderSize, getOriginalChunkSize, getParent, newInstance, newInstance, toByteArray, toByteArray, writeHeader, writePadprotected TypeChunk(java.nio.ByteBuffer buffer,
@Nullable
Chunk parent)
protected void init(java.nio.ByteBuffer buffer)
Chunkpublic int getId()
TypeChunk is holding.public java.lang.String getTypeName()
public BinaryResourceConfiguration getConfiguration()
public void setConfiguration(BinaryResourceConfiguration configuration)
configuration - The new configuration.public int getTotalEntryCount()
public java.util.Map<java.lang.Integer,TypeChunk.Entry> getEntries()
public boolean containsResource(BinaryResourceIdentifier resourceId)
resourceId.public void overrideEntries(java.util.Map<java.lang.Integer,TypeChunk.Entry> entries)
entries.
For example, if the current list of entries is {0: foo, 1: bar, 2: baz}, and entries
is {1: qux, 3: quux}, then the entries will be changed to {0: foo, 1: qux, 2: baz}. If an entry
has an index that does not exist in the dense entry list, then it is considered a no-op for
that single entry.entries - A sparse list containing index:entry pairs to override.public void overrideEntry(int index,
@Nullable
TypeChunk.Entry entry)
entry will remove that
entry from entries. Indices < 0 or >= getTotalEntryCount() are a no-op.index - The 0-based index for the entry to override.entry - The entry to override, or null if the entry should be removed at this location.protected java.lang.String getString(int index)
protected java.lang.String getKeyName(int index)
@Nullable public PackageChunk getPackageChunk()
protected Chunk.Type getType()
protected void writeHeader(java.nio.ByteBuffer output)
ChunkheaderSize, and chunkSize).writeHeader in class Chunkoutput - The buffer that the header will be written to.protected void writePayload(java.io.DataOutput output,
java.nio.ByteBuffer header,
boolean shrink)
throws java.io.IOException
ChunkheaderSize bytes of the chunk.writePayload in class Chunkoutput - The stream that the payload will be written to.header - The already-written header. This can be modified to fix payload offsets.shrink - True if this payload should be optimized for size.java.io.IOException - Thrown if output could not be written to (out of memory).