org.kde.koala
Class KURIFilterData

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

public class KURIFilterData
extends java.lang.Object
implements org.kde.qt.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

Field Summary
static int BLOCKED
           
static int ERROR
           
static int EXECUTABLE
           
static int HELP
           
static int LOCAL_DIR
           
static int LOCAL_FILE
           
static int NET_PROTOCOL
          Describes the type of the URI that was filtered.
static int SHELL
           
static int UNKNOWN
           
 
Constructor Summary
  KURIFilterData()
          Default constructor.
protected KURIFilterData(java.lang.Class dummy)
           
  KURIFilterData(KURIFilterData data)
          Copy constructor.
  KURIFilterData(KURL url)
          Creates a URIFilterData object from the given URL.
  KURIFilterData(java.lang.String url)
          Creates a URIFilterData object from the given string.
 
Method Summary
 java.lang.String absolutePath()
          Returns the absolute path if one has already been set.
 java.lang.String argsAndOptions()
          Returns the command line options and arguments for a local resource when present.
 boolean checkForExecutables()
           
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
 java.lang.String errorMsg()
          Returns an error message.
protected  void finalize()
          Deletes the wrapped C++ instance
 boolean hasAbsolutePath()
          Checks whether the supplied data had an absolute path.
 boolean hasArgsAndOptions()
          Checks whether the current data is a local resource with command line options and arguments.
 java.lang.String iconName()
          Returns the name of the icon that matches the current filtered URL.
protected  void init()
           
protected  void init(KURL url)
          Initializes the KURIFilterData on construction.
protected  void init(java.lang.String url)
          Initializes the KURIFilterData on construction.
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 boolean setAbsolutePath(java.lang.String abs_path)
          Sets the absolute path to be used whenever the supplied data is a relative local URL.
 void setCheckForExecutables(boolean check)
          Check whether the provided uri is executable or not.
 void setData(KURL url)
          Same as above except the argument is a URL.
 void setData(java.lang.String url)
          Sets the URL to be filtered.
 java.lang.String typedString()
           
 KURL uri()
          Returns the filtered or the original URL.
 int uriType()
          Returns the URI type.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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.

    See Also:
    Constant Field Values

    LOCAL_FILE

    public static final int LOCAL_FILE
    See Also:
    Constant Field Values

    LOCAL_DIR

    public static final int LOCAL_DIR
    See Also:
    Constant Field Values

    EXECUTABLE

    public static final int EXECUTABLE
    See Also:
    Constant Field Values

    HELP

    public static final int HELP
    See Also:
    Constant Field Values

    SHELL

    public static final int SHELL
    See Also:
    Constant Field Values

    BLOCKED

    public static final int BLOCKED
    See Also:
    Constant Field Values

    ERROR

    public static final int ERROR
    See Also:
    Constant Field Values

    UNKNOWN

    public static final int UNKNOWN
    See Also:
    Constant Field Values
    Constructor Detail

    KURIFilterData

    protected KURIFilterData(java.lang.Class dummy)

    KURIFilterData

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


    KURIFilterData

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

    Parameters:
    url - is the URL to be filtered.

    KURIFilterData

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

    Parameters:
    url - is the string to be filtered.

    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.
    Method Detail

    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.

    errorMsg

    public java.lang.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.

    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

    setData

    public void setData(java.lang.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.

    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.

    setAbsolutePath

    public boolean setAbsolutePath(java.lang.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.

    absolutePath

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

    Returns:
    the absolute path, or null
    See Also:
    hasAbsolutePath()

    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:
    absolutePath()

    argsAndOptions

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

    Returns:
    options and arguments when present, otherwise null

    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

    iconName

    public java.lang.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

    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.


    checkForExecutables

    public boolean checkForExecutables()
    Returns:
    true if the filters should attempt to check whether the supplied uri is an executable. False otherwise.

    typedString

    public java.lang.String typedString()
    Returns:
    the string as typed by the user, before any URL processing is done

    init

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

    Parameters:
    url - the URL to initialize the object with

    init

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

    Parameters:
    url - the URL to initialize the object with

    init

    protected void init()

    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?