Class AbstractHierarchicalFileConfiguration

    • Constructor Detail

      • AbstractHierarchicalFileConfiguration

        protected AbstractHierarchicalFileConfiguration()
        Creates a new instance of AbstractHierarchicalFileConfiguration.
      • AbstractHierarchicalFileConfiguration

        protected AbstractHierarchicalFileConfiguration​(HierarchicalConfiguration c)
        Creates a new instance of AbstractHierarchicalFileConfiguration and copies the content of the specified configuration into this object.
        Parameters:
        c - the configuration to copy
        Since:
        1.4
      • AbstractHierarchicalFileConfiguration

        public AbstractHierarchicalFileConfiguration​(java.lang.String fileName)
                                              throws ConfigurationException
        Creates and loads the configuration from the specified file.
        Parameters:
        fileName - The name of the plist file to load.
        Throws:
        ConfigurationException - Error while loading the file
      • AbstractHierarchicalFileConfiguration

        public AbstractHierarchicalFileConfiguration​(java.io.File file)
                                              throws ConfigurationException
        Creates and loads the configuration from the specified file.
        Parameters:
        file - The configuration file to load.
        Throws:
        ConfigurationException - Error while loading the file
      • AbstractHierarchicalFileConfiguration

        public AbstractHierarchicalFileConfiguration​(java.net.URL url)
                                              throws ConfigurationException
        Creates and loads the configuration from the specified URL.
        Parameters:
        url - The location of the configuration file to load.
        Throws:
        ConfigurationException - Error while loading the file
    • Method Detail

      • addPropertyDirect

        protected void addPropertyDirect​(java.lang.String key,
                                         java.lang.Object obj)
        Description copied from class: HierarchicalConfiguration
        Adds the property with the specified key. This task will be delegated to the associated ExpressionEngine, so the passed in key must match the requirements of this implementation.
        Overrides:
        addPropertyDirect in class HierarchicalConfiguration
        Parameters:
        key - the key of the new property
        obj - the value of the new property
      • clearProperty

        public void clearProperty​(java.lang.String key)
        Description copied from class: HierarchicalConfiguration
        Removes the property with the given key. Properties with names that start with the given key (i.e. properties below the specified key in the hierarchy) won't be affected.
        Specified by:
        clearProperty in interface Configuration
        Overrides:
        clearProperty in class HierarchicalConfiguration
        Parameters:
        key - the key of the property to be removed
      • clearTree

        public void clearTree​(java.lang.String key)
        Description copied from class: HierarchicalConfiguration
        Removes all values of the property with the given name and of keys that start with this name. So if there is a property with the key "foo" and a property with the key "foo.bar", a call of clearTree("foo") would remove both properties.
        Overrides:
        clearTree in class HierarchicalConfiguration
        Parameters:
        key - the key of the property to be removed
      • load

        public void load​(java.io.InputStream in,
                         java.lang.String encoding)
                  throws ConfigurationException
        Description copied from interface: FileConfiguration
        Load the configuration from the specified stream, using the specified encoding. If the encoding is null the default encoding is used.
        Specified by:
        load in interface FileConfiguration
        Parameters:
        in - the input stream
        encoding - the encoding used. null to use the default encoding
        Throws:
        ConfigurationException - if an error occurs during the load operation
      • save

        public void save​(java.io.OutputStream out,
                         java.lang.String encoding)
                  throws ConfigurationException
        Description copied from interface: FileConfiguration
        Save the configuration to the specified stream, using the specified encoding. If the encoding is null the default encoding is used.
        Specified by:
        save in interface FileConfiguration
        Parameters:
        out - the output stream
        encoding - the encoding to be used
        Throws:
        ConfigurationException - if an error occurs during the save operation
      • setFileName

        public void setFileName​(java.lang.String fileName)
        Description copied from interface: FileConfiguration
        Set the name of the file.
        Specified by:
        setFileName in interface FileConfiguration
        Parameters:
        fileName - the name of the file
      • getBasePath

        public java.lang.String getBasePath()
        Description copied from interface: FileConfiguration
        Returns the base path. One way to specify the location of a configuration source is by setting its base path and its file name. This method returns this base path. The concrete value returned by this method depends on the way the location of the configuration file was set. If methods like setFile() or setURL() were used, the base path typically points to the parent directory of the configuration file (e.g. for the URL file:/temp/test.properties the base path will be file:/temp/). If the base path was explicitly set using setBasePath(), this method will return the exact value specified here without further modifications.
        Specified by:
        getBasePath in interface FileConfiguration
        Returns:
        the base path
        See Also:
        AbstractFileConfiguration.setBasePath(String)
      • setBasePath

        public void setBasePath​(java.lang.String basePath)
        Description copied from interface: FileConfiguration
        Sets the base path. The methods setBasePath() and setFileName() can be used together to specify the location of the configuration file to be loaded. If relative file names are to be resolved (e.g. for the include files supported by PropertiesConfiguration), this base path will be used.
        Specified by:
        setBasePath in interface FileConfiguration
        Parameters:
        basePath - the base path.
      • getFile

        public java.io.File getFile()
        Description copied from interface: FileConfiguration
        Return the file where the configuration is stored.
        Specified by:
        getFile in interface FileConfiguration
        Returns:
        the configuration file
      • setFile

        public void setFile​(java.io.File file)
        Description copied from interface: FileConfiguration
        Set the file where the configuration is stored.
        Specified by:
        setFile in interface FileConfiguration
        Parameters:
        file - the file
      • getURL

        public java.net.URL getURL()
        Description copied from interface: FileConfiguration
        Return the URL where the configuration is stored.
        Specified by:
        getURL in interface FileConfiguration
        Returns:
        the URL of the configuration
      • setURL

        public void setURL​(java.net.URL url)
        Description copied from interface: FileConfiguration
        The URL where the configuration is stored.
        Specified by:
        setURL in interface FileConfiguration
        Parameters:
        url - the URL
      • setAutoSave

        public void setAutoSave​(boolean autoSave)
        Description copied from interface: FileConfiguration
        Enable or disable the automatically saving of modified properties to the disk.
        Specified by:
        setAutoSave in interface FileConfiguration
        Parameters:
        autoSave - true to enable, false to disable
      • isAutoSave

        public boolean isAutoSave()
        Description copied from interface: FileConfiguration
        Tells if properties are automatically saved to the disk.
        Specified by:
        isAutoSave in interface FileConfiguration
        Returns:
        true if auto-saving is enabled, false otherwise
      • refresh

        public void refresh()
                     throws ConfigurationException
        Reloads the associated configuration file. This method first clears the content of this configuration, then the associated configuration file is loaded again. Updates on this configuration which have not yet been saved are lost. Calling this method is like invoking reload() without checking the reloading strategy.
        Throws:
        ConfigurationException - if an error occurs
        Since:
        1.7
      • getEncoding

        public java.lang.String getEncoding()
        Description copied from interface: FileConfiguration
        Return the encoding used to store the configuration file. If the value is null the default encoding is used.
        Specified by:
        getEncoding in interface FileConfiguration
        Returns:
        the current encoding
      • setEncoding

        public void setEncoding​(java.lang.String encoding)
        Description copied from interface: FileConfiguration
        Set the encoding used to store the configuration file. Set the encoding to null to use the default encoding.
        Specified by:
        setEncoding in interface FileConfiguration
        Parameters:
        encoding - the encoding to use
      • containsKey

        public boolean containsKey​(java.lang.String key)
        Description copied from class: HierarchicalConfiguration
        Checks if the specified key is contained in this configuration. Note that for this configuration the term "contained" means that the key has an associated value. If there is a node for this key that has no value but children (either defined or undefined), this method will still return false .
        Specified by:
        containsKey in interface Configuration
        Overrides:
        containsKey in class HierarchicalConfiguration
        Parameters:
        key - the key to be chekced
        Returns:
        a flag if this key is contained in this configuration
      • getKeys

        public java.util.Iterator<java.lang.String> getKeys()
        Description copied from class: HierarchicalConfiguration
        Returns an iterator with all keys defined in this configuration. Note that the keys returned by this method will not contain any indices. This means that some structure will be lost.

        Specified by:
        getKeys in interface Configuration
        Overrides:
        getKeys in class HierarchicalConfiguration
        Returns:
        an iterator with the defined keys in this configuration
      • getKeys

        public java.util.Iterator<java.lang.String> getKeys​(java.lang.String prefix)
        Description copied from class: HierarchicalConfiguration
        Returns an iterator with all keys defined in this configuration that start with the given prefix. The returned keys will not contain any indices. This implementation tries to locate a node whose key is the same as the passed in prefix. Then the subtree of this node is traversed, and the keys of all nodes encountered (including attributes) are added to the result set.
        Specified by:
        getKeys in interface Configuration
        Overrides:
        getKeys in class HierarchicalConfiguration
        Parameters:
        prefix - the prefix of the keys to start with
        Returns:
        an iterator with the found keys
        See Also:
        Configuration.getKeys()
      • addNodes

        public void addNodes​(java.lang.String key,
                             java.util.Collection<? extends ConfigurationNode> nodes)
        Directly adds sub nodes to this configuration. This implementation checks whether auto save is necessary after executing the operation.
        Overrides:
        addNodes in class HierarchicalConfiguration
        Parameters:
        key - the key where the nodes are to be added
        nodes - a collection with the nodes to be added
        Since:
        1.5
      • fetchNodeList

        protected java.util.List<ConfigurationNode> fetchNodeList​(java.lang.String key)
        Fetches a list of nodes, which are selected by the specified key. This implementation will perform a reload if necessary.
        Overrides:
        fetchNodeList in class HierarchicalConfiguration
        Parameters:
        key - the key
        Returns:
        a list with the selected nodes
      • subnodeConfigurationChanged

        protected void subnodeConfigurationChanged​(ConfigurationEvent event)
        Reacts on changes of an associated subnode configuration. If the auto save mechanism is active, the configuration must be saved.
        Overrides:
        subnodeConfigurationChanged in class HierarchicalConfiguration
        Parameters:
        event - the event describing the change
        Since:
        1.5
      • createDelegate

        protected AbstractHierarchicalFileConfiguration.FileConfigurationDelegate createDelegate()
        Creates the file configuration delegate, i.e. the object that implements functionality required by the FileConfiguration interface. This base implementation will return an instance of the FileConfigurationDelegate class. Derived classes may override it to create a different delegate object.
        Returns:
        the file configuration delegate
      • configurationChanged

        public void configurationChanged​(ConfigurationEvent event)
        Reacts on configuration change events triggered by the delegate. These events are passed to the registered configuration listeners.
        Specified by:
        configurationChanged in interface ConfigurationListener
        Parameters:
        event - the triggered event
        Since:
        1.3
      • configurationError

        public void configurationError​(ConfigurationErrorEvent event)
        Description copied from interface: ConfigurationErrorListener
        Notifies this listener that in an observed configuration an error occurred. All information available about this error, including the causing Throwable object, can be obtained from the passed in event object.
        Specified by:
        configurationError in interface ConfigurationErrorListener
        Parameters:
        event - the event object with information about the error
      • setFileSystem

        public void setFileSystem​(FileSystem fileSystem)
        Set the FileSystem to be used for this Configuration.
        Specified by:
        setFileSystem in interface FileSystemBased
        Parameters:
        fileSystem - The FileSystem to use.