Class PropertiesParser


  • public class PropertiesParser
    extends java.lang.Object

    This is an utility calss used to parse the properties.

    Author:
    James House
    • Constructor Detail

      • PropertiesParser

        public PropertiesParser​(java.util.Properties props)
    • Method Detail

      • getUnderlyingProperties

        public java.util.Properties getUnderlyingProperties()
      • getStringProperty

        public java.lang.String getStringProperty​(java.lang.String name)
        Get the trimmed String value of the property with the given name. If the value the empty String (after trimming), then it returns null.
      • getStringProperty

        public java.lang.String getStringProperty​(java.lang.String name,
                                                  java.lang.String def)
        Get the trimmed String value of the property with the given name or the given default value if the value is null or empty after trimming.
      • getStringArrayProperty

        public java.lang.String[] getStringArrayProperty​(java.lang.String name)
      • getStringArrayProperty

        public java.lang.String[] getStringArrayProperty​(java.lang.String name,
                                                         java.lang.String[] def)
      • getBooleanProperty

        public boolean getBooleanProperty​(java.lang.String name)
      • getBooleanProperty

        public boolean getBooleanProperty​(java.lang.String name,
                                          boolean def)
      • getByteProperty

        public byte getByteProperty​(java.lang.String name)
                             throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getByteProperty

        public byte getByteProperty​(java.lang.String name,
                                    byte def)
                             throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getCharProperty

        public char getCharProperty​(java.lang.String name)
      • getCharProperty

        public char getCharProperty​(java.lang.String name,
                                    char def)
      • getDoubleProperty

        public double getDoubleProperty​(java.lang.String name)
                                 throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getDoubleProperty

        public double getDoubleProperty​(java.lang.String name,
                                        double def)
                                 throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getFloatProperty

        public float getFloatProperty​(java.lang.String name)
                               throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getFloatProperty

        public float getFloatProperty​(java.lang.String name,
                                      float def)
                               throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getIntProperty

        public int getIntProperty​(java.lang.String name)
                           throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getIntProperty

        public int getIntProperty​(java.lang.String name,
                                  int def)
                           throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getIntArrayProperty

        public int[] getIntArrayProperty​(java.lang.String name)
                                  throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getIntArrayProperty

        public int[] getIntArrayProperty​(java.lang.String name,
                                         int[] def)
                                  throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getLongProperty

        public long getLongProperty​(java.lang.String name)
                             throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getLongProperty

        public long getLongProperty​(java.lang.String name,
                                    long def)
                             throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getShortProperty

        public short getShortProperty​(java.lang.String name)
                               throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getShortProperty

        public short getShortProperty​(java.lang.String name,
                                      short def)
                               throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getPropertyGroups

        public java.lang.String[] getPropertyGroups​(java.lang.String prefix)
      • getPropertyGroup

        public java.util.Properties getPropertyGroup​(java.lang.String prefix)
      • getPropertyGroup

        public java.util.Properties getPropertyGroup​(java.lang.String prefix,
                                                     boolean stripPrefix)
      • getPropertyGroup

        public java.util.Properties getPropertyGroup​(java.lang.String prefix,
                                                     boolean stripPrefix,
                                                     java.lang.String[] excludedPrefixes)
        Get all properties that start with the given prefix.
        Parameters:
        prefix - The prefix for which to search. If it does not end in a "." then one will be added to it for search purposes.
        stripPrefix - Whether to strip off the given prefix in the result's keys.
        excludedPrefixes - Optional array of fully qualified prefixes to exclude. For example if prefix is "a.b.c", then excludedPrefixes might be "a.b.c.ignore".
        Returns:
        Group of Properties that start with the given prefix, optionally have that prefix removed, and do not include properties that start with one of the given excluded prefixes.