org.objectweb.jonathan.libs.helpers
Class ContextHelpers

java.lang.Object
  |
  +--org.objectweb.jonathan.libs.helpers.ContextHelpers

public class ContextHelpers
extends Object


Constructor Summary
ContextHelpers()
           
 
Method Summary
static int getIntValue(Context context, String name, char separator, int default_value)
          Returns the value of the element of name name in context as an integer.
static void importProperties(Configuration _configuration, Properties _props, String[] _except, boolean _force)
           
static void importProperties(Context _context, Properties _props, String[] _except, boolean _force)
          Imports the provided properties into the _context.
static void importProperty(Context _context, String _name, String _value, boolean _force)
           
static void importXML(Configuration _configuration, String _xml_file_name, ConfigurationFactory _configuration_factory, ClassLoader _loader)
           
static void importXMLAsNamedElement(String _element_name, Configuration _configuration, String _xml_file_name, ConfigurationFactory _configuration_factory, ClassLoader _loader)
           
static void importXMLElement(org.objectweb.jonathan.tools.nanoxml.XMLElement _xml_element, Configuration _configuration, ConfigurationFactory _configuration_factory, ClassLoader _loader)
           
static void importXMLElements(Enumeration _xml_elements, Configuration _configuration, ConfigurationFactory _configuration_factory, ClassLoader _loader)
           
static org.objectweb.jonathan.tools.nanoxml.XMLElement readXMLElementFromResource(String _resource_name, ClassLoader _loader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextHelpers

public ContextHelpers()
Method Detail

importProperties

public static void importProperties(Context _context,
                                    Properties _props,
                                    String[] _except,
                                    boolean _force)
Imports the provided properties into the _context.

Property keys are mapped to names in the provided context, using '.' as a separator.

Property values are mapped to values of type string, except when the value may be parsed as:

except specifies a list of property keys prefixes corresponding to keys that should not be imported into the context.

Parameters:
_context - the context to import the properties to;
_props - the properties to import;
except - prefix key prefixes corresponding to properties that should not ¨ be imported.
force - indicates whether already existing elements should be replaced or not.

importProperties

public static void importProperties(Configuration _configuration,
                                    Properties _props,
                                    String[] _except,
                                    boolean _force)

importProperty

public static void importProperty(Context _context,
                                  String _name,
                                  String _value,
                                  boolean _force)

getIntValue

public static int getIntValue(Context context,
                              String name,
                              char separator,
                              int default_value)
Returns the value of the element of name name in context as an integer.

The element may be of an integral type (one of int, short, char, byte), or of type Integer. It it is not, or if name is not bound in context, default_value is returned.

Parameters:
context - a context;
name - a string representing an name;
separator - the separator used to parse name;
default_value - the default value returned;
Returns:
the value of the element designated by name in context, as an int.

importXML

public static void importXML(Configuration _configuration,
                             String _xml_file_name,
                             ConfigurationFactory _configuration_factory,
                             ClassLoader _loader)
                      throws IOException,
                             org.objectweb.jonathan.tools.nanoxml.XMLParseException,
                             JonathanException

importXMLAsNamedElement

public static void importXMLAsNamedElement(String _element_name,
                                           Configuration _configuration,
                                           String _xml_file_name,
                                           ConfigurationFactory _configuration_factory,
                                           ClassLoader _loader)
                                    throws IOException,
                                           org.objectweb.jonathan.tools.nanoxml.XMLParseException,
                                           JonathanException

readXMLElementFromResource

public static org.objectweb.jonathan.tools.nanoxml.XMLElement readXMLElementFromResource(String _resource_name,
                                                                                         ClassLoader _loader)
                                                                                  throws IOException,
                                                                                         org.objectweb.jonathan.tools.nanoxml.XMLParseException,
                                                                                         JonathanException

importXMLElements

public static void importXMLElements(Enumeration _xml_elements,
                                     Configuration _configuration,
                                     ConfigurationFactory _configuration_factory,
                                     ClassLoader _loader)
                              throws IOException,
                                     org.objectweb.jonathan.tools.nanoxml.XMLParseException,
                                     JonathanException

importXMLElement

public static void importXMLElement(org.objectweb.jonathan.tools.nanoxml.XMLElement _xml_element,
                                    Configuration _configuration,
                                    ConfigurationFactory _configuration_factory,
                                    ClassLoader _loader)
                             throws IOException,
                                    org.objectweb.jonathan.tools.nanoxml.XMLParseException,
                                    JonathanException