Author: jukka
Date: Mon Oct 15 14:08:23 2007
New Revision: 584920
URL: http://svn.apache.org/viewvc?rev=584920&view=rev
Log:
TIKA-68 - Add dummy parser classes to be used as sentinels
Added:
incubator/tika/trunk/src/main/java/org/apache/tika/parser/EmptyParser.java
(with props)
incubator/tika/trunk/src/main/java/org/apache/tika/parser/ErrorParser.java
(with props)
Modified:
incubator/tika/trunk/CHANGES.txt
Modified: incubator/tika/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/tika/trunk/CHANGES.txt?rev=584920&r1=584919&r2=584920&view=diff
==============================================================================
--- incubator/tika/trunk/CHANGES.txt (original)
+++ incubator/tika/trunk/CHANGES.txt Mon Oct 15 14:08:23 2007
@@ -111,3 +111,5 @@
(mattmann)
50. TIKA-65 - Add encode detection support for HTML parser (siren)
+
+51. TIKA-68 - Add dummy parser classes to be used as sentinels (jukka)
Added:
incubator/tika/trunk/src/main/java/org/apache/tika/parser/EmptyParser.java
URL:
http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/EmptyParser.java?rev=584920&view=auto
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/EmptyParser.java
(added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/EmptyParser.java
Mon Oct 15 14:08:23 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Dummy parser that always produces an empty XHTML document without even
+ * attempting to parse the given document stream. Useful as a sentinel parser
+ * for unknown document types.
+ */
+public class EmptyParser implements Parser {
+
+ public void parse(
+ InputStream stream, ContentHandler handler, Metadata metadata)
+ throws IOException, SAXException, TikaException {
+ XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
+ xhtml.startDocument();
+ xhtml.endDocument();
+ }
+
+}
Propchange:
incubator/tika/trunk/src/main/java/org/apache/tika/parser/EmptyParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/tika/trunk/src/main/java/org/apache/tika/parser/ErrorParser.java
URL:
http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/ErrorParser.java?rev=584920&view=auto
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/ErrorParser.java
(added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/ErrorParser.java
Mon Oct 15 14:08:23 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser;
+
+import java.io.InputStream;
+
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.xml.sax.ContentHandler;
+
+/**
+ * Dummy parser that always throws a [EMAIL PROTECTED] TikaException} without
even
+ * attempting to parse the given document stream. Useful as a sentinel parser
+ * for unknown document types.
+ */
+public class ErrorParser implements Parser {
+
+ public void parse(
+ InputStream stream, ContentHandler handler, Metadata metadata)
+ throws TikaException {
+ throw new TikaException("Parse error");
+ }
+
+}
Propchange:
incubator/tika/trunk/src/main/java/org/apache/tika/parser/ErrorParser.java
------------------------------------------------------------------------------
svn:eol-style = native