Class PackageChunk
- java.lang.Object
-
- com.google.devrel.gmscore.tools.apk.arsc.Chunk
-
- com.google.devrel.gmscore.tools.apk.arsc.ChunkWithChunks
-
- com.google.devrel.gmscore.tools.apk.arsc.PackageChunk
-
- All Implemented Interfaces:
SerializableResource
public final class PackageChunk extends ChunkWithChunks
A package chunk is a collection of resource data types within a package.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.devrel.gmscore.tools.apk.arsc.Chunk
Chunk.Type
-
-
Field Summary
-
Fields inherited from class com.google.devrel.gmscore.tools.apk.arsc.Chunk
chunkSize, headerSize, METADATA_SIZE, offset, PAD_BOUNDARY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPackageChunk(java.nio.ByteBuffer buffer, Chunk parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetId()Returns the package id if this is a base package, or 0 if not a base package.StringPoolChunkgetKeyStringPool()Returns the string pool that contains the names of the resources in this package.java.lang.StringgetPackageName()Returns the name of this package.protected Chunk.TypegetType()java.util.Collection<TypeChunk>getTypeChunks()Returns allTypeChunkin this package.java.util.Collection<TypeChunk>getTypeChunks(int id)For a given type id, returns theTypeChunkobjects that match that id.java.util.Collection<TypeChunk>getTypeChunks(java.lang.String type)For a given type, returns theTypeChunkobjects that match that type (e.g.TypeSpecChunkgetTypeSpecChunk(int id)For a given (1-based) type id, returns theTypeSpecChunkmatching it.TypeSpecChunkgetTypeSpecChunk(java.lang.String type)For a giventype, returns theTypeSpecChunkthat matches it (e.g.java.util.Collection<TypeSpecChunk>getTypeSpecChunks()Returns allTypeSpecChunkin this package.StringPoolChunkgetTypeStringPool()Returns the string pool that contains the type strings for this package, such as "layout", "string", "color".protected voidinit(java.nio.ByteBuffer buffer)Finishes initialization of a chunk.protected voidwriteHeader(java.nio.ByteBuffer output)Writes the remaining header (after the type,headerSize, andchunkSize).protected voidwritePayload(java.io.DataOutput output, java.nio.ByteBuffer header, boolean shrink)Writes the chunk payload.-
Methods inherited from class com.google.devrel.gmscore.tools.apk.arsc.ChunkWithChunks
getChunks
-
Methods inherited from class com.google.devrel.gmscore.tools.apk.arsc.Chunk
getHeaderSize, getOriginalChunkSize, getParent, newInstance, newInstance, toByteArray, toByteArray, writeHeader, writePad
-
-
-
-
Constructor Detail
-
PackageChunk
protected PackageChunk(java.nio.ByteBuffer buffer, @Nullable Chunk parent)
-
-
Method Detail
-
init
protected void init(java.nio.ByteBuffer buffer)
Description copied from class:ChunkFinishes initialization of a chunk. This should be called immediately after the constructor. This is separate from the constructor so that the header of a chunk can be fully initialized before the payload of that chunk is initialized for chunks that require such behavior.- Overrides:
initin classChunkWithChunks- Parameters:
buffer- The buffer that the payload will be initialized from.
-
getId
public int getId()
Returns the package id if this is a base package, or 0 if not a base package.
-
getKeyStringPool
public StringPoolChunk getKeyStringPool()
Returns the string pool that contains the names of the resources in this package.
-
getTypeStringPool
public StringPoolChunk getTypeStringPool()
Returns the string pool that contains the type strings for this package, such as "layout", "string", "color".
-
getTypeChunks
public java.util.Collection<TypeChunk> getTypeChunks()
Returns allTypeChunkin this package.
-
getTypeChunks
public java.util.Collection<TypeChunk> getTypeChunks(int id)
For a given type id, returns theTypeChunkobjects that match that id. The type id is the 1-based index of the type in the type string pool (returned bygetTypeStringPool()).
-
getTypeChunks
public java.util.Collection<TypeChunk> getTypeChunks(java.lang.String type)
For a given type, returns theTypeChunkobjects that match that type (e.g. "attr", "id", "string", ...).
-
getTypeSpecChunks
public java.util.Collection<TypeSpecChunk> getTypeSpecChunks()
Returns allTypeSpecChunkin this package.
-
getTypeSpecChunk
public TypeSpecChunk getTypeSpecChunk(int id)
For a given (1-based) type id, returns theTypeSpecChunkmatching it.
-
getTypeSpecChunk
public TypeSpecChunk getTypeSpecChunk(java.lang.String type)
For a giventype, returns theTypeSpecChunkthat matches it (e.g. "attr", "id", "string", ...).
-
getPackageName
public java.lang.String getPackageName()
Returns the name of this package.
-
getType
protected Chunk.Type getType()
-
writeHeader
protected void writeHeader(java.nio.ByteBuffer output)
Description copied from class:ChunkWrites the remaining header (after the type,headerSize, andchunkSize).- Overrides:
writeHeaderin classChunk- Parameters:
output- The buffer that the header will be written to.
-
writePayload
protected void writePayload(java.io.DataOutput output, java.nio.ByteBuffer header, boolean shrink) throws java.io.IOExceptionDescription copied from class:ChunkWrites the chunk payload. The payload is data in a chunk which is not in the firstheaderSizebytes of the chunk.- Overrides:
writePayloadin classChunkWithChunks- Parameters:
output- 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.- Throws:
java.io.IOException- Thrown ifoutputcould not be written to (out of memory).
-
-