wjhk.jupload2.policies
Class UploadPolicyFactory

java.lang.Object
  extended by wjhk.jupload2.policies.UploadPolicyFactory

public class UploadPolicyFactory
extends Object

This class is used to control creation of the uploadPolicy instance, according to applet parameters (or System properties).

The used parameters are:

Version:
$Revision: 441 $
Author:
etienne_sf

Constructor Summary
UploadPolicyFactory()
           
 
Method Summary
static boolean getParameter(JUploadApplet theApplet, String key, boolean def, UploadPolicy uploadPolicy)
          Get a boolean parameter value from applet properties or System properties.
static float getParameter(JUploadApplet theApplet, String key, float def, UploadPolicy uploadPolicy)
          Get a String parameter value from applet properties or System properties.
static int getParameter(JUploadApplet theApplet, String key, int def, UploadPolicy uploadPolicy)
          Get a String parameter value from applet properties or System properties.
static long getParameter(JUploadApplet theApplet, String key, long def, UploadPolicy uploadPolicy)
          Get a String parameter value from applet properties or System properties.
static String getParameter(JUploadApplet theApplet, String key, String def, UploadPolicy uploadPolicy)
          Get a String parameter value from applet properties or System properties.
static UploadPolicy getUploadPolicy(JUploadApplet theApplet)
          Returns an upload Policy for the given applet and URL.
static boolean parseBoolean(String value, boolean def, UploadPolicy uploadPolicy)
          This function try to parse value as a boolean.
static float parseFloat(String value, float def, UploadPolicy uploadPolicy)
          This function try to parse value as a float number.
static int parseInt(String value, int def, UploadPolicy uploadPolicy)
          This function try to parse value as an integer.
static long parseLong(String value, long def, UploadPolicy uploadPolicy)
          This function try to parse value as a Long.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UploadPolicyFactory

public UploadPolicyFactory()
Method Detail

getUploadPolicy

public static UploadPolicy getUploadPolicy(JUploadApplet theApplet)
                                    throws Exception
Returns an upload Policy for the given applet and URL. All other parameters for the uploadPolicy are take from avaiable applet parameters (or from system properties, if it is not run as an applet).

Parameters:
theApplet - if not null : use this Applet Parameters. If null, use System properties.
Returns:
The newly created UploadPolicy.
Throws:
Exception

getParameter

public static String getParameter(JUploadApplet theApplet,
                                  String key,
                                  String def,
                                  UploadPolicy uploadPolicy)
Get a String parameter value from applet properties or System properties.

Parameters:
theApplet - The applet which provides the parameter. If null, the parameter is retrieved from the system property.
key - The name of the parameter to fetch.
def - A default value which is used, when the specified parameter is not set.
uploadPolicy - Unused
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

public static int getParameter(JUploadApplet theApplet,
                               String key,
                               int def,
                               UploadPolicy uploadPolicy)
Get a String parameter value from applet properties or System properties.

Parameters:
theApplet - The current applet
key - The parameter name
def - The default value
uploadPolicy - The current upload policy
Returns:
the parameter value, or the default, if the system is not set.

getParameter

public static float getParameter(JUploadApplet theApplet,
                                 String key,
                                 float def,
                                 UploadPolicy uploadPolicy)
Get a String parameter value from applet properties or System properties.

Parameters:
theApplet - The current applet
key - The parameter name
def - The default value
uploadPolicy - The current upload policy
Returns:
the parameter value, or the default, if the system is not set.

getParameter

public static long getParameter(JUploadApplet theApplet,
                                String key,
                                long def,
                                UploadPolicy uploadPolicy)
Get a String parameter value from applet properties or System properties.

Parameters:
theApplet - The current applet
key - The parameter name
def - The default value
uploadPolicy - The current upload policy
Returns:
the parameter value, or the default, if the system is not set.

getParameter

public static boolean getParameter(JUploadApplet theApplet,
                                   String key,
                                   boolean def,
                                   UploadPolicy uploadPolicy)
Get a boolean parameter value from applet properties or System properties.

Parameters:
theApplet - The current applet
key - The parameter name
def - The default value
uploadPolicy - The current upload policy
Returns:
the parameter value, or the default, if the system is not set.

parseInt

public static int parseInt(String value,
                           int def,
                           UploadPolicy uploadPolicy)
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
uploadPolicy - The current upload policy
Returns:
The integer value of value, or def if value is not valid.

parseFloat

public static float parseFloat(String value,
                               float def,
                               UploadPolicy uploadPolicy)
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
uploadPolicy - The current upload policy
Returns:
The float value of value, or def if value is not valid.

parseLong

public static long parseLong(String value,
                             long def,
                             UploadPolicy uploadPolicy)
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
uploadPolicy - The current upload policy
Returns:
The integer value of value, or def if value is not valid.

parseBoolean

public static boolean parseBoolean(String value,
                                   boolean def,
                                   UploadPolicy uploadPolicy)
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.
uploadPolicy - If not null, it will be used to display a warning when the value is invalid.
Returns:
The boolean value of value, or def if value is not a valid boolean.