@Override public boolean handles(ReadableArchive archive) throws IOException { return detector.handles(archive); }
@Override public boolean handles(ReadableArchive archive) throws IOException { return detector.handles(archive); }
public boolean handles(ReadableArchive archive) throws IOException { return detector.handles(archive); }
/** * Returns the ArchiveHandler for the passed archive abstraction or null * if there are none. * * @param archive the archive to find the handler for * @param type the type of the archive * @return the archive handler or null if not found. * @throws IOException when an error occur */ public ArchiveHandler getArchiveHandler(ReadableArchive archive, String type) throws IOException { if (type != null) { return habitat.<ArchiveDetector>getService(ArchiveDetector.class, type).getArchiveHandler(); } List<ArchiveDetector> detectors = new ArrayList<ArchiveDetector>(habitat.<ArchiveDetector>getAllServices(ArchiveDetector.class)); Collections.sort(detectors, new Comparator<ArchiveDetector>() { // rank 2 is considered lower than rank 1, let's sort them in inceasing order @Override public int compare(ArchiveDetector o1, ArchiveDetector o2) { return o1.rank() - o2.rank(); } }); for (ArchiveDetector ad : detectors) { if (ad.handles(archive)) { return ad.getArchiveHandler(); } } return null; }
/** * Returns the ArchiveHandler for the passed archive abstraction or null * if there are none. * * @param archive the archive to find the handler for * @param type the type of the archive * @return the archive handler or null if not found. * @throws IOException when an error occur */ public ArchiveHandler getArchiveHandler(ReadableArchive archive, String type) throws IOException { if (type != null) { return habitat.<ArchiveDetector>getService(ArchiveDetector.class, type).getArchiveHandler(); } List<ArchiveDetector> detectors = new ArrayList<ArchiveDetector>(habitat.<ArchiveDetector>getAllServices(ArchiveDetector.class)); Collections.sort(detectors, new Comparator<ArchiveDetector>() { // rank 2 is considered lower than rank 1, let's sort them in inceasing order @Override public int compare(ArchiveDetector o1, ArchiveDetector o2) { return o1.rank() - o2.rank(); } }); for (ArchiveDetector ad : detectors) { if (ad.handles(archive)) { return ad.getArchiveHandler(); } } return null; }