Openfire 3.5.0 Javadoc

org.jivesoftware.util
Class JiveGlobals

java.lang.Object
  extended by org.jivesoftware.util.JiveGlobals

public class JiveGlobals
extends Object

Controls Jive properties. Jive properties are only meant to be set and retrieved by core Jive classes. Some properties may be stored in XML format while others in the database.

When starting up the application this class needs to be configured so that the initial configuration of the application may be loaded from the configuration file. The configuration file holds properties stored in XML format, database configuration and user authentication configuration. Use setHomeDirectory(String) and setConfigName(String) for setting the home directory and path to the configuration file.

XML property names must be in the form prop.name - parts of the name must be seperated by ".". The value can be any valid String, including strings with line breaks.


Field Summary
static boolean failedLoading
           
 
Constructor Summary
JiveGlobals()
           
 
Method Summary
static void deleteProperty(String name)
          Deletes a Jive property.
static void deleteXMLProperty(String name)
          Deletes a locale property.
static String formatDate(Date date)
          Formats a Date object to return a date using the global locale.
static String formatDateTime(Date date)
          Formats a Date object to return a date and time using the global locale.
static String formatTime(Date date)
          Formats a Date object to return a time using the global locale.
static boolean getBooleanProperty(String name)
          Returns a boolean value Jive property.
static boolean getBooleanProperty(String name, boolean defaultValue)
          Returns a boolean value Jive property.
static String getHomeDirectory()
          Returns the location of the home directory.
static int getIntProperty(String name, int defaultValue)
          Returns an integer value Jive property.
static Locale getLocale()
          Returns the global Locale used by Jive.
static long getLongProperty(String name, long defaultValue)
          Returns a long value Jive property.
static List<String> getProperties(String parent)
          Return all immediate children property values of a parent Jive property as a list of strings, or an empty list if there are no children.
static String getProperty(String name)
          Returns a Jive property.
static String getProperty(String name, String defaultValue)
          Returns a Jive property.
static List<String> getPropertyNames()
          Returns all Jive property names.
static List<String> getPropertyNames(String parent)
          Return all immediate children property names of a parent Jive property as a list of strings, or an empty list if there are no children.
static TimeZone getTimeZone()
          Returns the global TimeZone used by Jive.
static List getXMLProperties(String parent)
          Return all immediate children property values of a parent local property as a list of strings, or an empty list if there are no children.
static String getXMLProperty(String name)
          Returns a local property.
static boolean getXMLProperty(String name, boolean defaultValue)
          Returns a boolean value local property.
static int getXMLProperty(String name, int defaultValue)
          Returns an integer value local property.
static String getXMLProperty(String name, String defaultValue)
          Returns a local property.
static void setConfigName(String configName)
          Allows the name of the local config file name to be changed.
static void setHomeDirectory(String pathname)
          Sets the location of the home directory.
static void setLocale(Locale newLocale)
          Sets the global locale used by Jive.
static void setProperties(Map<String,String> propertyMap)
          Sets multiple Jive properties at once.
static void setProperty(String name, String value)
          Sets a Jive property.
static void setTimeZone(TimeZone newTimeZone)
          Sets the global time zone used by Jive.
static void setXMLProperties(Map<String,String> propertyMap)
          Sets multiple local properties at once.
static void setXMLProperty(String name, String value)
          Sets a local property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

failedLoading

public static boolean failedLoading
Constructor Detail

JiveGlobals

public JiveGlobals()
Method Detail

getLocale

public static Locale getLocale()
Returns the global Locale used by Jive. A locale specifies language and country codes, and is used for internationalization. The default locale is system dependant - Locale.getDefault().

Returns:
the global locale used by Jive.

setLocale

public static void setLocale(Locale newLocale)
Sets the global locale used by Jive. A locale specifies language and country codes, and is used for formatting dates and numbers. The default locale is Locale.US.

Parameters:
newLocale - the global Locale for Jive.

getTimeZone

public static TimeZone getTimeZone()
Returns the global TimeZone used by Jive. The default is the VM's default time zone.

Returns:
the global time zone used by Jive.

setTimeZone

