org.modeshape.graph.text
Class TextExtractors

java.lang.Object
  extended by org.modeshape.graph.text.TextExtractors
All Implemented Interfaces:
TextExtractor

@ThreadSafe
public final class TextExtractors
extends Object
implements TextExtractor

Facility for managing TextExtractorConfigs.


Field Summary
protected static ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY
          Class loader factory instance that always returns the current thread's context class loader, or if null the class loader for this class.
static String DEFAULT_MIME_TYPE
           
 
Constructor Summary
TextExtractors()
           
 
Method Summary
 boolean addExtractor(TextExtractorConfig config)
          Adds the configuration for a text extractor before any previously added configurations, or updates any existing one that represents the same configuration
 void extractFrom(InputStream stream, TextExtractorOutput output, TextExtractorContext context)
          Sequence the data found in the supplied stream, placing the output information into the supplied map.
 ClassLoaderFactory getClassLoaderFactory()
          Gets the class loader factory that should be used to load text extractors.
 ComponentLibrary<TextExtractor,TextExtractorConfig> getLibrary()
           
 Logger getLogger()
          Gets the logger for this system
 boolean removeExtractor(TextExtractorConfig config)
          Removes the configuration for a text extractor.
 void setClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
          Sets the Maven Repository that should be used to load the MIME-type detectors.
 void setLogger(Logger logger)
          Sets the logger for this system.
 int size()
          Get the number of text extractors.
 boolean supportsMimeType(String mimeType)
          Determine if this extractor is capable of processing content with the supplied MIME type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MIME_TYPE

public static final String DEFAULT_MIME_TYPE
See Also:
Constant Field Values

DEFAULT_CLASSLOADER_FACTORY

protected static final ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY
Class loader factory instance that always returns the current thread's context class loader, or if null the class loader for this class.

Constructor Detail

TextExtractors

public TextExtractors()
Method Detail

getLibrary

public ComponentLibrary<TextExtractor,TextExtractorConfig> getLibrary()
Returns:
library

size

public int size()
Get the number of text extractors.

Returns:
the number of text extractors; may be 0 or greater

addExtractor

public boolean addExtractor(TextExtractorConfig config)
Adds the configuration for a text extractor before any previously added configurations, or updates any existing one that represents the same configuration

Parameters:
config - the new configuration; must not be null.
Returns:
true if the detector was added, or false if there already was an existing detector configuration.
See Also:
removeExtractor(TextExtractorConfig)

getClassLoaderFactory

public ClassLoaderFactory getClassLoaderFactory()
Gets the class loader factory that should be used to load text extractors. By default, this service uses a factory that will return either the current thread's context class loader, or if null the class loader for this class.

Returns:
the class loader factory; never null
See Also:
setClassLoaderFactory(ClassLoaderFactory)

getLogger

public Logger getLogger()
Gets the logger for this system

Returns:
the logger

supportsMimeType

public boolean supportsMimeType(String mimeType)
Determine if this extractor is capable of processing content with the supplied MIME type.

Specified by:
supportsMimeType in interface TextExtractor
Parameters:
mimeType - the MIME type; never null
Returns:
true if this extractor can process content with the supplied MIME type, or false otherwise.
See Also:
TextExtractor.supportsMimeType(java.lang.String)

extractFrom

public void extractFrom(InputStream stream,
                        TextExtractorOutput output,
                        TextExtractorContext context)
                 throws IOException
Sequence the data found in the supplied stream, placing the output information into the supplied map.

ModeShape's SequencingService determines the sequencers that should be executed by monitoring the changes to one or more workspaces that it is monitoring. Changes in those workspaces are aggregated and used to determine which sequencers should be called. If the sequencer implements this interface, then this method is called with the property that is to be sequenced along with the interface used to register the output. The framework takes care of all the rest.

Specified by:
extractFrom in interface TextExtractor
Parameters:
stream - the stream with the data to be sequenced; never null
output - the output from the sequencing operation; never null
context - the context for the sequencing operation; never null
Throws:
IOException - if there is a problem reading the stream
See Also:
TextExtractor.extractFrom(java.io.InputStream, org.modeshape.graph.text.TextExtractorOutput, org.modeshape.graph.text.TextExtractorContext)

removeExtractor

public boolean removeExtractor(TextExtractorConfig config)
Removes the configuration for a text extractor.

Parameters:
config - the configuration to be removed; must not be null.
Returns:
true if the configuration was removed, or false if there was no existing configuration
See Also:
addExtractor(TextExtractorConfig)

setClassLoaderFactory

public void setClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
Sets the Maven Repository that should be used to load the MIME-type detectors. By default, this service uses a factory that will return either the current thread's context class loader, or if null the class loader for this class.

Parameters:
classLoaderFactory - the class loader factory, or null if the default class loader factory should be used.
See Also:
getClassLoaderFactory()

setLogger

public void setLogger(Logger logger)
Sets the logger for this system.

Parameters:
logger - the logger, or null if the standard logging should be used


Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.