Connection Manager 3.6.3 Javadoc

org.jivesoftware.util
Class JiveGlobals

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

public class JiveGlobals
extends java.lang.Object

Controls Jive properties. Jive properties are only meant to be set and retrieved by core Jive classes. Properties are stored in XML format.

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. 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.

This class was copied from Openfire. Properties stored in the DB were removed from the code. Modified #getBooleanProperty to use properties stored in XML.


Field Summary
static boolean failedLoading
           
 
Constructor Summary
JiveGlobals()
           
 
Method Summary
static void deleteXMLProperty(java.lang.String name)
          Deletes a locale property.
static java.lang.String formatDateTime(java.util.Date date)
          Formats a Date object to return a date and time using the global locale.
static boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
          Returns a boolean value Jive property.
static java.lang.String getHomeDirectory()
          Returns the location of the home directory.
static int getIntProperty(java.lang.String name, int defaultValue)
          Returns an integer value Jive property.
static java.util.Locale getLocale()
          Returns the global Locale used by Jive.
static java.util.TimeZone getTimeZone()
          Returns the global TimeZone used by Jive.
static java.util.List getXMLProperties(java.lang.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 java.lang.String getXMLProperty(java.lang.String name)
          Returns a local property.
static int getXMLProperty(java.lang.String name, int defaultValue)
          Returns an integer value local property.
static java.lang.String getXMLProperty(java.lang.String name, java.lang.String defaultValue)
          Returns a local property.
static void setConfigName(java.lang.String configName)
          Allows the name of the local config file name to be changed.
static void setHomeDirectory(java.lang.String pathname)
          Sets the location of the home directory.
static void setLocale(java.util.Locale newLocale)
          Sets the global locale used by Jive.
static void setXMLProperties(java.util.Map<java.lang.String,java.lang.String> propertyMap)
          Sets multiple local properties at once.
static void setXMLProperty(java.lang.String name, java.lang.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 java.util.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(java.util.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 java.util.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.

formatDateTime

public static java.lang.String formatDateTime(java.util.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 java.lang.String getHomeDirectory()
Returns the location of the home directory.

Returns:
the location of the home dir.

setHomeDirectory

public static void setHomeDirectory(java.lang.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 java.lang.String getXMLProperty(java.lang.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 java.lang.String getXMLProperty(java.lang.String name,
                                              java.lang.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(java.lang.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.

setXMLProperty

public static void setXMLProperty(java.lang.String name,
                                  java.lang.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(java.util.Map<java.lang.String,java.lang.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 java.util.List getXMLProperties(java.lang.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.

getIntProperty

public static int getIntProperty(java.lang.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.

getBooleanProperty

public static boolean getBooleanProperty(java.lang.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.

deleteXMLProperty

public static void deleteXMLProperty(java.lang.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.

setConfigName

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

Parameters:
configName - the name of the config file.

Connection Manager 3.6.3 Javadoc

Copyright © 2003-2006 Jive Software.