Difference between revisions of "PropertiesHandler"

From GreenVulcano Wiki
Jump to: navigation, search
(Created page with "Class FQN: '''it.greenvulcano.util.metadata.PropertiesHandler''' /** * Helper class for metadata substitution in strings. * * @version 3.0.0 Feb 17, 2010 * @author GreenVulc...")
 
Line 1: Line 1:
 
Class FQN: '''it.greenvulcano.util.metadata.PropertiesHandler'''
 
Class FQN: '''it.greenvulcano.util.metadata.PropertiesHandler'''
  
 +
<syntaxhighlight lang="java5">
 
/**
 
/**
 
  * Helper class for metadata substitution in strings.
 
  * Helper class for metadata substitution in strings.
Line 9: Line 10:
 
  *
 
  *
 
  **/
 
  **/
 
+
</syntaxhighlight>
 
==Following the PropertiesHandler public static methods==
 
==Following the PropertiesHandler public static methods==
  
 
<syntaxhighlight lang="java5">
 
<syntaxhighlight lang="java5">
  
    /**
+
/**
    * @param type
+
* @param type
    * @param handler
+
* @param handler
    */
+
*/
    public static void registerHandler(String type, PropertyHandler handler)
+
public static void registerHandler(String type, PropertyHandler handler)
  
 +
/**
 +
* This method inserts the correct values for the dynamic parameter found in
 +
* the input string. The property value can be a combination of: - fixed : a
 +
* text string; - ${{propname}} : a System property name.
 +
*
 +
* @param str
 +
*        the string to value
 +
* @return the expanded string
 +
*
 +
* @throws PropertiesHandlerException
 +
*        if error occurs and the flag THROWS_EXCEPTION is set
 +
*/
 +
public static String expand(String str) throws PropertiesHandlerException
  
    /**
+
/**
    * This method insert the correct values for the dynamic parameter found in
+
* This method inserts the correct values for the dynamic parameter found in
    * the input string. The property value can be a combination of: - fixed : a
+
* the input string. The property value can be a combination of: - fixed : a
    * text string; - ${{propname}} : a System property name.
+
* text string; - ${{propname}} : a System property name; - @{{propname}} :
    *
+
* a inProperties property name;
    * @param str
+
*
    *        the string to value
+
* @param str
    * @return the expanded string
+
*        the string to value
    *
+
* @param inProperties
    * @throws PropertiesHandlerException
+
*        the hashTable containing the properties
    *        if error occurs and the flag THROWS_EXCEPTION is set
+
* @return the expanded string
    */
+
*
    public static String expand(String str) throws PropertiesHandlerException
+
* @throws PropertiesHandlerException
 +
*        if error occurs and the flag THROWS_EXCEPTION is set
 +
*/
 +
public static String expand(String str, Map<String, Object> inProperties) throws PropertiesHandlerException
  
 +
/**
 +
* This method inserts the correct values for the dynamic parameter found in
 +
* the input string. The property value can be a combination of: - fixed : a
 +
* text string; - %{{class}} : the object class name; - %{{fqclass}} : the
 +
* object fully qualified class name; - %{{package}} : the object package
 +
* name; - ${{propname}} : a System property name; - @{{propname}} : a
 +
* inProperties property name;
 +
*
 +
* @param str
 +
*        the string to value
 +
* @param inProperties
 +
*        the hashTable containing the properties
 +
* @param obj
 +
*        the object to work with
 +
* @return the expanded string
 +
*
 +
* @throws PropertiesHandlerException
 +
*        if error occurs and the flag THROWS_EXCEPTION is set
 +
*/
 +
public static String expand(String str, Map<String, Object> inProperties, Object obj)
 +
        throws PropertiesHandlerException
  
    /**
+
/**
    * This method insert the correct values for the dynamic parameter found in
+
* This method inserts the correct values for the dynamic parameter found in
    * the input string. The property value can be a combination of: - fixed : a
+
* the input string. The property value can be a combination of: - fixed : a
    * text string; - ${{propname}} : a System property name; - @{{propname}} :
+
* text string; - %{{class}} : the object class name; - %{{fqclass}} : the
    * a inProperties property name;
+
* object fully qualified class name; - %{{package}} : the obj package name;
    *
+
* - ${{propname}} : a System property name; - @{{propname}} : a
    * @param str
+
* inProperties property name; - &{{script}} : a JavaScript script;
    *        the string to value
+
*
    * @param inProperties
+
* @param str
    *        the hashTable containing the properties
+
*        the string to value
    * @return the expanded string
+
* @param inProperties
    *
+
*        the hashTable containing the properties
    * @throws PropertiesHandlerException
+
* @param obj
    *        if error occurs and the flag THROWS_EXCEPTION is set
+
*        the object to work with
    */
