net.wimpi.text
Class AbstractProcessor

java.lang.Object
  |
  +--net.wimpi.text.AbstractProcessor
All Implemented Interfaces:
Processor
Direct Known Subclasses:
ProcessingPipeImpl

public abstract class AbstractProcessor
extends java.lang.Object
implements Processor

Abstract class which implements most of the Processor interface. Might be useful to reduce the time necessary for custom implementations.

Version:
0.2 19/11/2002
Author:
Dieter Wimberger

Field Summary
protected  java.util.Properties m_Properties
           
 
Constructor Summary
AbstractProcessor()
           
 
Method Summary
 java.lang.String getDescription()
          Returns the description of this processor, in the default Locale, or the default available Locale of this Processor.
 java.lang.String getDescription(java.util.Locale loc)
          Returns the description of this processor, in the given Locale.
 java.lang.String getName()
          Returns the name of this processor.
 java.util.Properties getProperties()
           
 java.util.Locale[] listAvailableLocales()
          Returns a list of supported locales with regard to the descriptions.
 java.io.InputStream process(java.io.InputStream in)
          A standard implementation converting the stream into a String, processing it, and wrapping the result into a ByteArrayInputStream.
abstract  java.lang.String process(java.lang.String str)
          Processes the given String and returns the result as String.
 void setDefaultLocale(java.util.Locale l)
          Sets the default Locale of this processor to the given Locale, if an only if a description in this locale exists.
 void setDescription(java.lang.String desc, java.util.Locale l)
          Sets the description of this processor in a given Locale.
protected  void setName(java.lang.String name)
           
 void setProperties(java.util.Properties properties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Properties

protected java.util.Properties m_Properties
Constructor Detail

AbstractProcessor

public AbstractProcessor()
Method Detail

getName

public java.lang.String getName()
Description copied from interface: Processor
Returns the name of this processor.
Specified by:
getName in interface Processor
Following copied from interface: net.wimpi.text.Processor
Returns:
the name of this processor as String.

setName

protected void setName(java.lang.String name)

getProperties

public java.util.Properties getProperties()

setProperties

public void setProperties(java.util.Properties properties)

getDescription

public java.lang.String getDescription()
Description copied from interface: Processor
Returns the description of this processor, in the default Locale, or the default available Locale of this Processor.
Specified by:
getDescription in interface Processor
Following copied from interface: net.wimpi.text.Processor
Returns:
the description of this processor as String.

getDescription

public java.lang.String getDescription(java.util.Locale loc)
Description copied from interface: Processor
Returns the description of this processor, in the given Locale. If the given Locale is not available the default available one for this Processor will be returned.
Specified by:
getDescription in interface Processor
Following copied from interface: net.wimpi.text.Processor
Parameters:
l - a Locale.
Returns:
the description of this processor as String.

setDescription

public void setDescription(java.lang.String desc,
                           java.util.Locale l)
Description copied from interface: Processor
Sets the description of this processor in a given Locale. If no default Locale is set yet, the implementation should set the default to the first description it receives.
Specified by:
setDescription in interface Processor
Following copied from interface: net.wimpi.text.Processor
Parameters:
desc - the description of this processor as String.
l - a Locale.

setDefaultLocale

public void setDefaultLocale(java.util.Locale l)
Description copied from interface: Processor
Sets the default Locale of this processor to the given Locale, if an only if a description in this locale exists.
Specified by:
setDefaultLocale in interface Processor
Following copied from interface: net.wimpi.text.Processor
Parameters:
l - a Locale.

listAvailableLocales

public java.util.Locale[] listAvailableLocales()
Description copied from interface: Processor
Returns a list of supported locales with regard to the descriptions.
Specified by:
listAvailableLocales in interface Processor
Following copied from interface: net.wimpi.text.Processor
Returns:
the list as Locale[].

process

public abstract java.lang.String process(java.lang.String str)
Description copied from interface: Processor
Processes the given String and returns the result as String.
Specified by:
process in interface Processor
Following copied from interface: net.wimpi.text.Processor
Returns:
the processed String.

process

public java.io.InputStream process(java.io.InputStream in)
                            throws java.io.IOException
A standard implementation converting the stream into a String, processing it, and wrapping the result into a ByteArrayInputStream. This is probably convenient for limited text sizes, but not useful for real pipeline processing of large texts.
Specified by:
process in interface Processor
Parameters:
in - the InputStream to read from.
Returns:
the InputStream delivering the processed text.


Copyright 2001,2002 Dieter Wimberger. All Rights Reserved.