Class XMLConfigUtil

    • Constructor Detail

      • XMLConfigUtil

        public XMLConfigUtil()
    • Method Detail

      • findConfiguration

        public static org.apache.commons.configuration.tree.ConfigurationNode findConfiguration​(String fileName,
                                                                                                String configName,
                                                                                                String topNodeTag)
        Finds the configuration in an XML file, given the filename, name of the configuration (or null if you want to use the only one there) and the top node tag (E.g. "client" or "server"). This only permits single inheritance.
        Parameters:
        fileName -
        configName -
        topNodeTag -
        Returns:
      • findMultiNode

        public static org.apache.commons.configuration.tree.ConfigurationNode findMultiNode​(String fileName,
                                                                                            String cfgName,
                                                                                            String cfgTagName)
                                                                                     throws org.apache.commons.configuration.ConfigurationException
        Entry point for multiple-inheritance.
        Parameters:
        fileName -
        cfgName -
        cfgTagName -
        Returns:
        Throws:
        org.apache.commons.configuration.ConfigurationException
      • getConfigurations2

        protected static MultiConfigurations getConfigurations2​(String fileName,
                                                                String cfgTagName)
                                                         throws org.apache.commons.configuration.ConfigurationException
        Throws:
        org.apache.commons.configuration.ConfigurationException
      • findNamedConfig

        protected static org.apache.commons.configuration.tree.ConfigurationNode findNamedConfig​(org.apache.commons.configuration.XMLConfiguration cfg,
                                                                                                 String cfgName,
                                                                                                 String topNodeTag)
        This takes a configuration and looks in it for a given name for the tag. Called by findConfiguration(String, String, String).
        Parameters:
        cfg -
        cfgName -
        topNodeTag -
        Returns:
      • getValueSecsOrMillis

        public static Long getValueSecsOrMillis​(String x)
        For getting times in configuration files. The acceptable entries are
         x + sec for seconds
         x + s for seconds
         x + ms for milliseconds
         x (no units) for milliseconds
         
        Using this assumes that the default is milliseconds for the field. If you need to set the default for the field as seconds, use getValueSecsOrMillis(String, boolean).
        Parameters:
        x -
        Returns:
      • getValueSecsOrMillis

        public static Long getValueSecsOrMillis​(String x,
                                                boolean isSeconds)
        Parameters:
        x - un-parsed number
        isSeconds - no units means it is seconds (true) or milliseconds (false)
        Returns:
      • splitNumber

        protected static String[] splitNumber​(String x,
                                              boolean isSeconds)
        Splits a time into number and unit, normalizing.
        Parameters:
        x -
        Returns:
      • getMultiplier

        protected static long getMultiplier​(String units)
        Gets the correct multiplier for the units.
        Parameters:
        units -
        Returns:
      • main

        public static void main​(String[] args)
        Quick double check of this class. Run it and peruse the output.
        Parameters:
        args -