Class TypedProperties

  • All Implemented Interfaces:
    java.util.Map<java.lang.String,​java.lang.Object>

    public class TypedProperties
    extends java.util.AbstractMap<java.lang.String,​java.lang.Object>

    Map to load / store / update untyped or typed properties. The map is untyped if all properties are strings. When this is the case, the properties are stored without any encoding, else all properties are encoded using the ConfigurationHandler.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  TypedProperties.DynamicMap  
      static interface  TypedProperties.SubstitutionCallback  
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      private static java.lang.Object convertFromString​(java.lang.String value)  
      private static java.lang.String convertToString​(java.lang.Object value)  
      private void ensureTyped()  
      java.util.Set<java.util.Map.Entry<java.lang.String,​java.lang.Object>> entrySet()  
      java.lang.Object get​(java.lang.Object key)  
      java.util.List<java.lang.String> getComments​(java.lang.String key)  
      java.util.List<java.lang.String> getFooter()
      Return the comment footer.
      java.util.List<java.lang.String> getHeader()
      Return the comment header.
      java.util.List<java.lang.String> getRaw​(java.lang.String key)  
      void load​(java.io.File location)  
      void load​(java.io.InputStream is)  
      void load​(java.io.Reader reader)  
      void load​(java.net.URL location)  
      static java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> prepare​(java.util.Map<java.lang.String,​TypedProperties> properties)  
      java.lang.Object put​(java.lang.String key, java.lang.Object value)  
      java.lang.Object put​(java.lang.String key, java.lang.String comment, java.lang.Object value)  
      java.lang.Object put​(java.lang.String key, java.util.List<java.lang.String> commentLines, java.lang.Object value)  
      java.lang.Object put​(java.lang.String key, java.util.List<java.lang.String> commentLines, java.util.List<java.lang.String> valueLines)  
      java.lang.Object remove​(java.lang.Object key)  
      void save​(java.io.File location)  
      void save​(java.io.OutputStream os)  
      void save​(java.io.Writer writer)  
      void setFooter​(java.util.List<java.lang.String> footer)
      Set the comment footer.
      void setHeader​(java.util.List<java.lang.String> header)
      Set the comment header.
      void store​(java.io.OutputStream os, java.lang.String comment)
      Store a properties into a output stream, preserving comments, special character, etc.
      static void substitute​(java.util.Map<java.lang.String,​TypedProperties> properties, java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> dynamic, TypedProperties.SubstitutionCallback callback, boolean finalSubstitution)  
      void substitute​(TypedProperties.SubstitutionCallback cb)  
      boolean update​(java.util.Map<java.lang.String,​java.lang.Object> props)  
      boolean update​(TypedProperties properties)  
      private static TypedProperties.SubstitutionCallback wrap​(InterpolationHelper.SubstitutionCallback cb)  
      • Methods inherited from class java.util.AbstractMap

        clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Method Detail

      • load

        public void load​(java.io.File location)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • load

        public void load​(java.net.URL location)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • load

        public void load​(java.io.InputStream is)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • load

        public void load​(java.io.Reader reader)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • save

        public void save​(java.io.File location)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • save

        public void save​(java.io.OutputStream os)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • save

        public void save​(java.io.Writer writer)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • store

        public void store​(java.io.OutputStream os,
                          java.lang.String comment)
                   throws java.io.IOException
        Store a properties into a output stream, preserving comments, special character, etc. This method is mainly to be compatible with the java.util.Properties class.
        Parameters:
        os - an output stream.
        comment - this parameter is ignored as this Properties
        Throws:
        java.io.IOException - If storing fails
      • entrySet

        public java.util.Set<java.util.Map.Entry<java.lang.String,​java.lang.Object>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<java.lang.String,​java.lang.Object>
        Specified by:
        entrySet in class java.util.AbstractMap<java.lang.String,​java.lang.Object>
      • put

        public java.lang.Object put​(java.lang.String key,
                                    java.lang.Object value)
        Specified by:
        put in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        put in class java.util.AbstractMap<java.lang.String,​java.lang.Object>
      • get

        public java.lang.Object get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        get in class java.util.AbstractMap<java.lang.String,​java.lang.Object>
      • put

        public java.lang.Object put​(java.lang.String key,
                                    java.util.List<java.lang.String> commentLines,
                                    java.lang.Object value)
      • put

        public java.lang.Object put​(java.lang.String key,
                                    java.lang.String comment,
                                    java.lang.Object value)
      • put

        public java.lang.Object put​(java.lang.String key,
                                    java.util.List<java.lang.String> commentLines,
                                    java.util.List<java.lang.String> valueLines)
      • ensureTyped

        private void ensureTyped()
      • update

        public boolean update​(java.util.Map<java.lang.String,​java.lang.Object> props)
      • getRaw

        public java.util.List<java.lang.String> getRaw​(java.lang.String key)
      • getComments

        public java.util.List<java.lang.String> getComments​(java.lang.String key)
      • remove

        public java.lang.Object remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        remove in class java.util.AbstractMap<java.lang.String,​java.lang.Object>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        clear in class java.util.AbstractMap<java.lang.String,​java.lang.Object>
      • getHeader

        public java.util.List<java.lang.String> getHeader()
        Return the comment header.
        Returns:
        the comment header
      • setHeader

        public void setHeader​(java.util.List<java.lang.String> header)
        Set the comment header.
        Parameters:
        header - the header to use
      • getFooter

        public java.util.List<java.lang.String> getFooter()
        Return the comment footer.
        Returns:
        the comment footer
      • setFooter

        public void setFooter​(java.util.List<java.lang.String> footer)
        Set the comment footer.
        Parameters:
        footer - the footer to use
      • prepare

        public static java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> prepare​(java.util.Map<java.lang.String,​TypedProperties> properties)
      • substitute

        public static void substitute​(java.util.Map<java.lang.String,​TypedProperties> properties,
                                      java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> dynamic,
                                      TypedProperties.SubstitutionCallback callback,
                                      boolean finalSubstitution)
      • convertToString

        private static java.lang.String convertToString​(java.lang.Object value)
      • convertFromString

        private static java.lang.Object convertFromString​(java.lang.String value)