org.apache.tika.parser
Class ParseContext

java.lang.Object
  extended by org.apache.tika.parser.ParseContext
All Implemented Interfaces:
Serializable

public class ParseContext
extends Object
implements Serializable

Parse context. Used to pass context information to Tika parsers.

Since:
Apache Tika 0.5
See Also:
TIKA-275, Serialized Form

Constructor Summary
ParseContext()
           
 
Method Summary
<T> T
get(Class<T> key)
          Returns the object in this context that implements the given interface.
<T> T
get(Class<T> key, T defaultValue)
          Returns the object in this context that implements the given interface, or the given default value if such an object is not found.
 SAXParser getSAXParser()
          Returns the SAX parser specified in this parsing context.
 SAXParserFactory getSAXParserFactory()
          Returns the SAX parser factory specified in this parsing context.
<T> void
set(Class<T> key, T value)
          Adds the given value to the context as an implementation of the given interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParseContext

public ParseContext()
Method Detail

set

public <T> void set(Class<T> key,
                    T value)
Adds the given value to the context as an implementation of the given interface.

Parameters:
key - the interface implemented by the given value
value - the value to be added, or null to remove

get

public <T> T get(Class<T> key)
Returns the object in this context that implements the given interface.

Parameters:
key - the interface implemented by the requested object
Returns:
the object that implements the given interface, or null if not found

get

public <T> T get(Class<T> key,
                 T defaultValue)
Returns the object in this context that implements the given interface, or the given default value if such an object is not found.

Parameters:
key - the interface implemented by the requested object
defaultValue - value to return if the requested object is not found
Returns:
the object that implements the given interface, or the given default value if not found

getSAXParser

public SAXParser getSAXParser()
                       throws TikaException
Returns the SAX parser specified in this parsing context. If a parser is not explicitly specified, then one is created using the specified or the default SAX parser factory.

Returns:
SAX parser
Throws:
TikaException - if a SAX parser could not be created
Since:
Apache Tika 0.8
See Also:
getSAXParserFactory()

getSAXParserFactory

public SAXParserFactory getSAXParserFactory()
Returns the SAX parser factory specified in this parsing context. If a factory is not explicitly specified, then a default factory instance is created and returned. The default factory instance is configured to be namespace-aware and to use secure XML processing.

Returns:
SAX parser factory
Since:
Apache Tika 0.8


Copyright © 2007-2012 The Apache Software Foundation. All Rights Reserved.