Class PropertiesUtil


  • public final class PropertiesUtil
    extends java.lang.Object
    Convenience class for working with global properties
    Author:
    Andrew Varley
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Properties getProperties()
      Returns all InterMine properties
      static java.util.Properties getPropertiesStartingWith​(java.lang.String str)
      Returns all global Properties that begin with str
      static java.util.Properties getPropertiesStartingWith​(java.lang.String str, java.util.Properties props)
      Returns all Properties in props that begin with str
      static java.util.Properties loadProperties​(java.lang.String resourceName)
      Load a specified properties resource
      static java.lang.String serialize​(java.util.Properties props)
      Serialize properties to a string suitable for a subsequent load()
      static java.util.Properties stripStart​(java.lang.String prefix, java.util.Properties props)
      Strips the given string off the keys of the given Properties, and returns a new set of properties.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getProperties

        public static java.util.Properties getProperties()
        Returns all InterMine properties
        Returns:
        the global properties for InterMine
      • getPropertiesStartingWith

        public static java.util.Properties getPropertiesStartingWith​(java.lang.String str,
                                                                     java.util.Properties props)
        Returns all Properties in props that begin with str
        Parameters:
        str - the String that the returned properties should start with
        props - the Properties to search through
        Returns:
        a Properties object containing the subset of props
      • getPropertiesStartingWith

        public static java.util.Properties getPropertiesStartingWith​(java.lang.String str)
        Returns all global Properties that begin with str
        Parameters:
        str - the String that the returned properties should start with
        Returns:
        a Properties object containing the subset of the global properties
      • stripStart

        public static java.util.Properties stripStart​(java.lang.String prefix,
                                                      java.util.Properties props)

        Strips the given string off the keys of the given Properties, and returns a new set of properties. The original properties are not altered. For example, given the property:

        • database.name=production
        a call to stripStart("database", props) will produce:
        • name=production
        Note that a dot will be added to the prefix.
        Parameters:
        prefix - the String to strip off - a "." will be appended to this string.
        props - the Properties object to change
        Returns:
        a Properties object containing the same properties with the initial string + "." stripped off the keys
      • serialize

        public static java.lang.String serialize​(java.util.Properties props)
                                          throws java.io.IOException
        Serialize properties to a string suitable for a subsequent load()
        Parameters:
        props - the properties
        Returns:
        the string
        Throws:
        java.io.IOException - if an error occurs
      • loadProperties

        public static java.util.Properties loadProperties​(java.lang.String resourceName)
        Load a specified properties resource
        Parameters:
        resourceName - the resourceName of the properties file
        Returns:
        the corresponding Properties object