org.apache.geronimo.mail.util
Class SessionUtil

java.lang.Object
  extended by org.apache.geronimo.mail.util.SessionUtil

public class SessionUtil
extends Object

Simple utility class for managing session properties.


Constructor Summary
SessionUtil()
           
 
Method Summary
static boolean getBooleanProperty(Session session, String name, boolean defaultValue)
          Get a property associated with this mail session as a boolean value.
static boolean getBooleanProperty(String name, boolean defaultValue)
          Get a system property associated with this mail session as a boolean value.
static int getIntProperty(Session session, String name, int defaultValue)
          Get a property associated with this mail session as an integer value.
static String getProperty(Session session, String name)
          Get a property associated with this mail session.
static String getProperty(Session session, String name, String defaultValue)
          Get a property associated with this mail session.
static String getProperty(String name)
          Get a system property associated with this mail session as a boolean value.
static String getProperty(String name, String defaultValue)
          Get a system property associated with this mail session as a boolean value.
static boolean isPropertyFalse(Session session, String name)
          Process a session property as a boolean value, returning either true or false.
static boolean isPropertyTrue(Session session, String name)
          Process a session property as a boolean value, returning either true or false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionUtil

public SessionUtil()
Method Detail

getProperty

public static String getProperty(Session session,
                                 String name)
Get a property associated with this mail session. Returns the provided default if it doesn't exist.

Parameters:
session - The attached session.
name - The name of the property.
Returns:
The property value (returns null if the property has not been set).

getProperty

public static String getProperty(Session session,
                                 String name,
                                 String defaultValue)
Get a property associated with this mail session. Returns the provided default if it doesn't exist.

Parameters:
session - The attached session.
name - The name of the property.
defaultValue - The default value to return if the property doesn't exist.
Returns:
The property value (returns defaultValue if the property has not been set).

isPropertyTrue

public static boolean isPropertyTrue(Session session,
                                     String name)
Process a session property as a boolean value, returning either true or false.

Parameters:
session - The source session.
name -
Returns:
True if the property value is "true". Returns false for any other value (including null).

isPropertyFalse

public static boolean isPropertyFalse(Session session,
                                      String name)
Process a session property as a boolean value, returning either true or false.

Parameters:
session - The source session.
name -
Returns:
True if the property value is "false". Returns false for other value (including null).

getIntProperty

public static int getIntProperty(Session session,
                                 String name,
                                 int defaultValue)
Get a property associated with this mail session as an integer value. Returns the default value if the property doesn't exist or it doesn't have a valid int value.

Parameters:
session - The source session.
name - The name of the property.
defaultValue - The default value to return if the property doesn't exist.
Returns:
The property value converted to an int.

getBooleanProperty

public static boolean getBooleanProperty(Session session,
                                         String name,
                                         boolean defaultValue)
Get a property associated with this mail session as a boolean value. Returns the default value if the property doesn't exist or it doesn't have a valid boolean value.

Parameters:
session - The source session.
name - The name of the property.
defaultValue - The default value to return if the property doesn't exist.
Returns:
The property value converted to a boolean.

getBooleanProperty

public static boolean getBooleanProperty(String name,
                                         boolean defaultValue)
Get a system property associated with this mail session as a boolean value. Returns the default value if the property doesn't exist or it doesn't have a valid boolean value.

Parameters:
name - The name of the property.
defaultValue - The default value to return if the property doesn't exist.
Returns:
The property value converted to a boolean.

getProperty

public static String getProperty(String name,
                                 String defaultValue)
Get a system property associated with this mail session as a boolean value. Returns the default value if the property doesn't exist.

Parameters:
name - The name of the property.
defaultValue - The default value to return if the property doesn't exist.
Returns:
The property value

getProperty

public static String getProperty(String name)
Get a system property associated with this mail session as a boolean value. Returns the default value if the property doesn't exist.

Parameters:
name - The name of the property.
Returns:
The property value


Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.