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 2009/09/12 19:37:30 UTC
svn commit: r814207 -
/lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java
Author: jukka
Date: Sat Sep 12 17:37:30 2009
New Revision: 814207
URL: http://svn.apache.org/viewvc?rev=814207&view=rev
Log:
TIKA-269: Ease of use -facade for Tika
Make the facade methods static.
Modified:
lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java
Modified: lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java?rev=814207&r1=814206&r2=814207&view=diff
==============================================================================
--- lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java (original)
+++ lucene/tika/trunk/tika-core/src/main/java/org/apache/tika/Tika.java Sat Sep 12 17:37:30 2009
@@ -38,7 +38,13 @@
*/
public class Tika {
- private final Parser parser = new AutoDetectParser();
+ private static final Parser parser = new AutoDetectParser();
+
+ /**
+ * Private constructor to prevent this class from being instantiated.
+ */
+ private Tika() {
+ }
/**
* Parses the given document and returns the extracted text content.
@@ -47,7 +53,7 @@
* @result extracted text content
* @throws IOException if the document can not be read or parsed
*/
- public Reader parse(InputStream stream) throws IOException {
+ public static Reader parse(InputStream stream) throws IOException {
return new ParsingReader(parser, stream, new Metadata());
}
@@ -59,7 +65,8 @@
* @throws FileNotFoundException if the given file does not exist
* @throws IOException if the file can not be read or parsed
*/
- public Reader parse(File file) throws FileNotFoundException, IOException {
+ public static Reader parse(File file)
+ throws FileNotFoundException, IOException {
Metadata metadata = new Metadata();
metadata.set(Metadata.RESOURCE_NAME_KEY, file.getName());
return new ParsingReader(parser, new FileInputStream(file), metadata);
@@ -73,7 +80,7 @@
* @result extracted text content
* @throws IOException if the resource can not be read or parsed
*/
- public Reader parse(URL url) throws IOException {
+ public static Reader parse(URL url) throws IOException {
Metadata metadata = new Metadata();
String path = url.getPath();
int slash = path.lastIndexOf('/');