Class PropertyUtils


  • public class PropertyUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      PropertyUtils()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkMetadata​(java.util.Properties properties, java.lang.String key, java.lang.String expected)
      Check property has the value given - throw exception if not.
      void checkOrSetProperty​(java.util.Properties properties, java.lang.String key, java.lang.String expected)
      Check property is an expected value or set if missing
      void ensurePropertySet​(java.util.Properties properties, java.lang.String key, java.lang.String expected)
      Set property if not already set.
      java.lang.String getOrSetDefault​(java.util.Properties properties, java.lang.String key, java.lang.String expected)
      Get property or the default value - also set the default value if not present
      static java.lang.Boolean getPropertyAsBoolean​(java.util.Properties properties, java.lang.String key)  
      static boolean getPropertyAsBoolean​(java.util.Properties properties, java.lang.String key, boolean dftValue)  
      static int getPropertyAsInteger​(java.util.Properties properties, java.lang.String key)  
      static int getPropertyAsInteger​(java.util.Properties properties, java.lang.String key, int defaultValue)  
      static java.util.Properties loadFromFile​(java.lang.String filename)
      Load properties from a file if the file exists
      static void loadFromFile​(java.util.Properties properties, java.lang.String filename)
      Load properties from a file if the file exists
      boolean propertyEquals​(java.util.Properties properties, java.lang.String key, java.lang.String value)
      Test whether a property has a value.
      static void storeToFile​(java.util.Properties properties, java.lang.String comment, java.lang.String filename)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PropertyUtils

        public PropertyUtils()
    • Method Detail

      • loadFromFile

        public static java.util.Properties loadFromFile​(java.lang.String filename)
                                                 throws java.io.IOException
        Load properties from a file if the file exists
        Throws:
        java.io.IOException
      • loadFromFile

        public static void loadFromFile​(java.util.Properties properties,
                                        java.lang.String filename)
                                 throws java.io.IOException
        Load properties from a file if the file exists
        Throws:
        java.io.IOException
      • storeToFile

        public static void storeToFile​(java.util.Properties properties,
                                       java.lang.String comment,
                                       java.lang.String filename)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getPropertyAsInteger

        public static int getPropertyAsInteger​(java.util.Properties properties,
                                               java.lang.String key)
      • getPropertyAsInteger

        public static int getPropertyAsInteger​(java.util.Properties properties,
                                               java.lang.String key,
                                               int defaultValue)
      • getPropertyAsBoolean

        public static boolean getPropertyAsBoolean​(java.util.Properties properties,
                                                   java.lang.String key,
                                                   boolean dftValue)
      • getPropertyAsBoolean

        public static java.lang.Boolean getPropertyAsBoolean​(java.util.Properties properties,
                                                             java.lang.String key)
      • propertyEquals

        public boolean propertyEquals​(java.util.Properties properties,
                                      java.lang.String key,
                                      java.lang.String value)
        Test whether a property has a value. Null tests equal to not present.
      • ensurePropertySet

        public void ensurePropertySet​(java.util.Properties properties,
                                      java.lang.String key,
                                      java.lang.String expected)
        Set property if not already set.
      • getOrSetDefault

        public java.lang.String getOrSetDefault​(java.util.Properties properties,
                                                java.lang.String key,
                                                java.lang.String expected)
        Get property or the default value - also set the default value if not present
      • checkOrSetProperty

        public void checkOrSetProperty​(java.util.Properties properties,
                                       java.lang.String key,
                                       java.lang.String expected)
        Check property is an expected value or set if missing
      • checkMetadata

        public void checkMetadata​(java.util.Properties properties,
                                  java.lang.String key,
                                  java.lang.String expected)
        Check property has the value given - throw exception if not.