de.grogra.pf.io
Class FilterBase

java.lang.Object
  extended by de.grogra.pf.io.FilterBase
All Implemented Interfaces:
Filter, FilterSource, RegistryContext, Map
Direct Known Subclasses:
CompilationFilter, ContourFilter, CSVWriter, DTDFilter, DTDSourceFile.Loader, DTGFilter, ExcelWriter, ExportModule, FunctionReader, GraphReader, GSReader, GSWriter, GSZReader, GSZWriter, GUnzipFilter, GZipFilter, HTMLWriter, ImageReader, ImageWriter, ImportModule, LazyFilter, LuminanceFilter, MSMLProjectLoader, MSMLReader, MSMLWriter, MTGFilter, MTGLoader, MTGReader, MTGSourceFile.Loader, NullResourceFilter, PDFWriter, PlainTextWriter, RegistryReader, SAXFilterBase, SceneGraphExport, SMBFilter, SourceFile.Loader, SPDFilter, SurfaceFilter, X3DImport, XFrogFilter, XFrogProjectLoader, XLFilter, XMLReaderBase, XMLWriter

public abstract class FilterBase
extends java.lang.Object
implements Filter, FilterSource, Map

This is a base class for the implementation of Filters. Its implementation of getMetaData forwards to #getImpl(Object, Object) firstly, then to the item which defines this filter, then to the meta data of the source, and returns the first value which could be found this way.

Author:
Ole Kniemeyer

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.grogra.pf.io.FilterSource
FilterSource.MetaDataKey<V>
 
Nested classes/interfaces inherited from interface de.grogra.util.Map
Map.Chain
 
Field Summary
protected  FilterItem item
          The defining FilterItem for this filter.
protected  FilterSource source
          The data source of this filter.
 
Fields inherited from interface de.grogra.pf.io.FilterSource
AUTO_PROGRESS, DESTINATION_FILE, DESTINATION_URL
 
Fields inherited from interface de.grogra.util.Map
DEFAULT_VALUE, EMPTY_MAP
 
Constructor Summary
FilterBase(FilterItem item, FilterSource source)
          Creates a new FilterBase, initializes its item and source fields and sets the system id to the system id of the source.
 
Method Summary
 java.lang.Object get(java.lang.Object key, java.lang.Object defaultValue)
          Returns the value associated with key.
 Filter getFilter()
          Returns the Filter from which this instance obtains its data.
 IOFlavor getFlavor()
          Returns the IOFlavor of this data source.
protected  java.lang.Object getImpl(FilterSource.MetaDataKey key, java.lang.Object defaultValue)
          This method is invoked by get(Object, Object).
<V> V
getMetaData(FilterSource.MetaDataKey<V> key, V defaultValue)
           
 Registry getRegistry()
          Returns the Registry which is linked with this instance.
 FilterSource getSource()
          Returns the data source of this filter.
 java.lang.String getSystemId()
          Returns a system id which identifies this source.
 void initProgressMonitor(ProgressMonitor monitor)
           
protected  void setFlavor(IOFlavor flavor)
           
<V> void
setMetaData(FilterSource.MetaDataKey<V> key, V value)
           
protected  void setMetaData(Map metaData)
          Sets the internal meta data map to the specified map.
 void setProgress(java.lang.String text, float progress)
           
protected  void setSystemId(java.lang.String systemId)
           
 java.lang.String toString()
           
 java.net.URL toURL()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

item

protected final FilterItem item
The defining FilterItem for this filter.


source

protected final FilterSource source
The data source of this filter.

Constructor Detail

FilterBase

public FilterBase(FilterItem item,
                  FilterSource source)
Creates a new FilterBase, initializes its item and source fields and sets the system id to the system id of the source.

Parameters:
item - the defining FilterItem
source - the data source
Method Detail

get

public java.lang.Object get(java.lang.Object key,
                            java.lang.Object defaultValue)
Description copied from interface: Map
Returns the value associated with key. If there is no value associated with key, defaultValue is returned.

Specified by:
get in interface Map
Parameters:
key - a key for the map
defaultValue - the default value
Returns:
the associated value, or defaultValue

getFilter

public final Filter getFilter()
Description copied from interface: FilterSource
Returns the Filter from which this instance obtains its data. If there is no such filter, i.e., if this is the first object in the filter pipeline, this method returns null.

Specified by:
getFilter in interface FilterSource
Returns:
the filter from which data is obtained, or null

getFlavor

public final IOFlavor getFlavor()
Description copied from interface: FilterSource
Returns the IOFlavor of this data source. Depending on the flavor, this instance has to implement corresponding subinterfaces of FilterSource.

Specified by:
getFlavor in interface FilterSource
Returns:
the flavor of the data

getImpl

protected java.lang.Object getImpl(FilterSource.MetaDataKey key,
                                   java.lang.Object defaultValue)
This method is invoked by get(Object, Object). This default implementation forwards to the internal meta data map (see setMetaData(Map)), or returns defaultValue if no such internal map has been set.

Parameters:
key - a key
defaultValue - a default value
Returns:
the associated value, or defaultValue

getMetaData

public <V> V getMetaData(FilterSource.MetaDataKey<V> key,
                         V defaultValue)
Specified by:
getMetaData in interface FilterSource

getRegistry

public final Registry getRegistry()
Description copied from interface: RegistryContext
Returns the Registry which is linked with this instance.

Specified by:
getRegistry in interface RegistryContext
Returns:
the registry linked with this instance

getSource

public final FilterSource getSource()
Description copied from interface: Filter
Returns the data source of this filter.

Specified by:
getSource in interface Filter
Returns:
the data source of this filter

getSystemId

public final java.lang.String getSystemId()
Description copied from interface: FilterSource
Returns a system id which identifies this source.

Specified by:
getSystemId in interface FilterSource
Returns:
system id

initProgressMonitor

public void initProgressMonitor(ProgressMonitor monitor)
Specified by:
initProgressMonitor in interface FilterSource

setFlavor

protected final void setFlavor(IOFlavor flavor)

setMetaData

public <V> void setMetaData(FilterSource.MetaDataKey<V> key,
                            V value)
Specified by:
setMetaData in interface FilterSource

setMetaData

protected void setMetaData(Map metaData)
Sets the internal meta data map to the specified map.

Parameters:
metaData - a value for the internal meta data map

setProgress

public void setProgress(java.lang.String text,
                        float progress)
Specified by:
setProgress in interface FilterSource

setSystemId

protected final void setSystemId(java.lang.String systemId)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toURL

public java.net.URL toURL()
                   throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException