org.kde.koala

Class KURIFilterData

public class KURIFilterData extends Object implements QtSupport

A basic message object used for exchanging filtering information between the filter plugins and the application requesting the filtering service. Use this object if you require a more detailed information about the URI you want to filter. Any application can create an instance of this class and send it to KURIFilter to have the plugins fill out all possible information about the URI. xample
   String text = "kde.org";
   KURIFilterData d = text;
   boolean filtered = KURIFilter.self().filter( d );
   cout << "URL: " << text.latin1() << endl
        << "Filtered URL: " << d.uri().url().latin1() << endl
        << "URI Type: " << d.uriType() << endl
        << "Was Filtered: " << filtered << endl;
 
The above code should yield the following output:
   URI: kde.org
   Filtered URI: http://kde.org
   URI Type: 0            <== means NET_PROTOCOL
   Was Filtered: 1        <== means the URL was successfully filtered
 

Author: Dawit Alemayehu

UNKNOWN: A message object for exchanging filtering URI info.

Field Summary
static intBLOCKED
static intERROR
static intEXECUTABLE
static intHELP
static intLOCAL_DIR
static intLOCAL_FILE
static intNET_PROTOCOL
Describes the type of the URI that was filtered.
static intSHELL
static intUNKNOWN
Constructor Summary
protected KURIFilterData(Class dummy)
KURIFilterData()
Default constructor.
KURIFilterData(KURL url)
Creates a URIFilterData object from the given URL.
KURIFilterData(String url)
Creates a URIFilterData object from the given string.
KURIFilterData(KURIFilterData data)
Copy constructor.
Method Summary
StringabsolutePath()
Returns the absolute path if one has already been set.
StringargsAndOptions()
Returns the command line options and arguments for a local resource when present.
booleancheckForExecutables()
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
StringerrorMsg()
Returns an error message.
protected voidfinalize()
Deletes the wrapped C++ instance
booleanhasAbsolutePath()
Checks whether the supplied data had an absolute path.
booleanhasArgsAndOptions()
Checks whether the current data is a local resource with command line options and arguments.
StringiconName()
Returns the name of the icon that matches the current filtered URL.
protected voidinit(KURL url)
Initializes the KURIFilterData on construction.
protected voidinit(String url)
Initializes the KURIFilterData on construction.
protected voidinit()
booleanisDisposed()
Has the wrapped C++ instance been deleted?
booleansetAbsolutePath(String abs_path)
Sets the absolute path to be used whenever the supplied data is a relative local URL.
voidsetCheckForExecutables(boolean check)
Check whether the provided uri is executable or not.
voidsetData(String url)
Sets the URL to be filtered.
voidsetData(KURL url)
Same as above except the argument is a URL.
StringtypedString()
KURLuri()
Returns the filtered or the original URL.
inturiType()
Returns the URI type.

Field Detail

BLOCKED

public static final int BLOCKED

ERROR

public static final int ERROR

EXECUTABLE

public static final int EXECUTABLE

HELP

public static final int HELP

LOCAL_DIR

public static final int LOCAL_DIR

LOCAL_FILE

public static final int LOCAL_FILE

NET_PROTOCOL

