You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ju...@apache.org on 2011/11/03 15:59:04 UTC
svn commit: r1197170 - in
/tika/trunk/tika-core/src/main/java/org/apache/tika: config/TikaConfig.java
mime/MimeTypes.java
Author: jukka
Date: Thu Nov 3 14:59:03 2011
New Revision: 1197170
URL: http://svn.apache.org/viewvc?rev=1197170&view=rev
Log:
TIKA-703: Drop deprecated methods/classes/interfaces
Restore deprecated methods referenced in Tika in Action. Too late to change the book anymore...
Modified:
tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java
tika/trunk/tika-core/src/main/java/org/apache/tika/mime/MimeTypes.java
Modified: tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java?rev=1197170&r1=1197169&r2=1197170&view=diff
==============================================================================
--- tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java (original)
+++ tika/trunk/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java Thu Nov 3 14:59:03 2011
@@ -193,6 +193,13 @@ public class TikaConfig {
}
/**
+ * @deprecated Use the {@link #getParser()} method instead
+ */
+ public Parser getParser(MediaType mimeType) {
+ return parser.getParsers().get(mimeType);
+ }
+
+ /**
* Returns the configured parser instance.
*
* @return configured parser
Modified: tika/trunk/tika-core/src/main/java/org/apache/tika/mime/MimeTypes.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/java/org/apache/tika/mime/MimeTypes.java?rev=1197170&r1=1197169&r2=1197170&view=diff
==============================================================================
--- tika/trunk/tika-core/src/main/java/org/apache/tika/mime/MimeTypes.java (original)
+++ tika/trunk/tika-core/src/main/java/org/apache/tika/mime/MimeTypes.java Thu Nov 3 14:59:03 2011
@@ -18,6 +18,7 @@ package org.apache.tika.mime;
// JDK imports
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
@@ -32,6 +33,7 @@ import java.util.TreeSet;
import javax.xml.namespace.QName;
+import org.apache.tika.Tika;
import org.apache.tika.detect.Detector;
import org.apache.tika.detect.TextDetector;
import org.apache.tika.detect.XmlRootExtractor;
@@ -120,10 +122,11 @@ public final class MimeTypes implements
* Find the Mime Content Type of a document from its name.
* Returns application/octet-stream if no better match is found.
*
+ * @deprecated Use {@link Tika#detect(String)} instead
* @param name of the document to analyze.
* @return the Mime Content Type of the specified document name
*/
- private MimeType getMimeType(String name) {
+ public MimeType getMimeType(String name) {
MimeType type = patterns.matches(name);
if (type != null) {
return type;
@@ -137,6 +140,21 @@ public final class MimeTypes implements
}
/**
+ * Find the Mime Content Type of a document stored in the given file.
+ * Returns application/octet-stream if no better match is found.
+ *
+ * @deprecated Use {@link Tika#detect(File)} instead
+ * @param file file to analyze
+ * @return the Mime Content Type of the specified document
+ * @throws MimeTypeException if the type can't be detected
+ * @throws IOException if the file can't be read
+ */
+ public MimeType getMimeType(File file)
+ throws MimeTypeException, IOException {
+ return forName(new Tika(this).detect(file));
+ }
+
+ /**
* Returns the MIME type that best matches the given first few bytes
* of a document stream. Returns application/octet-stream if no better
* match is found.