public static void setTimeZone(TimeZone newTimeZone)
Sets the global time zone used by Jive. The default time zone is the VM's time zone.


formatTime

public static String formatTime(Date date)
Formats a Date object to return a time using the global locale.

Parameters:
date - the Date to format.
Returns:
a String representing the time.

formatDate

public static String formatDate(Date date)
Formats a Date object to return a date using the global locale.

Parameters:
date - the Date to format.
Returns:
a String representing the date.

formatDateTime

public static String formatDateTime(Date date)
Formats a Date object to return a date and time using the global locale.

Parameters:
date - the Date to format.
Returns:
a String representing the date and time.

getHomeDirectory

public static String getHomeDirectory()
Returns the location of the home directory.

Returns:
the location of the home dir.

setHomeDirectory

public static void setHomeDirectory(String pathname)
Sets the location of the home directory. The directory must exist and the user running the application must have read and write permissions over the specified directory.

Parameters:
pathname - the location of the home dir.

getXMLProperty

public static String getXMLProperty(String name)
Returns a local property. Local properties are stored in the file defined in JIVE_CONFIG_FILENAME that exists in the home directory. Properties are always specified as "foo.bar.prop", which would map to the following entry in the XML file:
 <foo>
     <bar>
         <prop>some value</prop>
     </bar>
 </foo>
 

Parameters:
name - the name of the property to return.
Returns:
the property value specified by name.

getXMLProperty

public static String getXMLProperty(String name,
                                    String defaultValue)
Returns a local property. Local properties are stored in the file defined in JIVE_CONFIG_FILENAME that exists in the home directory. Properties are always specified as "foo.bar.prop", which would map to the following entry in the XML file:
 <foo>
     <bar>
         <prop>some value</prop>
     </bar>
 </foo>
 
If the specified property can't be found, the defaultValue will be returned.

Parameters:
name - the name of the property to return.
defaultValue - the default value for the property.
Returns:
the property value specified by name.

getXMLProperty

public static int getXMLProperty(String name,
                                 int defaultValue)
Returns an integer value local property. Local properties are stored in the file defined in JIVE_CONFIG_FILENAME that exists in the home directory. Properties are always specified as "foo.bar.prop", which would map to the following entry in the XML file:
 <foo>
     <bar>
         <prop>some value</prop>
     </bar>
 </foo>
 
If the specified property can't be found, or if the value is not a number, the defaultValue will be returned.

Parameters:
name - the name of the property to return.
defaultValue - value returned if the property could not be loaded or was not a number.
Returns:
the property value specified by name or defaultValue.

getXMLProperty

public static boolean getXMLProperty(String name,
                                     boolean defaultValue)
Returns a boolean value local property. Local properties are stored in the file defined in JIVE_CONFIG_FILENAME that exists in the home directory. Properties are always specified as "foo.bar.prop", which would map to the following entry in the XML file:
 <foo>
     <bar>
         <prop>some value</prop>
     </bar>
 </foo>
 
If the specified property can't be found, the defaultValue will be returned. If the property is found, it will be parsed using Boolean.valueOf(String).

Parameters:
name - the name of the property to return.
defaultValue - value returned if the property could not be loaded or was not a number.
Returns:
the property value specified by name or defaultValue.

setXMLProperty

public static void setXMLProperty(String name,
                                  String value)
Sets a local property. If the property doesn't already exists, a new one will be created. Local properties are stored in the file defined in JIVE_CONFIG_FILENAME that exists in the home directory. Properties are always specified as "foo.bar.prop", which would map to the following entry in the XML file:
 <foo>
     <bar>
         <prop>some value</prop>
     </bar>
 </foo>
 

Parameters:
name - the name of the property being set.
value - the value of the property being set.

setXMLProperties

public static void setXMLProperties(Map<String,String> propertyMap)
Sets multiple local properties at once. If a property doesn't already exists, a new one will be created. Local properties are stored in the file defined in JIVE_CONFIG_FILENAME that exists in the home directory. Properties are always specified as "foo.bar.prop", which would map to the following entry in the XML file:
 <foo>
     <bar>
         <prop>some value</prop>
     </bar>
 </foo>
 

Parameters:
propertyMap - a map of properties, keyed on property name.

