2005-04-24 23:47:34 +02:00
|
|
|
//Parser.java
|
|
|
|
//------------------------
|
|
|
|
//part of YaCy
|
2008-07-20 19:14:51 +02:00
|
|
|
//(C) by Michael Peter Christen; mc@yacy.net
|
2005-04-24 23:47:34 +02:00
|
|
|
//first published on http://www.anomic.de
|
|
|
|
//Frankfurt, Germany, 2005
|
|
|
|
//
|
2005-05-03 11:47:56 +02:00
|
|
|
//this file was contributed by Martin Thelian
|
|
|
|
//last major change: $LastChangedDate$ by $LastChangedBy$
|
|
|
|
//Revision: $LastChangedRevision$
|
2005-04-24 23:47:34 +02:00
|
|
|
//
|
|
|
|
//This program is free software; you can redistribute it and/or modify
|
|
|
|
//it under the terms of the GNU General Public License as published by
|
|
|
|
//the Free Software Foundation; either version 2 of the License, or
|
|
|
|
//(at your option) any later version.
|
|
|
|
//
|
|
|
|
//This program is distributed in the hope that it will be useful,
|
|
|
|
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
//GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
//You should have received a copy of the GNU General Public License
|
|
|
|
//along with this program; if not, write to the Free Software
|
|
|
|
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2005-04-24 23:24:53 +02:00
|
|
|
|
|
|
|
package de.anomic.plasma.parser;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.InputStream;
|
2005-05-03 11:47:56 +02:00
|
|
|
import java.util.Hashtable;
|
2005-04-24 23:24:53 +02:00
|
|
|
|
|
|
|
import de.anomic.plasma.plasmaParserDocument;
|
2005-06-13 15:49:17 +02:00
|
|
|
import de.anomic.server.logging.serverLog;
|
2007-09-05 11:01:35 +02:00
|
|
|
import de.anomic.yacy.yacyURL;
|
2005-04-24 23:24:53 +02:00
|
|
|
|
2005-05-03 11:47:56 +02:00
|
|
|
/**
|
|
|
|
* This interface defines a list of methods that needs to be implemented
|
|
|
|
* by each content parser class.
|
|
|
|
* @author Martin Thelian
|
|
|
|
* @version $LastChangedRevision$ / $LastChangedDate$
|
|
|
|
*/
|
2005-04-24 23:24:53 +02:00
|
|
|
public interface Parser {
|
|
|
|
|
2006-09-30 11:31:53 +02:00
|
|
|
|
|
|
|
public static long MAX_KEEP_IN_MEMORY_SIZE = 5 * 1024 * 1024;
|
|
|
|
|
2005-05-03 11:47:56 +02:00
|
|
|
/**
|
|
|
|
* Parsing a document available as byte array
|
|
|
|
* @param location the origin of the document
|
|
|
|
* @param mimeType the mimetype of the document
|
2006-09-15 14:52:46 +02:00
|
|
|
* @param charset the supposed charset of the document or <code>null</code> if unkown
|
2005-05-03 11:47:56 +02:00
|
|
|
* @param source the content byte array
|
|
|
|
* @return a {@link plasmaParserDocument} containing the extracted plain text of the document
|
|
|
|
* and some additional metadata.
|
|
|
|
*
|
|
|
|
* @throws ParserException if the content could not be parsed properly
|
|
|
|
*/
|
2007-09-05 11:01:35 +02:00
|
|
|
public plasmaParserDocument parse(yacyURL location, String mimeType, String charset, byte[] source)
|
2006-09-03 16:59:00 +02:00
|
|
|
throws ParserException, InterruptedException;
|
2005-04-24 23:24:53 +02:00
|
|
|
|
2005-05-03 11:47:56 +02:00
|
|
|
/**
|
|
|
|
* Parsing a document stored in a {@link File}
|
|
|
|
* @param location the origin of the document
|
|
|
|
* @param mimeType the mimetype of the document
|
2006-09-15 14:52:46 +02:00
|
|
|
* @param charset the supposed charset of the document or <code>null</code> if unkown
|
2005-05-03 11:47:56 +02:00
|
|
|
* @param sourceFile the file containing the content of the document
|
|
|
|
* @return a {@link plasmaParserDocument} containing the extracted plain text of the document
|
|
|
|
* and some additional metadata.
|
|
|
|
*
|
|
|
|
* @throws ParserException if the content could not be parsed properly
|
|
|
|
*/
|
2007-09-05 11:01:35 +02:00
|
|
|
public plasmaParserDocument parse(yacyURL location, String mimeType, String charset, File sourceFile)
|
2006-09-03 16:59:00 +02:00
|
|
|
throws ParserException, InterruptedException;
|
2005-04-24 23:24:53 +02:00
|
|
|
|
2005-05-03 11:47:56 +02:00
|
|
|
/**
|
|
|
|
* Parsing a document available as {@link InputStream}
|
|
|
|
* @param location the origin of the document
|
|
|
|
* @param mimeType the mimetype of the document
|
2006-09-15 14:52:46 +02:00
|
|
|
* @param charset the supposed charset of the document or <code>null</code> if unkown
|
2005-05-03 11:47:56 +02:00
|
|
|
* @param source the {@link InputStream} containing the document content
|
|
|
|
* @return a {@link plasmaParserDocument} containing the extracted plain text of the document
|
|
|
|
* and some additional metadata.
|
|
|
|
*
|
|
|
|
* @throws ParserException if the content could not be parsed properly
|
|
|
|
*/
|
2007-09-05 11:01:35 +02:00
|
|
|
public plasmaParserDocument parse(yacyURL location, String mimeType, String charset, InputStream source)
|
2006-09-03 16:59:00 +02:00
|
|
|
throws ParserException, InterruptedException;
|
2005-04-24 23:24:53 +02:00
|
|
|
|
2005-05-03 11:47:56 +02:00
|
|
|
/**
|
|
|
|
* Can be used to determine the MimeType(s) that are supported by the parser
|
|
|
|
* @return a {@link Hashtable} containing a list of MimeTypes that are supported by
|
|
|
|
* the parser
|
|
|
|
*/
|
2008-01-22 12:51:43 +01:00
|
|
|
public Hashtable<String, String> getSupportedMimeTypes();
|
2005-04-24 23:24:53 +02:00
|
|
|
|
2005-05-03 11:47:56 +02:00
|
|
|
/**
|
|
|
|
* This function should be called before reusing the parser object.
|
|
|
|
*/
|
2005-04-24 23:24:53 +02:00
|
|
|
public void reset();
|
|
|
|
|
2006-10-03 13:05:48 +02:00
|
|
|
public void setContentLength(long length);
|
|
|
|
|
2005-05-17 10:25:04 +02:00
|
|
|
/**
|
|
|
|
* @return Returns a list of library names that are needed by this parser
|
|
|
|
*/
|
|
|
|
public String[] getLibxDependences();
|
2005-04-24 23:24:53 +02:00
|
|
|
|
2005-06-13 15:49:17 +02:00
|
|
|
/**
|
|
|
|
* Can be used to set the logger that should be used by the parser module
|
|
|
|
* @param log the {@link serverLog logger} that should be used
|
|
|
|
*/
|
|
|
|
public void setLogger(serverLog log);
|
|
|
|
|
2005-11-29 08:27:58 +01:00
|
|
|
/**
|
|
|
|
* Returns the version number of the current parser
|
|
|
|
* @return parser version number
|
|
|
|
*/
|
|
|
|
public String getVersion();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the parser
|
|
|
|
* @return parser name
|
|
|
|
*/
|
|
|
|
public String getName();
|
2005-04-24 23:24:53 +02:00
|
|
|
}
|
2005-11-29 08:27:58 +01:00
|
|
|
|
|
|
|
|