Holger's Java API

## com.antelmann.cddb
Class CDID

    java.lang.Object
      com.antelmann.cddb.CDID

All Implemented Interfaces:
  Serializable

    public class CDID

extends Object
implements Serializable

CDID represents a unique music CD with the characteristics usually provided by a CDDrive. This entry can be used to query additional information for the CD from services like CDDB

Author:
  Holger Antelmann
See Also:
  `CDDrive`, `CDDB`, Serialized Form

Constructor Summary
`CDID(CDDrive cddrive)` reads the CD information directly from the drive (preferred construction method)
`CDID(String queryString)` parses the CDID information from the given CDDB query string.
`CDID(String id, int[] offset, int length)` constructs the CDID manually (doesn't perform a consistency check)

Method Summary
`boolean` `equals(Object obj)` compares the query string for identity
`String` `getDiscID()` The returned discid can be used to match this CD to a CDDBRecord.
`int` `getFrameOffset(int track)` returns the offset of the frame on the CD where the given track starts.
`int` `getLength()` returns the duration of the CD in seconds
`int` `getNumberOfTracks()` this is equivalent to the number of frame offsets
`String` `getQueryString()` returns the query string in CDDB format
`int` `getTrackLength(int trackNo)` returns the duration of the track in seconds; trackNo specifies track 0 to (getNumberOfTracks() - 1).
`int` `hashCode()` hashes the discID
`String` `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### CDID

    public CDID(String id,
                int[] offset,
                int length)

  constructs the CDID manually (doesn't perform a consistency check)

### CDID

    public CDID(CDDrive cddrive)
         throws IllegalArgumentException

  reads the CD information directly from the drive (preferred construction method)

  Throws:
    `IllegalArgumentException`

### CDID

    public CDID(String queryString)
         throws NumberFormatException,
                ArrayIndexOutOfBoundsException

  parses the CDID information from the given CDDB query string.

  This constructor is useful for importing CDIDs from a file or the alike; it does not check the validity/consistency of the string, though.

  Parameters:
    `queryString` - a string in the exact format specified by the CDDB protocol for querying a CD.
  Throws:
    `NumberFormatException` - if the string cannot be parsed properly
    `ArrayIndexOutOfBoundsException` - if the string cannot be parsed properly
  See Also:
    `CDDrive.getQueryString()`

Method Detail

### getDiscID

    public String getDiscID()

  The returned discid can be used to match this CD to a CDDBRecord.

  See Also:
    `CDDBRecord.getDiscID()`

### getLength

    public int getLength()

  returns the duration of the CD in seconds

### getFrameOffset

    public int getFrameOffset(int track)

  returns the offset of the frame on the CD where the given track starts. Note: track is to be specified from 0 to `getNumberOfTracks()-1`.

### getNumberOfTracks

    public int getNumberOfTracks()

  this is equivalent to the number of frame offsets

### getTrackLength

    public int getTrackLength(int trackNo)

  returns the duration of the track in seconds; trackNo specifies track 0 to (getNumberOfTracks() - 1). The last track is currently over-calculated; this over-estimate for the last track worsens if there is a data track at the end.

### getQueryString

    public String getQueryString()

  returns the query string in CDDB format

### hashCode

    public int hashCode()

  hashes the discID

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object obj)

  compares the query string for identity

  Overrides:
    `equals` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads