Holger's Java API

## com.antelmann.cddb
Class CDDBXmcdParser

    java.lang.Object
      com.antelmann.cddb.CDDBXmcdParser

All Implemented Interfaces:
  Serializable

    public class CDDBXmcdParser

extends Object
implements Serializable

CDDBXmcdParser provides methods to parse the file content from a CDDB/FreeDB raw file in xmcd format.

Author:
  Holger Antelmann
See Also:
  `CDInfo`, Serialized Form

Field Summary
`static String` `DEFAULT_COMMENT` used for generated Contribution comments or Artist descriptions

Constructor Summary
`CDDBXmcdParser(CDInfo cdinfo)`
`CDDBXmcdParser(File file)` file must be in the CDDB/FreeDB file format
`CDDBXmcdParser(String fileContent)` fileContent must be derived from CDDB/FreeDB file format

Method Summary
`String[]` `checkWarnings()` checks the xmcd file for completeness (this should return an empty array before the underlying content would be subject to a CDDB submission).
`static String` `createXmcdTemplate(CDID cd)` this static method provides a blank string template for an xmcd format entry based on the given cd
`static String` `createXmcdTemplateWithReplacer(CDID cd)` this static method provides a string template for an xmcd format entry based on the given cd containing easily replaceable entries
`Artist` `extractCDArtist()` returns the artist defined for the CD or null if none was found
`Composition` `extractComposition(boolean includeTracks)` creates a default Composition object from the embedded CDInfo that regards the entire CD as one composition and will contain certain Composition objects as far as applicable.
`Artist` `extractTrackArtist(int track)` returns the artist defined for the track or null if none was found
`Track[]` `extractTracks(boolean addArtist)` generates default Track objects that - if addArtist is true - contain applicable contributions
`String` `getContent()` return the content in xcmd format (used during construction)
`Properties` `getProperties()` returns a list of properties.
`protected String` `getTagText(String tag)` returns the text for the tag that could be found in multiple lines
`boolean` `isConsistenWith(CDID cd)` checks whether the given CD is consistent with the content
`protected String` `parseTag(String btag, String etag, int index)` returns the text between btag and etag after index; leading and tailing white space is removed
`String` `readArtist()` parses the title for the part before ' / ' which refers to the artist specified as <firstName lastName> by convention; null is returned if no artist separator could be found
`CDID` `readCDID()` parses for the offsets and returns a CDID object using the first discID found in the DISCID field
`String` `readCDTitle()` parses the title for the part after ' / ' which by convention refers to the CD title; if no title separator is found, the full title (same as `readTitle()`) is returned
`String[]` `readDiscIDs()` parses for possibly multiple discIDs to support searching for discIDs that link to the same file
`String` `readExtension()` parses for extended CD information
`String` `readGenre()` parses for the genre
`int` `readLength()` parses for the disc length and returns the seconds
`int` `readNumberOfTracks()`
`int[]` `readOffsets()` parses for the track offsets
`int[]` `readPlayOrder()` parses for the play order
`String` `readProcessedBy()` parses for the "Processed by" entry (an optional entry)
`int` `readRevision()` parses for the revision number of the entry
`String` `readSubmitter()` parses for the "Submitted via" entry
`String` `readTitle()` parses for the full title
`String` `readTitle(int track)` parses for the entire track title (including artist if available)
`String` `readTrackArtist(int track)` parses for the track artist (using first the track artist info, then the CD artist info)
`String` `readTrackExtension(int track)` parses for extended track info
`String` `readTrackTitle(int track)` parses for the track title (without artist info if applicable)
`int` `readYear()` parses for the year; returns 0 if no year was entered

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

Field Detail

### DEFAULT_COMMENT

    public static final String DEFAULT_COMMENT

  used for generated Contribution comments or Artist descriptions

  See Also:
    Constant Field Values

Constructor Detail

### CDDBXmcdParser

    public CDDBXmcdParser(File file)
                   throws IOException,
                          ParseException

  file must be in the CDDB/FreeDB file format

  Throws:
    `IOException`
    `ParseException`

### CDDBXmcdParser

    public CDDBXmcdParser(CDInfo cdinfo)
                   throws ParseException

Throws:
  `ParseException`

### CDDBXmcdParser

    public CDDBXmcdParser(String fileContent)
                   throws ParseException

  fileContent must be derived from CDDB/FreeDB file format

  Throws:
    `ParseException`

Method Detail

### getContent

    public String getContent()

  return the content in xcmd format (used during construction)

### isConsistenWith

    public boolean isConsistenWith(CDID cd)
                            throws XmcdFormatException

  checks whether the given CD is consistent with the content

  Throws:
    `XmcdFormatException`

### createXmcdTemplate

    public static String createXmcdTemplate(CDID cd)

  this static method provides a blank string template for an xmcd format entry based on the given cd

### createXmcdTemplateWithReplacer

    public static String createXmcdTemplateWithReplacer(CDID cd)

  this static method provides a string template for an xmcd format entry based on the given cd containing easily replaceable entries

### checkWarnings

    public String[] checkWarnings()
                           throws XmcdFormatException

  checks the xmcd file for completeness (this should return an empty array before the underlying content would be subject to a CDDB submission).

  Returns:
    an array of warnings discovered during processing or an empty array if no warnings present
  Throws:
    `XmcdFormatException`

