FileDocCategorySizeDatePackage
Chunk.javaAPI DocJaudiotagger 2.0.45641Wed Mar 30 16:11:50 BST 2011org.jaudiotagger.audio.asf.data

Chunk

public class Chunk extends Object
This class represents a chunk within ASF streams.
Each chunk starts with a 16byte {@linkplain GUID GUID} identifying the type. After that a number (represented by 8 bytes) follows which shows the size in bytes of the chunk. Finally there is the data of the chunk.
author
Christian Laireiter

Fields Summary
protected final BigInteger
chunkLength
The length of current chunk.
protected final GUID
guid
The GUID of represented chunk header.
protected long
position
The position of current header object within file or stream.
Constructors Summary
public Chunk(GUID headerGuid, BigInteger chunkLen)
Creates an instance

param
headerGuid The GUID of header object.
param
chunkLen Length of current chunk.

        if (headerGuid == null) {
            throw new IllegalArgumentException("GUID must not be null.");
        }
        if (chunkLen == null || chunkLen.compareTo(BigInteger.ZERO) < 0) {
            throw new IllegalArgumentException(
                    "chunkLen must not be null nor negative.");
        }
        this.guid = headerGuid;
        this.chunkLength = chunkLen;
    
public Chunk(GUID headerGuid, long pos, BigInteger chunkLen)
Creates an instance

param
headerGuid The GUID of header object.
param
pos Position of header object within stream or file.
param
chunkLen Length of current chunk.

        if (headerGuid == null) {
            throw new IllegalArgumentException("GUID must not be null");
        }
        if (pos < 0) {
            throw new IllegalArgumentException(
                    "Position of header can't be negative.");
        }
        if (chunkLen == null || chunkLen.compareTo(BigInteger.ZERO) < 0) {
            throw new IllegalArgumentException(
                    "chunkLen must not be null nor negative.");
        }
        this.guid = headerGuid;
        this.position = pos;
        this.chunkLength = chunkLen;
    
Methods Summary
public longgetChunckEnd()
This method returns the End of the current chunk introduced by current header object.

return
Position after current chunk.
deprecated
typo, use {@link #getChunkEnd()} instead.

        return this.position + this.chunkLength.longValue();
    
public longgetChunkEnd()
This method returns the End of the current chunk introduced by current header object.

return
Position after current chunk.

        return this.position + this.chunkLength.longValue();
    
public java.math.BigIntegergetChunkLength()

return
Returns the chunkLength.

        return this.chunkLength;
    
public GUIDgetGuid()

return
Returns the guid.

        return this.guid;
    
public longgetPosition()

return
Returns the position.

        return this.position;
    
public java.lang.StringprettyPrint(java.lang.String prefix)
This method creates a String containing useful information prepared to be printed on STD-OUT.
This method is intended to be overwritten by inheriting classes.

param
prefix each line gets this string prepended.
return
Information of current Chunk Object.

        final StringBuilder result = new StringBuilder();
        result.append(prefix).append("-> GUID: ").append(
                GUID.getGuidDescription(this.guid))
                .append(Utils.LINE_SEPARATOR);
        result.append(prefix).append("  | : Starts at position: ").append(
                getPosition()).append(Utils.LINE_SEPARATOR);
        result.append(prefix).append("  | : Last byte at: ").append(
                getChunkEnd() - 1).append(Utils.LINE_SEPARATOR);
        return result.toString();
    
public voidsetPosition(long pos)
Sets the position.

param
pos position to set.

        this.position = pos;
    
public java.lang.StringtoString()
(overridden)

see
java.lang.Object#toString()

        return prettyPrint("");