@Test public void testDWG2010CustomPropertiesParser() throws Exception { InputStream testInput = DWGParserTest.class.getResourceAsStream( "/test-documents/testDWG2010_custom_props.dwg"); testParser(testInput); try (InputStream input = DWGParserTest.class.getResourceAsStream( "/test-documents/testDWG2010_custom_props.dwg")) { Metadata metadata = new Metadata(); ContentHandler handler = new BodyContentHandler(); new DWGParser().parse(input, handler, metadata, null); assertEquals("valueforcustomprop1", metadata.get("customprop1")); assertEquals("valueforcustomprop2", metadata.get("customprop2")); } }
public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, TikaException, SAXException { byte[] header = new byte[128]; IOUtils.readFully(stream, header); String version = new String(header, 0, 6, "US-ASCII"); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); if (version.equals("AC1015")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipTo2000PropertyInfoSection(stream, header)) { get2000Props(stream,metadata,xhtml); } } else if (version.equals("AC1018")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2004Props(stream,metadata,xhtml); } } else if (version.equals("AC1021") || version.equals("AC1024")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2007and2010Props(stream,metadata,xhtml); } } else { throw new TikaException( "Unsupported AutoCAD drawing version: " + version); } xhtml.endDocument(); }
DWGParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, TikaException, SAXException { byte[] header = new byte[128]; IOUtils.readFully(stream, header); String version = new String(header, 0, 6, "US-ASCII"); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); if (version.equals("AC1015")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipTo2000PropertyInfoSection(stream, header)) { get2000Props(stream,metadata,xhtml); } } else if (version.equals("AC1018")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2004Props(stream,metadata,xhtml); } } else if (version.equals("AC1021") || version.equals("AC1024")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2007and2010Props(stream,metadata,xhtml); } } else { throw new TikaException( "Unsupported AutoCAD drawing version: " + version); } xhtml.endDocument(); } }
DWGParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, TikaException, SAXException { byte[] header = new byte[128]; IOUtils.readFully(stream, header); String version = new String(header, 0, 6, "US-ASCII"); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); if (version.equals("AC1015")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipTo2000PropertyInfoSection(stream, header)) { get2000Props(stream,metadata,xhtml); } } else if (version.equals("AC1018")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2004Props(stream,metadata,xhtml); } } else if (version.equals("AC1021") || version.equals("AC1024")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2007and2010Props(stream,metadata,xhtml); } } else { throw new TikaException( "Unsupported AutoCAD drawing version: " + version); } xhtml.endDocument(); }  }
DWGParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, TikaException, SAXException { byte[] header = new byte[128]; IOUtils.readFully(stream, header); String version = new String(header, 0, 6, "US-ASCII"); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); if (version.equals("AC1015")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipTo2000PropertyInfoSection(stream, header)) { get2000Props(stream,metadata,xhtml); } } else if (version.equals("AC1018")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2004Props(stream,metadata,xhtml); } } else if (version.equals("AC1021") || version.equals("AC1024")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2007and2010Props(stream,metadata,xhtml); } } else { throw new TikaException( "Unsupported AutoCAD drawing version: " + version); } xhtml.endDocument(); }  Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context); }
DWGParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, TikaException, SAXException { byte[] header = new byte[128]; IOUtils.readFully(stream, header); String version = new String(header, 0, 6, "US-ASCII"); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); if (version.equals("AC1015")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipTo2000PropertyInfoSection(stream, header)) { get2000Props(stream,metadata,xhtml); } } else if (version.equals("AC1018")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2004Props(stream,metadata,xhtml); } } else if (version.equals("AC1021") || version.equals("AC1024")) { metadata.set(Metadata.CONTENT_TYPE, TYPE.toString()); if (skipToPropertyInfoSection(stream, header)) { get2007and2010Props(stream,metadata,xhtml); } } else { throw new TikaException( "Unsupported AutoCAD drawing version: " + version); } xhtml.endDocument(); }  Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context);  }