### readCDID

    public CDID readCDID()
                  throws XmcdFormatException

  parses for the offsets and returns a CDID object using the first discID found in the DISCID field

  Throws:
    `XmcdFormatException`

### readNumberOfTracks

    public int readNumberOfTracks()

### readOffsets

    public int[] readOffsets()

  parses for the track offsets

### readLength

    public int readLength()
                   throws XmcdFormatException

  parses for the disc length and returns the seconds

  Throws:
    `XmcdFormatException`

### readRevision

    public int readRevision()
                     throws XmcdFormatException

  parses for the revision number of the entry

  Throws:
    `XmcdFormatException`

### readSubmitter

    public String readSubmitter()
                         throws XmcdFormatException

  parses for the "Submitted via" entry

  Throws:
    `XmcdFormatException`

### readProcessedBy

    public String readProcessedBy()
                           throws XmcdFormatException

  parses for the "Processed by" entry (an optional entry)

  Throws:
    `XmcdFormatException`

### readDiscIDs

    public String[] readDiscIDs()
                         throws XmcdFormatException

  parses for possibly multiple discIDs to support searching for discIDs that link to the same file

  Throws:
    `XmcdFormatException`

### readTitle

    public String readTitle()
                     throws XmcdFormatException

  parses for the full title

  Throws:
    `XmcdFormatException`

### readCDTitle

    public String readCDTitle()
                       throws XmcdFormatException

  parses the title for the part after ' / ' which by convention refers to the CD title; if no title separator is found, the full title (same as `readTitle()`) is returned

  Throws:
    `XmcdFormatException`

### readArtist

    public String readArtist()
                      throws XmcdFormatException

  parses the title for the part before ' / ' which refers to the artist specified as <firstName lastName> by convention; null is returned if no artist separator could be found

  Throws:
    `XmcdFormatException`

### readExtension

    public String readExtension()
                         throws XmcdFormatException

  parses for extended CD information

  Throws:
    `XmcdFormatException`

### readYear

    public int readYear()
                 throws XmcdFormatException

  parses for the year; returns 0 if no year was entered

  Throws:
    `XmcdFormatException`

### readGenre

    public String readGenre()
                     throws XmcdFormatException

  parses for the genre

  Throws:
    `XmcdFormatException`

### readTitle

    public String readTitle(int track)
                     throws XmcdFormatException

  parses for the entire track title (including artist if available)

  Throws:
    `XmcdFormatException`

### readTrackTitle

    public String readTrackTitle(int track)
                          throws XmcdFormatException

  parses for the track title (without artist info if applicable)

  Throws:
    `XmcdFormatException`

### readTrackArtist

    public String readTrackArtist(int track)
                           throws XmcdFormatException

  parses for the track artist (using first the track artist info, then the CD artist info)

  Throws:
    `XmcdFormatException`

### readTrackExtension

    public String readTrackExtension(int track)
                              throws XmcdFormatException

  parses for extended track info

  Throws:
    `XmcdFormatException`

### readPlayOrder

    public int[] readPlayOrder()
                        throws XmcdFormatException

  parses for the play order

  Throws:
    `XmcdFormatException`

### getProperties

    public Properties getProperties()
                             throws XmcdFormatException

  returns a list of properties. The property keys - as far as they are found in the content - are as follows:
  - cd.discids
  - cd.title
  - cd.cdtitle
  - cd.artist
  - cd.length
  - cd.revision
  - cd.genre
  - cd.submitter
  - cd.processedBy
  - cd.title
  - cd.extension
  - cd.year
  - track.n.title (where n is the number of the track)
  - track.n.artist (where n is the number of the track)
  - track.n.ext (where n is the number of the track)

  Throws:
    `XmcdFormatException`

### extractComposition

    public Composition extractComposition(boolean includeTracks)
                                   throws XmcdFormatException

  creates a default Composition object from the embedded CDInfo that regards the entire CD as one composition and will contain certain Composition objects as far as applicable.

  Parameters:
    `includeTracks` - if true, the generated Composition object will already contain all tracks from the embedded CDInfo
  Throws:
    `XmcdFormatException`

### extractTracks

    public Track[] extractTracks(boolean addArtist)
                          throws XmcdFormatException

  generates default Track objects that - if addArtist is true - contain applicable contributions

  Throws:
    `XmcdFormatException`

### extractCDArtist

    public Artist extractCDArtist()
                           throws XmcdFormatException

  returns the artist defined for the CD or null if none was found

  Throws:
    `XmcdFormatException`

### extractTrackArtist

    public Artist extractTrackArtist(int track)
                              throws XmcdFormatException

  returns the artist defined for the track or null if none was found

  Throws:
    `XmcdFormatException`

### getTagText

    protected String getTagText(String tag)
                         throws XmcdFormatException

  returns the text for the tag that could be found in multiple lines

  Throws:
    `XmcdFormatException`

### parseTag

    protected String parseTag(String btag,
                              String etag,
                              int index)
                       throws XmcdFormatException

  returns the text between btag and etag after index; leading and tailing white space is removed

  Throws:
    `XmcdFormatException`

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