getXMLProperties

public static List getXMLProperties(String parent)
Return all immediate children property values of a parent local property as a list of strings, or an empty list if there are no children. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are A, B, and C (the value of C.D would not be returned using this method).

Local properties are stored in the file defined in JIVE_CONFIG_FILENAME that exists in the home directory. Properties are always specified as "foo.bar.prop", which would map to the following entry in the XML file:

 <foo>
     <bar>
         <prop>some value</prop>
     </bar>
 </foo>
 

Parameters:
parent - the name of the parent property to return the children for.
Returns:
all child property values for the given parent.

deleteXMLProperty

public static void deleteXMLProperty(String name)
Deletes a locale property. If the property doesn't exist, the method does nothing.

Parameters:
name - the name of the property to delete.

getProperty

public static String getProperty(String name)
Returns a Jive property.

Parameters:
name - the name of the property to return.
Returns:
the property value specified by name.

getProperty

public static String getProperty(String name,
                                 String defaultValue)
Returns a Jive property. If the specified property doesn't exist, the defaultValue will be returned.

Parameters:
name - the name of the property to return.
defaultValue - value returned if the property doesn't exist.
Returns:
the property value specified by name.

getIntProperty

public static int getIntProperty(String name,
                                 int defaultValue)
Returns an integer value Jive property. If the specified property doesn't exist, the defaultValue will be returned.

Parameters:
name - the name of the property to return.
defaultValue - value returned if the property doesn't exist or was not a number.
Returns:
the property value specified by name or defaultValue.

getLongProperty

public static long getLongProperty(String name,
                                   long defaultValue)
Returns a long value Jive property. If the specified property doesn't exist, the defaultValue will be returned.

Parameters:
name - the name of the property to return.
defaultValue - value returned if the property doesn't exist or was not a number.
Returns:
the property value specified by name or defaultValue.

getBooleanProperty

public static boolean getBooleanProperty(String name)
Returns a boolean value Jive property.

Parameters:
name - the name of the property to return.
Returns:
true if the property value exists and is set to "true" (ignoring case). Otherwise false is returned.

getBooleanProperty

public static boolean getBooleanProperty(String name,
                                         boolean defaultValue)
Returns a boolean value Jive property. If the property doesn't exist, the defaultValue will be returned. If the specified property can't be found, or if the value is not a number, the defaultValue will be returned.

Parameters:
name - the name of the property to return.
defaultValue - value returned if the property doesn't exist.
Returns:
true if the property value exists and is set to "true" (ignoring case). Otherwise false is returned.

getPropertyNames

public static List<String> getPropertyNames(String parent)
Return all immediate children property names of a parent Jive property as a list of strings, or an empty list if there are no children. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are A, B, and C (C.D would not be returned using this method).

Returns:
a List of all immediate children property names (Strings).

getProperties

public static List<String> getProperties(String parent)
Return all immediate children property values of a parent Jive property as a list of strings, or an empty list if there are no children. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are X.Y.A, X.Y.B, and X.Y.C (the value of X.Y.C.D would not be returned using this method).

Parameters:
parent - the name of the parent property to return the children for.
Returns:
all child property values for the given parent.

getPropertyNames

public static List<String> getPropertyNames()
Returns all Jive property names.

Returns:
a List of all property names (Strings).

setProperty

public static void setProperty(String name,
                               String value)
Sets a Jive property. If the property doesn't already exists, a new one will be created.

Parameters:
name - the name of the property being set.
value - the value of the property being set.

setProperties

public static void setProperties(Map<String,String> propertyMap)
Sets multiple Jive properties at once. If a property doesn't already exists, a new one will be created.

Parameters:
propertyMap - a map of properties, keyed on property name.

deleteProperty

public static void deleteProperty(String name)
Deletes a Jive property. If the property doesn't exist, the method does nothing. All children of the property will be deleted as well.

Parameters:
name - the name of the property to delete.

setConfigName

public static void setConfigName(String configName)
Allows the name of the local config file name to be changed. The default is "openfire.xml".

Parameters:
configName - the name of the config file.

Openfire 3.5.0 Javadoc

Copyright © 2003-2007 Jive Software.