Package jodd.props

Class PropsData

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class PropsData
    extends java.lang.Object
    implements java.lang.Cloneable
    Props data storage for base and profile properties. Properties can be lookuped and modified only through this class.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        PropsData()  
      protected PropsData​(java.util.HashMap<java.lang.String,​PropsEntry> properties, java.util.HashMap<java.lang.String,​java.util.Map<java.lang.String,​PropsEntry>> profiles)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      PropsData clone()  
      int countBaseProperties()
      Counts base properties.
      int countProfileProperties()
      Counts profile properties.
      java.util.Map extract​(java.util.Map target, java.lang.String[] profiles, java.lang.String[] wildcardPatterns, java.lang.String prefix)
      Extracts props to target map.
      protected void extractMap​(java.util.Map target, java.util.Map<java.lang.String,​PropsEntry> map, java.lang.String[] profiles, java.lang.String[] wildcardPatterns, java.lang.String prefix)  
      PropsEntry getBaseProperty​(java.lang.String key)
      Returns base property or null if it doesn't exist.
      PropsEntry getProfileProperty​(java.lang.String profile, java.lang.String key)
      Returns profile property.
      protected java.lang.String lookupValue​(java.lang.String key, java.lang.String... profiles)
      Lookup props value through profiles and base properties.
      protected void put​(java.lang.String profile, java.util.Map<java.lang.String,​PropsEntry> map, java.lang.String key, java.lang.String value, boolean append)
      Puts key-value pair into the map, with respect of appending duplicate properties
      void putBaseProperty​(java.lang.String key, java.lang.String value, boolean append)
      Adds base property.
      void putProfileProperty​(java.lang.String key, java.lang.String value, java.lang.String profile, boolean append)
      Adds profile property.
      java.lang.String resolveMacros​(java.lang.String value, java.lang.String... profiles)
      Resolves all macros in this props set.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • baseProperties

        protected final java.util.HashMap<java.lang.String,​PropsEntry> baseProperties
      • profileProperties

        protected final java.util.HashMap<java.lang.String,​java.util.Map<java.lang.String,​PropsEntry>> profileProperties
      • appendDuplicateProps

        protected boolean appendDuplicateProps
        If set, duplicate props will be appended to the end, separated by comma.
      • ignoreMissingMacros

        protected boolean ignoreMissingMacros
        When set, missing macros will be replaces with an empty string.
      • skipEmptyProps

        protected boolean skipEmptyProps
        When set, empty properties will be skipped.
    • Constructor Detail

      • PropsData

        public PropsData()
      • PropsData

        protected PropsData​(java.util.HashMap<java.lang.String,​PropsEntry> properties,
                            java.util.HashMap<java.lang.String,​java.util.Map<java.lang.String,​PropsEntry>> profiles)
    • Method Detail

      • clone

        public PropsData clone()
        Overrides:
        clone in class java.lang.Object
      • put

        protected void put​(java.lang.String profile,
                           java.util.Map<java.lang.String,​PropsEntry> map,
                           java.lang.String key,
                           java.lang.String value,
                           boolean append)
        Puts key-value pair into the map, with respect of appending duplicate properties
      • countBaseProperties

        public int countBaseProperties()
        Counts base properties.
      • putBaseProperty

        public void putBaseProperty​(java.lang.String key,
                                    java.lang.String value,
                                    boolean append)
        Adds base property.
      • getBaseProperty

        public PropsEntry getBaseProperty​(java.lang.String key)
        Returns base property or null if it doesn't exist.
      • countProfileProperties

        public int countProfileProperties()
        Counts profile properties. Note: this method is not that easy on execution.
      • putProfileProperty

        public void putProfileProperty​(java.lang.String key,
                                       java.lang.String value,
                                       java.lang.String profile,
                                       boolean append)
        Adds profile property.
      • getProfileProperty

        public PropsEntry getProfileProperty​(java.lang.String profile,
                                             java.lang.String key)
        Returns profile property.
      • lookupValue

        protected java.lang.String lookupValue​(java.lang.String key,
                                               java.lang.String... profiles)
        Lookup props value through profiles and base properties. Returns null if value not found.
      • resolveMacros

        public java.lang.String resolveMacros​(java.lang.String value,
                                              java.lang.String... profiles)
        Resolves all macros in this props set. Called on property lookup.
      • extract

        public java.util.Map extract​(java.util.Map target,
                                     java.lang.String[] profiles,
                                     java.lang.String[] wildcardPatterns,
                                     java.lang.String prefix)
        Extracts props to target map. This is all-in-one method, that does many things at once.
      • extractMap

        protected void extractMap​(java.util.Map target,
                                  java.util.Map<java.lang.String,​PropsEntry> map,
                                  java.lang.String[] profiles,
                                  java.lang.String[] wildcardPatterns,
                                  java.lang.String prefix)