class SpotVgtProductReaderPlugIn implements ProductReaderPlugIn {

    @Override
    public DecodeQualification getDecodeQualification(Object input) {
        File file = getFileInput(input);
        if (file == null) {
            return DecodeQualification.UNABLE;
        }

        VirtualDir virtualDir = VirtualDir.create(file);
        if (virtualDir == null) {
            return DecodeQualification.UNABLE;
        }

        try {
            try {
                Reader reader = virtualDir.getReader(SpotVgtConstants.PHYS_VOL_FILENAME);
                if (reader == null) {
                    return DecodeQualification.UNABLE;
                }
                try {
                    PhysVolDescriptor descriptor = new PhysVolDescriptor(reader);
                    String[] strings = virtualDir.list(descriptor.getLogVolDirName());
                    if (strings.length == 0) {
                        return DecodeQualification.UNABLE;
                    }
                } finally {
                    reader.close();
                }
                return DecodeQualification.INTENDED;
            } catch (IOException e) {
                // check for new structure of VGT P Collection3 products:
                // can be a directory or a zip file, e.g. V220140304096 or V220140304096.zip:
                // contains files <dirname>_*.hdf, <dirname>_LOG.txt, <dirname>_RIG.txt
                // --> check if <dirname>_LOG.txt and all <dirname>_*.hdf exist:
                final String productName = FilenameUtils.getBaseName(file.getName());
                try {
                    // is directory?
                    virtualDir.getReader(productName + "_LOG.TXT");
                } catch (IOException e1) {
                    try {
                        // is zip file?
                        virtualDir.getReader(productName + "/" + productName + "_LOG.TXT");
                    } catch (IOException e2) {
                        return DecodeQualification.UNABLE;
                    }
                }

                String[] filesInProduct;
                if (file.list() != null) {
                    // dir
                    filesInProduct = file.list();
                } else {
                    // zip
                    try {
                        filesInProduct = virtualDir.list(productName);
                    } catch (IOException e1) {
                        return DecodeQualification.UNABLE;
                    }
                }

                if (filesInProduct != null) {
                    for (int i = 0; i < SpotVgtConstants.BANDS_IN_VGT_P_COLLECTION3_PRODUCT.length; i++) {
                        boolean vgtPCollection3ProductFile = false;
                        for (int j = 0; j < filesInProduct.length; j++) {
                            if (filesInProduct[j].toUpperCase().
                                    equals(productName + "_" + SpotVgtConstants.BANDS_IN_VGT_P_COLLECTION3_PRODUCT[i] + ".HDF")) {
                                vgtPCollection3ProductFile = true;
                                break;
                            }
                        }
                        if (!vgtPCollection3ProductFile) {
                            return DecodeQualification.UNABLE;
                        }
                    }
                    isVgtPCollection3Product = true;
                    return DecodeQualification.INTENDED;
                } else {
                    return DecodeQualification.UNABLE;
                }
            }
        } finally {
            virtualDir.close();
        }
    }

    public  SpotVgtProductReaderPlugIn();

}