+
* @param scope
    public static String expand(String str, Map<String, Object> inProperties) throws PropertiesHandlerException
+
*        the JavaScript scope
 +
* @return the expanded string
 +
*
 +
* @throws PropertiesHandlerException
 +
*        if error occurs and the flag THROWS_EXCEPTION is set
 +
*/
 +
public static String expand(String str, Map<String, Object> inProperties, Object obj, Scriptable scope)
 +
        throws PropertiesHandlerException
  
 +
/**
 +
* This method inserts the correct values for the dynamic parameter found in
 +
* the input string. The property value can be a combination of: - fixed : a
 +
* text string; - %{{class}} : the object class name; - %{{fqclass}} : the
 +
* object fully qualified class name; - %{{package}} : the object package
 +
* name; - ${{propname}} : a System property name; - @{{propname}} : a
 +
* inProperties property name; - &{{script}} : a JavaScript script;
 +
*
 +
* @param str
 +
*        the string to value
 +
* @param inProperties
 +
*        the hashTable containing the properties
 +
* @param obj
 +
*        the object to work with
 +
* @param scope
 +
*        the JavaScript scope
 +
* @param extra
 +
*        a extra object passed to property handlers
 +
* @return the expanded string
 +
*
 +
* @throws PropertiesHandlerException
 +
*        if error occurs and the flag THROWS_EXCEPTION is set
 +
*/
 +
public static String expand(String str, Map<String, Object> inProperties, Object obj, Scriptable scope, Object extra)
 +
        throws PropertiesHandlerException
  
    /**
+
/**
    * This method insert the correct values for the dynamic parameter found in
+
* @param type
    * the input string. The property value can be a combination of: - fixed : a
+
* @param value
    * text string; - %{{class}} : the object class name; - %{{fqclass}} : the
+
* @param inProperties
    * object fully qualified class name; - %{{package}} : the object package
+
* @param obj
    * name; - ${{propname}} : a System property name; - @{{propname}} : a
+
* @param scope
    * inProperties property name;
+
* @param extra
    *
+
*        a extra object passed to property handlers
    * @param str
+
* @return the expanded string
    *        the string to value
+
* @throws PropertiesHandlerException
    * @param inProperties
+
*/
    *        the hashTable containing the properties
+
public static String expandInternal(String type, String value, Map<String, Object> inProperties, Object obj,
    * @param obj
+
        Scriptable scope, Object extra) throws PropertiesHandlerException
    *        the object to work with
 
    * @return the expanded string
 
    *
 
    * @throws PropertiesHandlerException
 
    *        if error occurs and the flag THROWS_EXCEPTION is set
 
    */
 
    public static String expand(String str, Map<String, Object> inProperties, Object obj)
 
            throws PropertiesHandlerException
 
  
 +
/**
 +
* Enables the exception throwing on errors, for the current thread.
 +
*
 +
* Example:
 +
*
 +
* <pre>
 +
*
 +
*    ...
 +
*    PropertiesHandler.enableExceptionOnErrors();
 +
*    try {
 +
*        ...
 +
*        String value = PropertiesHandler.expand(...);
 +
*        ...
 +
*    }
 +
*    catch (PropertiesHandlerException exc) {
 +
*        ...
 +
*    }
 +
*    finally {
 +
*        PropertiesHandler.disableExceptionOnErrors();
 +
*    }
 +
*
 +
* </pre>
 +
*/
 +
public static void enableExceptionOnErrors()
  
    /**
+
/**
    * This method insert the correct values for the dynamic parameter found in
+
* Disables the exception throwing on errors, for the current thread.
    * the input string. The property value can be a combination of: - fixed : a
+
*
    * text string; - %{{class}} : the object class name; - %{{fqclass}} : the
+
*/
    * object fully qualified class name; - %{{package}} : the obj package name;
+
public static void disableExceptionOnErrors()
    * - ${{propname}} : a System property name; - @{{propname}} : a
 
    * inProperties property name; - &{{script}} : a JavaScript script;
 
    *
 
    * @param str
 
    *        the string to value
 
    * @param inProperties
 
    *        the hashTable containing the properties
 
    * @param obj
 
    *        the object to work with
 
    * @param scope
 
    *        the JavaScript scope
 
    * @return the expanded string
 
    *
 
    * @throws PropertiesHandlerException
 
    *        if error occurs and the flag THROWS_EXCEPTION is set
 
    */
 
    public static String expand(String str, Map<String, Object> inProperties, Object obj, Scriptable scope)
 
            throws PropertiesHandlerException
 
  
 +
