org.kde.koala
Class KURIFilter

java.lang.Object
  extended by org.kde.koala.KURIFilter
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KURIFilter
extends java.lang.Object
implements org.kde.qt.QtSupport

Manages the filtering of URIs. The intention of this plugin class is to allow people to extend the functionality of KURL without modifying it directly. This way KURL will remain a generic parser capable of parsing any generic URL that adheres to specifications. The KURIFilter class applies a number of filters to a URI and returns the filtered version whenever possible. The filters are implemented using plugins to provide easy extensibility of the filtering mechanism. New filters can be added in the future by simply inheriting from KURIFilterPlugin and implementing the KURIFilterPlugin.filterURI method. Use of this plugin-manager class is straight forward. Since it is a singleton object, all you have to do is obtain an instance by doing KURIFilter.self() and use any of the public member functions to preform the filtering. xample To simply filter a given string:

 boolean filtered = KURIFilter.self().filterURI( "kde.org" );
 
You can alternatively use a KURL:
 KURL url = "kde.org";
 boolean filtered = KURIFilter.self().filterURI( url );
 
If you have a constant string or a constant URL, simply invoke the corresponding function to obtain the filtered string or URL instead of a booleanean flag:
 String u = KURIFilter.self().filteredURI( "kde.org" );
 
You can also restrict the filter(s) to be used by supplying the name of the filter(s) to use. By defualt all available filters will be used. To use specific filters, add the names of the filters you want to use to an ArrayList and invoke the appropriate filtering function. The examples below show the use of specific filters. The first one uses a single filter called kshorturifilter while the second example uses multiple filters:
 String text = "kde.org";
 boolean filtered = KURIFilter.self().filterURI( text, "kshorturifilter" );
 
 ArrayList list;
 list << "kshorturifilter" << "localdomainfilter";
 boolean filtered = KURIFilter.self().filterURI( text, list );
 
KURIFilter also allows richer data exchange through a simple meta-object called KURIFilterData. Using this meta-object you can find out more information about the URL you want to filter. See KURIFilterData for examples and details.


Constructor Summary
  KURIFilter()
          A protected constructor.
protected KURIFilter(java.lang.Class dummy)
           
 
Method Summary
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
 KURL filteredURI(KURL uri)
           
 KURL filteredURI(KURL uri, java.lang.String[] filters)
          Returns the filtered URI.
 java.lang.String filteredURI(java.lang.String uri)
           
 java.lang.String filteredURI(java.lang.String uri, java.lang.String[] filters)
          Return a filtered string representation of a URI.
 boolean filterURI(KURIFilterData data)
           
 boolean filterURI(KURIFilterData data, java.lang.String[] filters)
          Filters the URI given by the object URIFilterData.
 boolean filterURI(KURL uri)
           
 boolean filterURI(KURL uri, java.lang.String[] filters)
          Filters the URI given by the URL.
 boolean filterURI(java.lang.StringBuffer uri)
           
 boolean filterURI(java.lang.StringBuffer uri, java.lang.String[] filters)
          Filters a string representing a URI.
protected  void finalize()
          Deletes the wrapped C++ instance
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
protected  void loadPlugins()
          Loads all allowed plugins.
 java.util.ArrayList pluginNames()
          Return a list of the names of all loaded plugins.
static KURIFilter self()
          Returns an instance of KURIFilter.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KURIFilter

protected KURIFilter(java.lang.Class dummy)

KURIFilter

public KURIFilter()
A protected constructor. This constructor creates a KURIFilter and initializes all plugins it can find by invoking loadPlugins.

Method Detail

filterURI

public boolean filterURI(KURIFilterData data,
                         java.lang.String[] filters)
Filters the URI given by the object URIFilterData. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

Parameters:
data - object that contains the URI to be filtered.
filters - specify the list of filters to be used.
Returns:
a boolean indicating whether the URI has been changed

filterURI

public boolean filterURI(KURIFilterData data)

filterURI

public boolean filterURI(KURL uri,
                         java.lang.String[] filters)
Filters the URI given by the URL. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

Parameters:
uri - the URI to filter.
filters - specify the list of filters to be used.
Returns:
a boolean indicating whether the URI has been changed

filterURI

public boolean filterURI(KURL uri)

filterURI

public boolean filterURI(java.lang.StringBuffer uri,
                         java.lang.String[] filters)
Filters a string representing a URI. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

Parameters:
uri - The URI to filter.
filters - specify the list of filters to be used.
Returns:
a boolean indicating whether the URI has been changed

filterURI

public boolean filterURI(java.lang.StringBuffer uri)

filteredURI

public KURL filteredURI(KURL uri,
                        java.lang.String[] filters)
Returns the filtered URI. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

Parameters:
uri - The URI to filter.
filters - specify the list of filters to be used.
Returns:
the filtered URI or null if it cannot be filtered

filteredURI

public KURL filteredURI(KURL uri)

filteredURI

public java.lang.String filteredURI(java.lang.String uri,
                                    java.lang.String[] filters)
Return a filtered string representation of a URI. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used.

Parameters:
uri - the URI to filter.
filters - specify the list of filters to be used.
Returns:
the filtered URI or null if it cannot be filtered

filteredURI

public java.lang.String filteredURI(java.lang.String uri)

pluginNames

public java.util.ArrayList pluginNames()
Return a list of the names of all loaded plugins.

Returns:
an ArrayList of plugin names

self

public static KURIFilter self()
Returns an instance of KURIFilter.


loadPlugins

protected void loadPlugins()
Loads all allowed plugins. This function loads all filters that have not been disbled.


finalize

protected void finalize()
                 throws java.lang.InternalError
Deletes the wrapped C++ instance

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.InternalError

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()


isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?