@Test public void should_detect_new_xls_format() throws Exception { try (InputStream inputStream = this.getClass().getResourceAsStream("test_new.xlsx")) { Format actual = xlsDetector.detect(inputStream); assertTrue(actual.getFormatFamily() instanceof XlsFormatFamily); assertTrue(StringUtils.equals("UTF-8", actual.getEncoding())); } }
@Override public Format detect(Metadata metadata, TikaInputStream inputStream) throws IOException { Format result = null; MediaType mediaType = super.detect(inputStream, metadata); if (mediaType == null || StringUtils.equals(mediaType.toString(), FormatUtils.UNKNOWN_MEDIA_TYPE)) { mediaType = zipContainerDetector.detect(inputStream, new Metadata()); } if (mediaType != null) { String mediaTypeName = mediaType.toString(); if (StringUtils.startsWith(mediaTypeName, XlsFormatFamily.MEDIA_TYPE) || StringUtils.equals(mediaTypeName, OLD_XLS_MEDIA_TYPE)) { result = new Format(xlsFormatFamily, FormatUtils.DEFAULT_ENCODING); } } return result; }
XlsDetector extends POIFSContainerDetector implements Detector { @Override public Format detect(Metadata metadata, TikaInputStream inputStream) throws IOException { Format result = null; MediaType mediaType = super.detect(inputStream, metadata); if (mediaType == null || StringUtils.equals(mediaType.toString(), FormatUtils.UNKNOWN_MEDIA_TYPE)) { mediaType = zipContainerDetector.detect(inputStream, new Metadata()); } if (mediaType != null) { String mediaTypeName = mediaType.toString(); if (StringUtils.startsWith(mediaTypeName, XlsFormatFamily.MEDIA_TYPE) || StringUtils.equals(mediaTypeName, OLD_XLS_MEDIA_TYPE)) { result = new Format(xlsFormatFamily, FormatUtils.DEFAULT_ENCODING); } } return result; } }
XlsDetector extends POIFSContainerDetector implements Detector { @Override public Format detect(Metadata metadata, TikaInputStream inputStream) throws IOException { Format result = null; MediaType mediaType = super.detect(inputStream, metadata); if (mediaType == null || StringUtils.equals(mediaType.toString(), FormatUtils.UNKNOWN_MEDIA_TYPE)) { mediaType = zipContainerDetector.detect(inputStream, new Metadata()); } if (mediaType != null) { String mediaTypeName = mediaType.toString(); if (StringUtils.startsWith(mediaTypeName, XlsFormatFamily.MEDIA_TYPE) || StringUtils.equals(mediaTypeName, OLD_XLS_MEDIA_TYPE)) { result = new Format(xlsFormatFamily, FormatUtils.DEFAULT_ENCODING); } } return result; }  }
XlsDetector extends POIFSContainerDetector implements Detector { @Override public Format detect(Metadata metadata, TikaInputStream inputStream) throws IOException { Format result = null; MediaType mediaType = super.detect(inputStream, metadata); if (mediaType == null || StringUtils.equals(mediaType.toString(), FormatUtils.UNKNOWN_MEDIA_TYPE)) { mediaType = zipContainerDetector.detect(inputStream, new Metadata()); } if (mediaType != null) { String mediaTypeName = mediaType.toString(); if (StringUtils.startsWith(mediaTypeName, XlsFormatFamily.MEDIA_TYPE) || StringUtils.equals(mediaTypeName, OLD_XLS_MEDIA_TYPE)) { result = new Format(xlsFormatFamily, FormatUtils.DEFAULT_ENCODING); } } return result; }  @Override Format detect(Metadata metadata, TikaInputStream inputStream); }
XlsDetector extends POIFSContainerDetector implements Detector { @Override public Format detect(Metadata metadata, TikaInputStream inputStream) throws IOException { Format result = null; MediaType mediaType = super.detect(inputStream, metadata); if (mediaType == null || StringUtils.equals(mediaType.toString(), FormatUtils.UNKNOWN_MEDIA_TYPE)) { mediaType = zipContainerDetector.detect(inputStream, new Metadata()); } if (mediaType != null) { String mediaTypeName = mediaType.toString(); if (StringUtils.startsWith(mediaTypeName, XlsFormatFamily.MEDIA_TYPE) || StringUtils.equals(mediaTypeName, OLD_XLS_MEDIA_TYPE)) { result = new Format(xlsFormatFamily, FormatUtils.DEFAULT_ENCODING); } } return result; }  @Override Format detect(Metadata metadata, TikaInputStream inputStream);  }