equal
deleted
inserted
replaced
507 return null; |
507 return null; |
508 } |
508 } |
509 }; |
509 }; |
510 } |
510 } |
511 |
511 |
|
512 /** |
|
513 * Returns a {@code FileTypeDetector} that chains the given array of file |
|
514 * type detectors. When the {@code implProbeContentType} method is invoked |
|
515 * then each of the detectors is invoked in turn, the result from the |
|
516 * first to detect the file type is returned. |
|
517 */ |
|
518 final FileTypeDetector chain(final AbstractFileTypeDetector... detectors) { |
|
519 return new AbstractFileTypeDetector() { |
|
520 @Override |
|
521 protected String implProbeContentType(Path file) throws IOException { |
|
522 for (AbstractFileTypeDetector detector : detectors) { |
|
523 String result = detector.implProbeContentType(file); |
|
524 if (result != null && !result.isEmpty()) { |
|
525 return result; |
|
526 } |
|
527 } |
|
528 return null; |
|
529 } |
|
530 }; |
|
531 } |
512 } |
532 } |