Record Class RiffChunk
- Record Components:
id- the four-character chunk identifier; must be non-nullsize- declared payload length in bytes; must be non-negativedataStartOffset- absolute byte position of the first payload byte within the enclosing source; must be non-negative
A RIFF chunk is a length-prefixed, ID-tagged run of bytes: four ASCII
characters of id (for example "fmt ", "data",
"LIST", or "ds64"), a 32-bit little-endian size
field giving the number of payload bytes that follow the 8-byte header,
and then size bytes of payload — plus one zero-byte pad
when size is odd, carried at the next higher level by
RiffReader.
This record describes only the chunk's header. It does not
hold the payload itself: the WAV reader streams the payload directly
through RiffReader.skip(long) for ignored chunks and through
fmt /ds64 parsers for chunks the provider understands.
dataStartOffset() is the absolute byte position of the first
payload byte within the enclosing source (file or stream), measured from
the same origin as RiffReader.position().
Contract:
idis the four-character chunk identifier, exactly four ASCII bytes interpreted asStandardCharsets.US_ASCII. Must be non-null.RiffReaderproduces IDs by callingreadAscii(4), which in turn enforces the length invariant, so callers constructing aRiffChunkby hand (test fixtures, for example) must keep the same shape.sizeis the declared payload length in bytes, from the chunk's 32-bit little-endian size field, promoted tolongbecause WAV's size field is unsigned 32-bit and the natural Javaintwould sign-flip at2 GiB. For RF64 files the outerRIFF/RF64anddatachunks use an0xFFFFFFFFsentinel here and the real size is pulled from theds64chunk by the caller. Must be non-negative.dataStartOffsetis the absolute byte position of the chunk's payload within the underlying source, i.e. the position immediately after the 8-byte ID+size header. Must be non-negative.
This record is not part of the published API. It
lives in com.tino1b2be.dtmf.io.wav.internal, whose stability
contract (see the package Javadoc) explicitly allows breakage between
any two releases. It is public at the type level purely so
classes in the parent com.tino1b2be.dtmf.io.wav package can
reach it; external callers MUST NOT depend on it.
- Since:
- 2.1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of thedataStartOffsetrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.longsize()Returns the value of thesizerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RiffChunk
Compact constructor validating the non-null and non-negative invariants. Note that this constructor deliberately does not check the length ofid:RiffReaderis the only production path that createsRiffChunkinstances and always passes a four-character string, and leaving the length unconstrained keeps test fixtures free to exercise degenerate IDs.- Throws:
NullPointerException- ifidisnullIllegalArgumentException- ifsizeordataStartOffsetis negative
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
size
public long size()Returns the value of thesizerecord component.- Returns:
- the value of the
sizerecord component
-
dataStartOffset
public long dataStartOffset()Returns the value of thedataStartOffsetrecord component.- Returns:
- the value of the
dataStartOffsetrecord component
-