public static final int NET_PROTOCOL
Describes the type of the URI that was filtered. Here is a brief description of the types:
  • NET_PROTOCOL - Any network protocol: http, ftp, nttp, pop3, etc...
  • LOCAL_FILE - A local file whose executable flag is not set
  • LOCAL_DIR - A local directory
  • EXECUTABLE - A local file whose executable flag is set
  • HELP - A man or info page
  • SHELL - A shell executable (ex: echo "Test..." >> ~/testfile)
  • BLOCKED - A URI that should be blocked/filtered (ex: ad filtering)
  • ERROR - An incorrect URI (ex: "~johndoe" when user johndoe does not exist in that system )
  • UNKNOWN - A URI that is not identified. Default value when a KURIFilterData is first created.
  • @short Describes the type of the URI that was filtered.

    SHELL

    public static final int SHELL

    UNKNOWN

    public static final int UNKNOWN

    Constructor Detail

    KURIFilterData

    protected KURIFilterData(Class dummy)

    KURIFilterData

    public KURIFilterData()
    Default constructor. Creates a URIFilterData object.

    UNKNOWN: Default constructor.

    KURIFilterData

    public KURIFilterData(KURL url)
    Creates a URIFilterData object from the given URL.

    Parameters: url is the URL to be filtered.

    UNKNOWN: Creates a URIFilterData object from the given URL.

    KURIFilterData

    public KURIFilterData(String url)
    Creates a URIFilterData object from the given string.

    Parameters: url is the string to be filtered.

    UNKNOWN: Creates a URIFilterData object from the given string.

    KURIFilterData

    public KURIFilterData(KURIFilterData data)
    Copy constructor. Creates a URIFilterData object from another URI filter data object.

    Parameters: data the uri filter data to be copied.

    UNKNOWN: Copy constructor.

    Method Detail

    absolutePath

    public String absolutePath()
    Returns the absolute path if one has already been set.

    Returns: the absolute path, or null

    See Also: KURIFilterData

    UNKNOWN: Returns the absolute path if one has already been set.

    argsAndOptions

    public String argsAndOptions()
    Returns the command line options and arguments for a local resource when present.

    Returns: options and arguments when present, otherwise null

    UNKNOWN: Returns the command line options and arguments for a local resource when present.

    checkForExecutables

    public boolean checkForExecutables()

    Returns: true if the filters should attempt to check whether the supplied uri is an executable. False otherwise.

    UNKNOWN:

    dispose

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

    errorMsg

    public String errorMsg()
    Returns an error message. This functions returns the error message set by the plugin whenever the uri type is set to KURIFilterData.ERROR. Otherwise, it returns a null.

    Returns: the error message or a NULL when there is none.

    UNKNOWN: Returns an error message.

    finalize

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

    hasAbsolutePath

    public boolean hasAbsolutePath()
    Checks whether the supplied data had an absolute path.

    Returns: true if the supplied data has an absolute path

    See Also: KURIFilterData

    UNKNOWN: Checks whether the supplied data had an absolute path.

    hasArgsAndOptions

    public boolean hasArgsAndOptions()
    Checks whether the current data is a local resource with command line options and arguments.

    Returns: true if the current data has command line options and arguments

    UNKNOWN: Checks whether the current data is a local resource with command line options and arguments.

    iconName

    public String iconName()
    Returns the name of the icon that matches the current filtered URL. NOTE that this function will return a NULL string by default and when no associated icon is found.

    Returns: the name of the icon associated with the resource, or null if not found

    UNKNOWN: Returns the name of the icon that matches the current filtered URL.

    init

    protected void init(KURL url)
    Initializes the KURIFilterData on construction.

    Parameters: url the URL to initialize the object with

    UNKNOWN: Initializes the KURIFilterData on construction.

    init

    protected void init(String url)
    Initializes the KURIFilterData on construction.

    Parameters: url the URL to initialize the object with

    UNKNOWN: Initializes the KURIFilterData on construction.

    init

    protected void init()

    isDisposed

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

    setAbsolutePath

    public boolean setAbsolutePath(String abs_path)
    Sets the absolute path to be used whenever the supplied data is a relative local URL. NOTE: This function should only be used for local resources, i.e. the "file:/" protocol. It is useful for specifying the absolute path in cases where the actual URL might be relative. meta object. If deriving the path from a KURL, make sure you set the argument for this function to the result of calling path () instead of url ().

    Parameters: abs_path the abolute path to the local resource.

    Returns: true if absolute path is successfully set. Otherwise, false.

    UNKNOWN: Sets the absolute path to be used whenever the supplied data is a relative local URL.

    setCheckForExecutables

    public void setCheckForExecutables(boolean check)
    Check whether the provided uri is executable or not. Setting this to false ensures that typing the name of an executable does not start that application. This is useful in the location bar of a browser. The default value is true.

    UNKNOWN: Check whether the provided uri is executable or not.

    setData

    public void setData(String url)
    Sets the URL to be filtered. Use this function to set the string to be filtered when you construct an empty filter object.

    Parameters: url the string to be filtered.

    UNKNOWN: Sets the URL to be filtered.

    setData

    public void setData(KURL url)
    Same as above except the argument is a URL. Use this function to set the string to be filtered when you construct an empty filter object.

    Parameters: url the URL to be filtered.

    UNKNOWN: Same as above except the argument is a URL.

    typedString

    public String typedString()

    Returns: the string as typed by the user, before any URL processing is done

    UNKNOWN:

    uri

    public KURL uri()
    Returns the filtered or the original URL. This function returns the filtered url if one of the plugins successfully filtered the original URL. Otherwise, it returns the original URL. See hasBeenFiltered() and

    Returns: the filtered or original url.

    UNKNOWN: Returns the filtered or the original URL.

    uriType

    public int uriType()
    Returns the URI type. This method always returns KURIFilterData.UNKNOWN if the given URL was not filtered.

    Returns: the type of the URI

    UNKNOWN: Returns the URI type.