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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Common handler types for content. -
Constructor Summary
ConstructorDescriptionBasicContentHandlerFactory
(BasicContentHandlerFactory.HANDLER_TYPE type, int writeLimit) Create a BasicContentHandlerFactory withthrowOnWriteLimitReached
is trueBasicContentHandlerFactory
(BasicContentHandlerFactory.HANDLER_TYPE type, int writeLimit, boolean throwOnWriteLimitReached, ParseContext parseContext) -
Method Summary
Modifier and TypeMethodDescriptiongetNewContentHandler
(OutputStream os, Charset charset) getType()
int
boolean
parseHandlerType
(String handlerTypeName, BasicContentHandlerFactory.HANDLER_TYPE defaultType) Tries to parse string into handler type.
-
Constructor Details
-
BasicContentHandlerFactory
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 Details
-
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
- Specified by:
getNewContentHandler
in interfaceContentHandlerFactory
-
getNewContentHandler
- Specified by:
getNewContentHandler
in interfaceContentHandlerFactory
-
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
-