public Entry [ ] query ( String discid , int [ ] frameOffsets , int length ) throws IOException , CDDBException { // sanity check if ( _sock == null ) { throw new CDDBException ( 500 , "Not connected" ) ; } // construct the query parameter StringBuilder req = new StringBuilder ( "cddb query " ) ; req . append ( discid ) . append ( " " ) ; req . append ( frameOffsets . length ) . append ( " " ) ; for ( int frameOffset : frameOffsets ) { req . append ( frameOffset ) . append ( " " ) ; } req . append ( length ) ; // make the request Response rsp = request ( req . toString ( ) ) ; Entry [ ] entries = null ; // if this is an exact match, parse the entry and return it if ( rsp . code == 200 /* exact match */ ) { entries = new Entry [ 1 ] ; entries [ 0 ] = new Entry ( ) ; entries [ 0 ] . parse ( rsp . message ) ; } else if ( rsp . code == 211 /* inexact matches */ ) { // read the matches from the server ArrayList < Entry > list = new ArrayList < Entry > ( ) ; String input = _in . readLine ( ) ; while ( input != null && ! input . equals ( CDDBProtocol . TERMINATOR ) ) { System . out . println ( "...: " + input ) ; Entry e = new Entry ( ) ; e . parse ( input ) ; list . add ( e ) ; input = _in . readLine ( ) ; } entries = new Entry [ list . size ( ) ] ; list . toArray ( entries ) ; } else if ( CDDBProtocol . codeFamily ( rsp . code ) != CDDBProtocol . OK ) { throw new CDDBException ( rsp . code , rsp . message ) ; } return entries ; }
Issues a query to the CDDB server using the supplied CD identifying information .