/** Test the data using a detector. * @param data the data we are testing. * @return if we have a match. */ private boolean testDetector(final ByteBuffer data) { final String detectorClassName = new String(this.match.getTest().array()).trim(); try { final Class<?> detectorClass = classForName(detectorClassName); final Object detectorObject = detectorClass.getDeclaredConstructor().newInstance(); final Method processMethod = detectorClass.getDeclaredMethod("process", byte[].class, //$NON-NLS-1$ Integer.TYPE, Integer.TYPE, Long.TYPE, Character.TYPE, String.class, Map.class); final String[] types = (String[]) processMethod.invoke(detectorObject, data.array(), Integer.valueOf(this.match.getOffset()), Integer.valueOf(this.match.getLength()), Long.valueOf(this.match.getBitmask()), Character.valueOf(this.match.getComparator()), this.match.getMimeType(), this.match.getProperties()); if (types != null && types.length > 0) { // the match object has no mime type set, so set from the detector class processing this.match.setMimeType(types[0]); return true; } } catch (final Throwable e) { java.util.logging.Logger.getLogger("es.gob.afirma").warning(e.toString()); //$NON-NLS-1$ } return false; }
String[] types = detector.process(data.array(), match.getOffset(), match.getLength(), match.getBitmask(), match.getComparator(), match.getMimeType(), match.getProperties());
String[] types = detector.process(data.array(), match.getOffset(), match.getLength(), match.getBitmask(), match.getComparator(), match.getMimeType(), match.getProperties());