Package org.apache.tika.sax
Class BasicContentHandlerFactory
- java.lang.Object
-
- org.apache.tika.sax.BasicContentHandlerFactory
-
- All Implemented Interfaces:
Serializable
,ContentHandlerFactory
,WriteLimiter
public class BasicContentHandlerFactory extends Object implements ContentHandlerFactory, WriteLimiter
Basic factory for creating common types of ContentHandlers- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BasicContentHandlerFactory.HANDLER_TYPE
Common handler types for content.
-
Constructor Summary
Constructors Constructor Description BasicContentHandlerFactory(BasicContentHandlerFactory.HANDLER_TYPE type, int writeLimit)
Create a BasicContentHandlerFactory withthrowOnWriteLimitReached
is trueBasicContentHandlerFactory(BasicContentHandlerFactory.HANDLER_TYPE type, int writeLimit, boolean throwOnWriteLimitReached, ParseContext parseContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ContentHandler
getNewContentHandler()
ContentHandler
getNewContentHandler(OutputStream os, Charset charset)
BasicContentHandlerFactory.HANDLER_TYPE
getType()
int
getWriteLimit()
boolean
isThrowOnWriteLimitReached()
static BasicContentHandlerFactory.HANDLER_TYPE
parseHandlerType(String handlerTypeName, BasicContentHandlerFactory.HANDLER_TYPE defaultType)
Tries to parse string into handler type.
-
-
-
Constructor Detail
-
BasicContentHandlerFactory
public BasicContentHandlerFactory(BasicContentHandlerFactory.HANDLER_TYPE type, int writeLimit)
Create a BasicContentHandlerFactory withthrowOnWriteLimitReached
is true- Parameters:
type
- basic type of handlerwriteLimit
- max number of characters to store; if < 0, the handler will store all characters
-
BasicContentHandlerFactory
public BasicContentHandlerFactory(BasicContentHandlerFactory.HANDLER_TYPE type, int writeLimit, boolean throwOnWriteLimitReached, ParseContext parseContext)
- Parameters:
type
- basic type of handlerwriteLimit
- maximum number of characters to storethrowOnWriteLimitReached
- whether or not to throw aWriteLimitReachedException
when the write limit has been reachedparseContext
- to store the writelimitreached warning if throwOnWriteLimitReached is set tofalse
-
-
Method Detail
-
parseHandlerType
public static BasicContentHandlerFactory.HANDLER_TYPE parseHandlerType(String handlerTypeName, BasicContentHandlerFactory.HANDLER_TYPE defaultType)
Tries to parse string into handler type. Returns default if string is null or parse fails. Options: xml, html, text, body, ignore (no content)- Parameters:
handlerTypeName
- string to parsedefaultType
- type to return if parse fails- Returns:
- handler type
-
getNewContentHandler
public ContentHandler getNewContentHandler()
- Specified by:
getNewContentHandler
in interfaceContentHandlerFactory
-
getNewContentHandler
public ContentHandler getNewContentHandler(OutputStream os, Charset charset)
- Specified by:
getNewContentHandler
in interfaceContentHandlerFactory
-
getType
public BasicContentHandlerFactory.HANDLER_TYPE getType()
- Returns:
- handler type used by this factory
-
getWriteLimit
public int getWriteLimit()
- Specified by:
getWriteLimit
in interfaceWriteLimiter
-
isThrowOnWriteLimitReached
public boolean isThrowOnWriteLimitReached()
- Specified by:
isThrowOnWriteLimitReached
in interfaceWriteLimiter
-
-