/**
 +
* Checks if the exception throwing on errors is enabled for the current
 +
* thread.
 +
*
 +
* @return if the exception throwing on errors is enabled for the current
 +
*        thread.
 +
*
 +
*/
 +
public static boolean isExceptionOnErrors()
  
    /**
+
/**
    * This method insert the correct values for the dynamic parameter found in
+
* Checks if the input string need to be processed.
    * the input string. The property value can be a combination of: - fixed : a
+
*
    * text string; - %{{class}} : the object class name; - %{{fqclass}} : the
+
* @param str
    * object fully qualified class name; - %{{package}} : the object package
+
*        the string to check
    * name; - ${{propname}} : a System property name; - @{{propname}} : a
+
* @return true if the string is processed
    * inProperties property name; - &{{script}} : a JavaScript script;
+
*/
    *
+
public static boolean isExpanded(String str)
    * @param str
 
    *        the string to value
 
    * @param inProperties
 
    *        the hashTable containing the properties
 
    * @param obj
 
    *        the object to work with
 
    * @param scope
 
    *        the JavaScript scope
 
    * @param extra
 
    *        a extra object passed to property handlers
 
    * @return the expanded string
 
    *
 
    * @throws PropertiesHandlerException
 
    *        if error occurs and the flag THROWS_EXCEPTION is set
 
    */
 
    public static String expand(String str, Map<String, Object> inProperties, Object obj, Scriptable scope, Object extra)
 
            throws PropertiesHandlerException
 
 
 
 
 
    /**
 
    * @param type
 
    * @param value
 
    * @param inProperties
 
    * @param obj
 
    * @param scope
 
    * @param extra
 
    *        a extra object passed to property handlers
 
    * @return the expanded string
 
    * @throws PropertiesHandlerException
 
    */
 
    public static String expandInternal(String type, String value, Map<String, Object> inProperties, Object obj,
 
            Scriptable scope, Object extra) throws PropertiesHandlerException
 
 
 
    /**
 
    * @param token
 
    * @param mdt
 
    */
 
    private static void parse(PropertyToken token, MetaDataTokenizer mdt)
 
 
 
 
 
    /**
 
    * Enable the exception throwing on errors, for the current thread.
 
    *
 
    * Example:
 
    *
 
    * <pre>
 
    *
 
    *    ...
 
    *    PropertiesHandler.enableExceptionOnErrors();
 
    *    try {
 
    *        ...
 
    *        String value = PropertiesHandler.expand(...);
 
    *        ...
 
    *    }
 
    *    catch (PropertiesHandlerException exc) {
 
    *        ...
 
    *    }
 
    *    finally {
 
    *        PropertiesHandler.disableExceptionOnErrors();
 
    *    }
 
    *
 
    * </pre>
 
    */
 
    public static void enableExceptionOnErrors()
 
 
 
 
 
    /**
 
    * Disable the exception throwing on errors, for the current thread.
 
    *
 
    */
 
    public static void disableExceptionOnErrors()
 
 
 
 
 
    /**
 
    * Check if the exception throwing on errors is enabled for the current
 
    * thread.
 
    *
 
    * @return if the exception throwing on errors is enabled for the current
 
    *        thread.
 
    *
 
    */
 
    public static boolean isExceptionOnErrors()
 
 
 
    /**
 
    * Check if the input string need to be processed.
 
    *
 
    * @param str
 
    *        the string to check
 
    * @return true if the string is processed
 
    */
 
    public static boolean isExpanded(String str)
 
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 13:18, 18 December 2012

Class FQN: it.greenvulcano.util.metadata.PropertiesHandler

/**
 * Helper class for metadata substitution in strings.
 *
 * @version 3.0.0 Feb 17, 2010
 * @author GreenVulcano Developer Team
 *
 *
 **/

Following the PropertiesHandler public static methods

/**
* @param type
* @param handler
*/
public static void registerHandler(String type, PropertyHandler handler)

