org.kde.koala

Class KURIFilter

public class KURIFilter extends Object implements 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.

UNKNOWN: Filters a given URL into its proper format whenever possible.

Constructor Summary
protected KURIFilter(Class dummy)
KURIFilter()
A protected constructor.
Method Summary
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
KURLfilteredURI(KURL uri, String[] filters)
Returns the filtered URI.
KURLfilteredURI(KURL uri)
StringfilteredURI(String uri, String[] filters)
Return a filtered string representation of a URI.
StringfilteredURI(String uri)
booleanfilterURI(KURIFilterData data, String[] filters)
Filters the URI given by the object URIFilterData.
booleanfilterURI(KURIFilterData data)
booleanfilterURI(KURL uri, String[] filters)
Filters the URI given by the URL.
booleanfilterURI(KURL uri)
booleanfilterURI(StringBuffer uri, String[] filters)
Filters a string representing a URI.
booleanfilterURI(StringBuffer uri)
protected voidfinalize()
Deletes the wrapped C++ instance
booleanisDisposed()
Has the wrapped C++ instance been deleted?
protected voidloadPlugins()
Loads all allowed plugins.
ArrayListpluginNames()
Return a list of the names of all loaded plugins.
static KURIFilterself()
Returns an instance of KURIFilter.

Constructor Detail

KURIFilter

protected KURIFilter(Class dummy)

KURIFilter

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

UNKNOWN: A protected constructor.

Method Detail

dispose

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

filteredURI

public KURL filteredURI(KURL uri, 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

UNKNOWN: Returns the filtered URI.

filteredURI

public KURL filteredURI(KURL uri)

filteredURI

public String filteredURI(String uri, 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

UNKNOWN: Return a filtered string representation of a URI.

filteredURI

public String filteredURI(String uri)

filterURI

public boolean filterURI(KURIFilterData data, 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

UNKNOWN: Filters the URI given by the object URIFilterData.

filterURI

public boolean filterURI(KURIFilterData data)

filterURI

public boolean filterURI(KURL uri, 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

UNKNOWN: Filters the URI given by the URL.

filterURI

public boolean filterURI(KURL uri)

filterURI

public boolean filterURI(StringBuffer uri, 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

UNKNOWN: Filters a string representing a URI.

filterURI

public boolean filterURI(StringBuffer uri)

finalize

protected void finalize()
Deletes the wrapped C++ instance

isDisposed

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

loadPlugins

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

UNKNOWN: Loads all allowed plugins.

pluginNames

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

Returns: an ArrayList of plugin names

UNKNOWN: Return a list of the names of all loaded plugins.

self

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

UNKNOWN: Returns an instance of KURIFilter.