tri.close(); return retFormat;
    public static BitstreamFormat guessFormat(Context context,            Bitstream bitstream) throws SQLException    {        // FIXME: Just setting format to first guess        // For now just get the file name        String filename = bitstream.getName().toLowerCase();        // Gracefully handle the null case        if (filename == null)        {            return null;        }        // This isn't rocket science. We just get the name of the        // bitstream, get the extension, and see if we know the type.        String extension = filename;        int lastDot = filename.lastIndexOf('.');        if (lastDot != -1)        {            extension = filename.substring(lastDot + 1);        }        // If the last character was a dot, then extension will now be        // an empty string. If this is the case, we don't know what        // file type it is.        if (extension.equals(""))        {            return null;        }        // See if the extension is in the fileextension table        TableRowIterator tri = DatabaseManager.query(context,                "SELECT bitstreamformatregistry.* FROM bitstreamformatregistry, "                        + "fileextension WHERE fileextension.extension LIKE '"                        + extension                        + "' AND bitstreamformatregistry.bitstream_format_id="                        + "fileextension.bitstream_format_id");        if (tri.hasNext())        {            // Return first match            return new BitstreamFormat(context, tri.next());        }        else        {            return null;        }    }