/**
* This method inserts the correct values for the dynamic parameter found in
* the input string. The property value can be a combination of: - fixed : a
* text string; - ${{propname}} : a System property name.
*
* @param str
*        the string to value
* @return the expanded string
*
* @throws PropertiesHandlerException
*         if error occurs and the flag THROWS_EXCEPTION is set
*/
public static String expand(String str) throws PropertiesHandlerException

/**
* This method inserts the correct values for the dynamic parameter found in
* the input string. The property value can be a combination of: - fixed : a
* text string; - ${{propname}} : a System property name; - @{{propname}} :
* a inProperties property name;
*
* @param str
*        the string to value
* @param inProperties
*        the hashTable containing the properties
* @return the expanded string
*
* @throws PropertiesHandlerException
*         if error occurs and the flag THROWS_EXCEPTION is set
*/
public static String expand(String str, Map<String, Object> inProperties) throws PropertiesHandlerException

/**
* This method inserts the correct values for the dynamic parameter found in
* the input string. The property value can be a combination of: - fixed : a
* text string; - %{{class}} : the object class name; - %{{fqclass}} : the
* object fully qualified class name; - %{{package}} : the object package
* name; - ${{propname}} : a System property name; - @{{propname}} : a
* inProperties property name;
*
* @param str
*        the string to value
* @param inProperties
*        the hashTable containing the properties
* @param obj
*        the object to work with
* @return the expanded string
*
* @throws PropertiesHandlerException
*         if error occurs and the flag THROWS_EXCEPTION is set
*/
public static String expand(String str, Map<String, Object> inProperties, Object obj)
         throws PropertiesHandlerException

/**
* This method inserts the correct values for the dynamic parameter found in
* the input string. The property value can be a combination of: - fixed : a
* text string; - %{{class}} : the object class name; - %{{fqclass}} : the
* object fully qualified class name; - %{{package}} : the obj package name;
* - ${{propname}} : a System property name; - @{{propname}} : a
* inProperties property name; - &{{script}} : a JavaScript script;
*
* @param str
*        the string to value
* @param inProperties
*        the hashTable containing the properties
* @param obj
*        the object to work with
* @param scope
*        the JavaScript scope
* @return the expanded string
*
* @throws PropertiesHandlerException
*         if error occurs and the flag THROWS_EXCEPTION is set
*/
public static String expand(String str, Map<String, Object> inProperties, Object obj, Scriptable scope)
         throws PropertiesHandlerException

/**
* This method inserts the correct values for the dynamic parameter found in
* the input string. The property value can be a combination of: - fixed : a
* text string; - %{{class}} : the object class name; - %{{fqclass}} : the
* object fully qualified class name; - %{{package}} : the object package
* name; - ${{propname}} : a System property name; - @{{propname}} : a
* inProperties property name; - &{{script}} : a JavaScript script;
*
* @param str
*        the string to value
* @param inProperties
*        the hashTable containing the properties
* @param obj
*        the object to work with
* @param scope
*        the JavaScript scope
* @param extra
*        a extra object passed to property handlers
* @return the expanded string
*
* @throws PropertiesHandlerException
*         if error occurs and the flag THROWS_EXCEPTION is set
*/
public static String expand(String str, Map<String, Object> inProperties, Object obj, Scriptable scope, Object extra)
         throws PropertiesHandlerException

/**
* @param type
* @param value
* @param inProperties
* @param obj
* @param scope
* @param extra
*        a extra object passed to property handlers
* @return the expanded string
* @throws PropertiesHandlerException
*/
public static String expandInternal(String type, String value, Map<String, Object> inProperties, Object obj,
         Scriptable scope, Object extra) throws PropertiesHandlerException

/**
* Enables the exception throwing on errors, for the current thread.
*
* Example:
*
* <pre>
*
*     ...
*     PropertiesHandler.enableExceptionOnErrors();
*     try {
*        ...
*        String value = PropertiesHandler.expand(...);
*        ...
*     }
*     catch (PropertiesHandlerException exc) {
*        ...
*     }
*     finally {
*        PropertiesHandler.disableExceptionOnErrors();
*     }
*
* </pre>
*/
public static void enableExceptionOnErrors()

/**
* Disables the exception throwing on errors, for the current thread.
*
*/
public static void disableExceptionOnErrors()

/**
* Checks if the exception throwing on errors is enabled for the current
* thread.
*
* @return if the exception throwing on errors is enabled for the current
*         thread.
*
*/
public static boolean isExceptionOnErrors()

/**
* Checks if the input string need to be processed.
*
* @param str
*        the string to check
* @return true if the string is processed
*/
public static boolean isExpanded(String str)