net.sf.dc.freedb
Class Freedb

java.lang.Object
  extended bynet.sf.dc.freedb.Freedb

public class Freedb
extends java.lang.Object


Constructor Summary
Freedb(java.lang.String server, ImportAudioCDDialog ui)
           
 
Method Summary
 AudioCD convertToDcObject(FreedbQueryResult result)
          Converts a query result (not detailed) to a Data Crow Object
 AudioCD convertToDcObject(FreedbReadResult result)
          Converts a read result (detailed) to a Data Crow Object
 java.lang.String[] getAvailableServers()
           
 java.lang.String[] getCategories()
          public FreedbQueryResult[] queryKeywords(String search) throws Exception { String answer = searchFreedb(search); StringTokenizer st = new StringTokenizer(answer, "\n"); LinkedList list = new LinkedList(); String[] infos = new String[4]; int counter = 0; ui.initProgressBar(st.countTokens()); while (st.hasMoreTokens()) { ui.updateProgressBar(counter); String line = st.nextToken(); if (bigMatch(line, infos)) { // We have a line that has an artist/album list.add(new FreedbQueryResult(infos[0]+" "+infos[1]+" "+infos[2])); if (smallMatch(infos[3], infos)) { // Do we have a number 2 of the same album/artist ? list.add(new FreedbQueryResult(infos[0]+" "+infos[1]+" "+infos[2])); } } else if(smallMatch(line, infos)) { // We have a line that is number 3,4 of the previous artist/album list.add(new FreedbQueryResult(infos[0]+" "+infos[1]+" "+infos[2])); } counter++; } FreedbQueryResult[] results = new FreedbQueryResult[list.size()]; Iterator it = list.iterator(); int i = 0; while (it.hasNext()) { results[i] = (FreedbQueryResult) it.next(); i++; } return results; }
 AudioCD[] query(java.lang.String id)
          Queries the freedb server for the full id: Client command: -> cddb query discid ntrks off1 off2 ...
 AudioCD[] queryDiscId(java.lang.String discID)
           
 FreedbReadResult read(FreedbQueryResult query)
           
 FreedbReadResult read(java.lang.String genre, java.lang.String id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Freedb

public Freedb(java.lang.String server,
              ImportAudioCDDialog ui)
Method Detail

queryDiscId

public AudioCD[] queryDiscId(java.lang.String discID)
                      throws java.lang.Exception
Throws:
java.lang.Exception

getCategories

public java.lang.String[] getCategories()
                                 throws java.lang.Exception
public FreedbQueryResult[] queryKeywords(String search) throws Exception { String answer = searchFreedb(search); StringTokenizer st = new StringTokenizer(answer, "\n"); LinkedList list = new LinkedList(); String[] infos = new String[4]; int counter = 0; ui.initProgressBar(st.countTokens()); while (st.hasMoreTokens()) { ui.updateProgressBar(counter); String line = st.nextToken(); if (bigMatch(line, infos)) { // We have a line that has an artist/album list.add(new FreedbQueryResult(infos[0]+" "+infos[1]+" "+infos[2])); if (smallMatch(infos[3], infos)) { // Do we have a number 2 of the same album/artist ? list.add(new FreedbQueryResult(infos[0]+" "+infos[1]+" "+infos[2])); } } else if(smallMatch(line, infos)) { // We have a line that is number 3,4 of the previous artist/album list.add(new FreedbQueryResult(infos[0]+" "+infos[1]+" "+infos[2])); } counter++; } FreedbQueryResult[] results = new FreedbQueryResult[list.size()]; Iterator it = list.iterator(); int i = 0; while (it.hasNext()) { results[i] = (FreedbQueryResult) it.next(); i++; } return results; }

Throws:
java.lang.Exception

getAvailableServers

public java.lang.String[] getAvailableServers()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

query

public AudioCD[] query(java.lang.String id)
                throws java.lang.Exception
Queries the freedb server for the full id: Client command: -> cddb query discid ntrks off1 off2 ... nsecs After querying, the cd is queried by its discid and genre

Parameters:
id - full disc id
Throws:
java.lang.Exception

read

public FreedbReadResult read(java.lang.String genre,
                             java.lang.String id)
                      throws java.lang.Exception
Throws:
java.lang.Exception

read

public FreedbReadResult read(FreedbQueryResult query)
                      throws java.lang.Exception
Throws:
java.lang.Exception

convertToDcObject

public AudioCD convertToDcObject(FreedbQueryResult result)
Converts a query result (not detailed) to a Data Crow Object

Parameters:
result - query result

convertToDcObject

public AudioCD convertToDcObject(FreedbReadResult result)
Converts a read result (detailed) to a Data Crow Object

Parameters:
result - read result