|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteap.filter.FilterBroker
Maintains a registry of filters which it can apply to a data stream based on file name extensions. Filter classes are not loaded until they are needed, so there is little overhead for registering a large number of filters which will not be used. In fact a filter can be registered for which the implementation class bytecode is not available.
| Constructor Summary | |
FilterBroker()
Creates a new FilterBroker with no filters registered. |
|
| Method Summary | |
void |
addDefaultFilters()
Equivalent to calling addDefaultFilters(eap.filter.FilterBroker.class) |
void |
addDefaultFilters(Class c)
Add the default filters listed in the "filter.properties" file which can be found in the same directory as the given class's .class file. |
void |
addFilter(String extension,
String classname,
String name)
Add a filter with the given properties to the registry. |
void |
addFilters(Properties properties)
Add the filters defined in a set of properties. |
InputStream |
filter(InputStream in,
String filename)
Get a filtered input stream appropriate for a filename. |
String |
getLastFileName()
Accesses the file name in the last call to filter(InputStream, String) with all the filtered extensions removed. |
boolean |
hasFilter(String filename)
Returns true if there is a filter registered for a given filename. |
static void |
main(String[] args)
Main method mostly useful for testing. |
void |
setPasswordProvider(PasswordProvider password)
Sets the class which will be used to obtain a single string of metadata needed to create a filter. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public FilterBroker()
| Method Detail |
public void setPasswordProvider(PasswordProvider password)
password - The password provider to be used. If this is null, then
no password provider will be registered.
public void addDefaultFilters()
throws IOException
IOException
public void addDefaultFilters(Class c)
throws IOException
c - The class whose class loader will be used to find the
filter.properties file.
IOExceptionaddFilters(Properties)public void addFilters(Properties properties)
properties - the set of properties defining a set of filters
public void addFilter(String extension,
String classname,
String name)
extension - The file name extension (e.g. ".gz") which indicates
that this filter should be appliedclassname - The name of the java class which implements the filter.
A filter class must be a subclass of java.io.InputStream, and have
a constructor: Class(java.io.InputStream), or Class(java.io.InputStream, String).name - a human-readable name for this filter.public boolean hasFilter(String filename)
filename - the filename to examine.
public InputStream filter(InputStream in,
String filename)
throws FilterException
in - the input stream to be filteredfilename - the file name or URL used to decide what filter(s) to apply.
FilterExceptionpublic String getLastFileName()
filter(InputStream, String) with all the filtered extensions removed.
This can be useful if you want to write the filtered version of a file.
Note that this is not thread safe. Another thread could apply a filter
after the current thread but before this method could be called.
filter(InputStream, String)
has never been called for this object.
public static void main(String[] args)
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||