wjhk.jupload2.context
Interface JUploadContext

All Known Implementing Classes:
DefaultJUploadContext, JUploadContextApplet, JUploadContextExecutable

public interface JUploadContext

This interface it used in upload policies to get information on the current Context. This context is responsible for:

  • Reading parameters from the environment or the applet parameters.
  • Storing the current UploadPolicy (or null if not set yet)
  • Author:
    etienne_sf

    Method Summary
     void displayURL(java.lang.String url, boolean success)
              Displays a given URL, in the given target.
     javax.swing.JApplet getApplet()
              Retrieves the current applet.
     java.lang.String getBuildDate()
               
     int getBuildNumber()
               
     java.awt.Cursor getCursor()
               
     java.lang.String getLastModified()
               
     JUploadTextArea getLogWindow()
              Retrieves the current log window of this applet.
     java.lang.String getMimeType(java.lang.String fileExtension)
              Returns the mime type associated with the given file extension.
     boolean getParameter(java.lang.String key, boolean def)
              Get a boolean parameter value from applet properties or System properties.
     float getParameter(java.lang.String key, float def)
              Get a String parameter value from applet properties or System properties.
     int getParameter(java.lang.String key, int def)
              Get a String parameter value from applet properties or System properties.
     long getParameter(java.lang.String key, long def)
              Get a String parameter value from applet properties or System properties.
     java.lang.String getParameter(java.lang.String key, java.lang.String def)
              Get a String parameter value from applet properties or System properties.
     JUploadPanel getUploadPanel()
              Retrieves the current upload panel.
     UploadPolicy getUploadPolicy()
              This method the current UploadPolicy, associated with the current execution context.
     java.lang.String getVersion()
               
     java.lang.String normalizeURL(java.lang.String url)
              Generates a valid URL, from a String.
     boolean parseBoolean(java.lang.String value, boolean def)
              This function try to parse value as a boolean.
     float parseFloat(java.lang.String value, float def)
              This function try to parse value as a float number.
     int parseInt(java.lang.String value, int def)
              This function try to parse value as an integer.
     long parseLong(java.lang.String value, long def)
              This function try to parse value as a Long.
     void readCookieFromNavigator(java.util.Vector<java.lang.String> headers)
              This method allows to read the navigator cookies.
     void readUserAgentFromNavigator(java.util.Vector<java.lang.String> headers)
              This method allows to read the navigator userAgent.
     void registerUnload(java.lang.Object o, java.lang.String method)
              Register a callback to be executed during applet termination.
     void runUnload()
              Runs all callback that must be called when releasing the applet.
     java.awt.Cursor setCursor(java.awt.Cursor cursor)
               
     void setProperty(java.lang.String prop, java.lang.String value)
              This allow runtime modifications of properties, from javascript.
     java.awt.Cursor setWaitCursor()
              Sets the wait cursor on the current application (applet, executable...).
     void showStatus(java.lang.String status)
              Displays a message in the status window.
     java.lang.String startUpload()
              Public method that can be called by Javascript to start upload
     

    Method Detail

    getVersion

    java.lang.String getVersion()
    Returns:
    The 'official' version (applet version and SVN revision)

    getLastModified

    java.lang.String getLastModified()
    Returns:
    Last modification date (date of last commit)

    getBuildDate

    java.lang.String getBuildDate()
    Returns:
    Last modification date (date of last commit)

    getBuildNumber

    int getBuildNumber()
    Returns:
    Last modification date (date of last commit)

    displayURL

    void displayURL(java.lang.String url,
                    boolean success)
    Displays a given URL, in the given target. The target is meant in html <A> tag, and may be ignored if not relevant.

    Parameters:
    url - The URL to display, in text format. It will be normalized 'before use'.
    success - Indicates whether the upload was a success or not.

    getApplet

    javax.swing.JApplet getApplet()
    Retrieves the current applet. This call is still used by ByteArrayEncoderHTTP, to append form variable. It will be removed, in the future.

    Returns:
    The current applet, or null if not running in an applet

    getLogWindow

    JUploadTextArea getLogWindow()
    Retrieves the current log window of this applet. This log window may visible or not depending on various applet parameter.

    Returns:
    the current log window of this instance.
    See Also:
    JUploadPanel.showOrHideLogWindow()

    getMimeType

    java.lang.String getMimeType(java.lang.String fileExtension)
    Returns the mime type associated with the given file extension. As the applet may run on windows, the fileExtension is always changed to minor case, before looking for the corresponding mime type.

    Parameters:
    fileExtension - The file extension, in any case.
    Returns:
    Returns the current mime type, for this extension.

    getUploadPanel

    JUploadPanel getUploadPanel()
    Retrieves the current upload panel.

    Returns:
    the current upload panel of this instance.

    getUploadPolicy

    UploadPolicy getUploadPolicy()
    This method the current UploadPolicy, associated with the current execution context. This UploadPolicy is set once, when the application start. It can not change afterwards.

    Returns:
    The current UploadPolicy, or null of the uploadPolicy has not been set yet.

    getCursor

    java.awt.Cursor getCursor()
    Returns:
    The current cursor.
    See Also:
    UploadPolicy.setCursor(Cursor)

    setCursor

    java.awt.Cursor setCursor(java.awt.Cursor cursor)
    Parameters:
    cursor - The cursor to set
    Returns:
    The Cursor that was active, before setting the new one. It's up to the caller to remind it, to be able to restore it if necessary.
    See Also:
    UploadPolicy.setCursor(Cursor)

    setWaitCursor

    java.awt.Cursor setWaitCursor()
    Sets the wait cursor on the current application (applet, executable...).

    Returns:
    The cursor that was active before the call to this method
    See Also:
    UploadPolicy.setCursor(Cursor)

    showStatus

    void showStatus(java.lang.String status)
    Displays a message in the status window.

    Parameters:
    status -

    getParameter

    java.lang.String getParameter(java.lang.String key,
                                  java.lang.String def)
    Get a String parameter value from applet properties or System properties.

    Parameters:
    key - The name of the parameter to fetch.
    def - A default value which is used, when the specified parameter is not set.
    Returns:
    The value of the applet parameter (resp. system property). If the parameter was not specified or no such system property exists, returns the given default value.

    getParameter

    int getParameter(java.lang.String key,
                     int def)
    Get a String parameter value from applet properties or System properties.

    Parameters:
    key - The parameter name
    def - The default value
    Returns:
    the parameter value, or the default, if the system is not set.

    getParameter

    float getParameter(java.lang.String key,
                       float def)
    Get a String parameter value from applet properties or System properties.

    Parameters:
    key - The parameter name
    def - The default value
    Returns:
    the parameter value, or the default, if the system is not set.

    getParameter

    long getParameter(java.lang.String key,
                      long def)
    Get a String parameter value from applet properties or System properties.

    Parameters:
    key - The parameter name
    def - The default value
    Returns:
    the parameter value, or the default, if the system is not set.

    getParameter

    boolean getParameter(java.lang.String key,
                         boolean def)
    Get a boolean parameter value from applet properties or System properties.

    Parameters:
    key - The parameter name
    def - The default value
    Returns:
    the parameter value, or the default, if the system is not set.

    parseInt

    int parseInt(java.lang.String value,
                 int def)
    This function try to parse value as an integer. If value is not a correct integer, def is returned.

    Parameters:
    value - The string value, that must be parsed
    def - The default value
    Returns:
    The integer value of value, or def if value is not valid.

    parseFloat

    float parseFloat(java.lang.String value,
                     float def)
    This function try to parse value as a float number. If value is not a correct float, def is returned.

    Parameters:
    value - The string value, that must be parsed
    def - The default value
    Returns:
    The float value of value, or def if value is not valid.

    parseLong

    long parseLong(java.lang.String value,
                   long def)
    This function try to parse value as a Long. If value is not a correct long, def is returned.

    Parameters:
    value - The string value, that must be parsed
    def - The default value
    Returns:
    The integer value of value, or def if value is not valid.

    parseBoolean

    boolean parseBoolean(java.lang.String value,
                         boolean def)
    This function try to parse value as a boolean. If value is not a correct boolean, def is returned.

    Parameters:
    value - The new value for this property. If invalid, the default value is used.
    def - The default value: used if value is invalid.
    Returns:
    The boolean value of value, or def if value is not a valid boolean.

    readCookieFromNavigator

    void readCookieFromNavigator(java.util.Vector<java.lang.String> headers)
    This method allows to read the navigator cookies. These items will be added as headers, in the given Vector.

    Parameters:
    headers - The headers, coming from DefaultUploadPolicy

    readUserAgentFromNavigator

    void readUserAgentFromNavigator(java.util.Vector<java.lang.String> headers)
    This method allows to read the navigator userAgent. It will be added as headers, in the given Vector.

    Parameters:
    headers - The headers, coming from DefaultUploadPolicy

    normalizeURL

    java.lang.String normalizeURL(java.lang.String url)
                                  throws JUploadException
    Generates a valid URL, from a String. The generation may add the documentBase of the applet.

    Parameters:
    url - A url. Can be a path relative to the current one.
    Returns:
    The normalized URL
    Throws:
    JUploadException

    registerUnload

    void registerUnload(java.lang.Object o,
                        java.lang.String method)
    Register a callback to be executed during applet termination.

    Parameters:
    o - The Object instance to be registered
    method - The Method of that object to be registered. The method must be of type void and must not take any parameters and must be public.

    runUnload

    void runUnload()
    Runs all callback that must be called when releasing the applet.


    setProperty

    void setProperty(java.lang.String prop,
                     java.lang.String value)
    This allow runtime modifications of properties, from javascript. Currently, this can only be used after full initialization. This method only calls the UploadPolicy.setProperty method.
    Ex: document.jupload.setProperty(prop, value);

    Parameters:
    prop - The property name that must be set.
    value - The value of this property.

    startUpload

    java.lang.String startUpload()
    Public method that can be called by Javascript to start upload

    Returns:
    Returns the upload result. See the constants defined in the JavascriptHandler javadoc.