public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws TikaException { throw new TikaException("Parse error"); } }
public void setFreeSpace(long free_space) throws TikaException { if (free_space < 0) { throw new TikaException("Bad PMGLheader.FreeSpace="+free_space); } this.free_space = free_space; }
public void throwStoredException() throws TikaException, SAXException, IOException { if (exception != null) { if (exception instanceof IOException) throw (IOException) exception; if (exception instanceof SAXException) throw (SAXException) exception; if (exception instanceof TikaException) throw (TikaException) exception; throw new TikaException(exception.getMessage()); } }
public ParserFactory build() throws TikaException { try { Class<?> clazz = Class.forName(className); Constructor<?> con = clazz.getConstructor(Map.class); return (ParserFactory) con.newInstance(args); } catch (ReflectiveOperationException|IllegalStateException e) { throw new TikaException("Couldn't create factory", e); } }
private static SAXParser newSAXParser() throws TikaException { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(false); try { factory.setFeature( XMLConstants.FEATURE_SECURE_PROCESSING, true); return factory.newSAXParser(); } catch (ParserConfigurationException|SAXException e) { throw new TikaException("prooblem creating SAX parser factory", e); } } }
public static byte[] copyOfRange(byte[] original, int from, int to) throws TikaException { checkCopyOfRangeParams(original, from, to); int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); if (to > original.length) { throw new TikaException("can't copy beyond array length"); } byte[] copy = new byte[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
public void parseJpeg(File file) throws IOException, SAXException, TikaException { try { com.drew.metadata.Metadata jpegMetadata = JpegMetadataReader.readMetadata(file); handle(jpegMetadata); } catch (JpegProcessingException e) { throw new TikaException("Can't read JPEG metadata", e); } catch (MetadataException e) { throw new TikaException("Can't read JPEG metadata", e); } }
public void parseTiff(File file) throws IOException, SAXException, TikaException { try { com.drew.metadata.Metadata tiffMetadata = TiffMetadataReader.readMetadata(file); handle(tiffMetadata); } catch (MetadataException e) { throw new TikaException("Can't read TIFF metadata", e); } catch (TiffProcessingException e) { throw new TikaException("Can't read TIFF metadata", e); } }
public static List<ExternalParser> read(InputStream stream) throws TikaException, IOException { try { DocumentBuilder builder = XMLReaderUtils.getDocumentBuilder(); Document document = builder.parse(new InputSource(stream)); return read(document); } catch (SAXException e) { throw new TikaException("Invalid parser configuration", e); } }
/** * Translate, using the first available service-loaded translator */ public String translate(String text, String sourceLanguage, String targetLanguage) throws TikaException, IOException { Translator t = getFirstAvailable(loader); if (t != null) { return t.translate(text, sourceLanguage, targetLanguage); } throw new TikaException("No translators currently available"); }
public XPSExtractorDecorator(ParseContext context, POIXMLTextExtractor extractor) throws TikaException { super(context, extractor); this.context = context; if (extractor.getPackage() instanceof ZipPackage) { this.pkg = (ZipPackage) extractor.getPackage(); } else { throw new TikaException("OPCPackage must be a ZipPackage"); } }
/** * Translate, using the first available service-loaded translator */ public String translate(String text, String targetLanguage) throws TikaException, IOException { Translator t = getFirstAvailable(loader); if (t != null) { return t.translate(text, targetLanguage); } throw new TikaException("No translators currently available"); }
public OutlookExtractor(DirectoryNode root, ParseContext context) throws TikaException { super(context); this.parseContext = context; this.extractAllAlternatives = context.get(OfficeParserConfig.class).getExtractAllAlternativesFromMSG(); try { this.msg = new MAPIMessage(root); } catch (IOException e) { throw new TikaException("Failed to parse Outlook message", e); } }
public void parseRawExif(byte[] exifData) throws IOException, SAXException, TikaException { com.drew.metadata.Metadata metadata = new com.drew.metadata.Metadata(); ExifReader reader = new ExifReader(); reader.extract(new ByteArrayReader(exifData), metadata, ExifReader.JPEG_SEGMENT_PREAMBLE.length()); try { handle(metadata); } catch (MetadataException e) { throw new TikaException("Can't process the EXIF Data", e); } }
public void extract( TikaInputStream stream, ContainerExtractor recurseExtractor, EmbeddedResourceHandler handler) throws IOException, TikaException { ParseContext context = new ParseContext(); context.set(Parser.class, new RecursiveParser(recurseExtractor, handler)); try { parser.parse(stream, new DefaultHandler(), new Metadata(), context); } catch (SAXException e) { throw new TikaException("Unexpected SAX exception", e); } }
private short readThroughNumEntries(InputStream stream) throws TikaException, IOException { //mime EndianUtils.readIntBE(stream); //version long version = EndianUtils.readIntBE(stream); if (version != 0x00020000) { throw new TikaException("Version should have been 0x00020000, but was:"+version); } IOUtils.skipFully(stream, 16);//filler return EndianUtils.readShortBE(stream);//number of entries }
private long unmarshalUInt32(byte[] data, int dataLenght, long dest) throws TikaException { ChmAssert.assertByteArrayNotNull(data); if (4 > dataLenght) throw new TikaException("4 > dataLenght"); dest = (data[this.getCurrentPlace()] & 0xff) | (data[this.getCurrentPlace() + 1] & 0xff) << 8 | (data[this.getCurrentPlace() + 2] & 0xff) << 16 | (data[this.getCurrentPlace() + 3] & 0xff) << 24; setDataRemained(this.getDataRemained() - 4); this.setCurrentPlace(this.getCurrentPlace() + 4); return dest; }
private int unmarshalInt32(byte[] data, int dest) throws TikaException{ ChmAssert.assertByteArrayNotNull(data); if (4 > this.getDataRemained()) throw new TikaException("4 > dataLenght"); dest = (data[this.getCurrentPlace()] & 0xff) | (data[this.getCurrentPlace() + 1] & 0xff) << 8 | (data[this.getCurrentPlace() + 2] & 0xff) << 16 | (data[this.getCurrentPlace() + 3] & 0xff) << 24; this.setCurrentPlace(this.getCurrentPlace() + 4); this.setDataRemained(this.getDataRemained() - 4); return dest; }
private long unmarshalUInt32(byte[] data, long dest) throws TikaException{ ChmAssert.assertByteArrayNotNull(data); if (4 > getDataRemained()) throw new TikaException("4 > dataLenght"); dest = data[this.getCurrentPlace()] | data[this.getCurrentPlace() + 1] << 8 | data[this.getCurrentPlace() + 2] << 16 | data[this.getCurrentPlace() + 3] << 24; setDataRemained(this.getDataRemained() - 4); this.setCurrentPlace(this.getCurrentPlace() + 4); return dest; }
private int unmarshalInt32(byte[] data, int dataLenght, int dest) throws TikaException { ChmAssert.assertByteArrayNotNull(data); if (4 > this.getDataRemained()) throw new TikaException("4 > dataLenght"); dest = (data[this.getCurrentPlace()] & 0xff) | (data[this.getCurrentPlace() + 1] & 0xff) << 8 | (data[this.getCurrentPlace() + 2] & 0xff) << 16 | (data[this.getCurrentPlace() + 3] & 0xff) << 24; this.setCurrentPlace(this.getCurrentPlace() + 4); this.setDataRemained(this.getDataRemained() - 4); return dest; }