Class PatternSubtreeConfigurationWrapper

    • Constructor Detail

      • PatternSubtreeConfigurationWrapper

        public PatternSubtreeConfigurationWrapper​(HierarchicalConfiguration<ImmutableNode> config,
                                                  java.lang.String path)
        Constructor
        Parameters:
        config - The Configuration to be wrapped.
        path - The base path pattern.
    • Method Detail

      • addPropertyInternal

        protected void addPropertyInternal​(java.lang.String key,
                                           java.lang.Object value)
        Description copied from class: AbstractHierarchicalConfiguration
        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:
        addPropertyInternal in class AbstractHierarchicalConfiguration<ImmutableNode>
        Parameters:
        key - the key of the new property
        value - the value of the new property
      • clearPropertyDirect

        protected void clearPropertyDirect​(java.lang.String key)
        Description copied from class: AbstractHierarchicalConfiguration
        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. This implementation delegates to the node+ model.
        Overrides:
        clearPropertyDirect in class AbstractHierarchicalConfiguration<ImmutableNode>
        Parameters:
        key - the key of the property to be removed
      • containsKeyInternal

        protected boolean containsKeyInternal​(java.lang.String key)
        Description copied from class: AbstractHierarchicalConfiguration
        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 .
        Overrides:
        containsKeyInternal in class AbstractHierarchicalConfiguration<ImmutableNode>
        Parameters:
        key - the key to be checked
        Returns:
        a flag if this key is contained in this configuration
      • getBigDecimal

        public java.math.BigDecimal getBigDecimal​(java.lang.String key,
                                                  java.math.BigDecimal defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a BigDecimal associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getBigDecimal in interface ImmutableConfiguration
        Overrides:
        getBigDecimal in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated BigDecimal if key is found and has valid format, default value otherwise.
      • getBigInteger

        public java.math.BigInteger getBigInteger​(java.lang.String key,
                                                  java.math.BigInteger defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a BigInteger associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getBigInteger in interface ImmutableConfiguration
        Overrides:
        getBigInteger in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated BigInteger if key is found and has valid format, default value otherwise.
      • getBoolean

        public boolean getBoolean​(java.lang.String key,
                                  boolean defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a boolean associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getBoolean in interface ImmutableConfiguration
        Overrides:
        getBoolean in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated boolean.
      • getBoolean

        public java.lang.Boolean getBoolean​(java.lang.String key,
                                            java.lang.Boolean defaultValue)
        Description copied from class: AbstractConfiguration
        Obtains the value of the specified key and tries to convert it into a Boolean object. If the property has no value, the passed in default value will be used.
        Specified by:
        getBoolean in interface ImmutableConfiguration
        Overrides:
        getBoolean in class AbstractConfiguration
        Parameters:
        key - the key of the property
        defaultValue - the default value
        Returns:
        the value of this key converted to a Boolean
      • getByte

        public byte getByte​(java.lang.String key,
                            byte defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a byte associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getByte in interface ImmutableConfiguration
        Overrides:
        getByte in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated byte.
      • getByte

        public java.lang.Byte getByte​(java.lang.String key,
                                      java.lang.Byte defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a Byte associated with the given configuration key.
        Specified by:
        getByte in interface ImmutableConfiguration
        Overrides:
        getByte in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated byte if key is found and has valid format, default value otherwise.
      • getDouble

        public double getDouble​(java.lang.String key,
                                double defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a double associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getDouble in interface ImmutableConfiguration
        Overrides:
        getDouble in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated double.
      • getDouble

        public java.lang.Double getDouble​(java.lang.String key,
                                          java.lang.Double defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a Double associated with the given configuration key.
        Specified by:
        getDouble in interface ImmutableConfiguration
        Overrides:
        getDouble in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated double if key is found and has valid format, default value otherwise.
      • getFloat

        public float getFloat​(java.lang.String key,
                              float defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a float associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getFloat in interface ImmutableConfiguration
        Overrides:
        getFloat in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated float.
      • getFloat

        public java.lang.Float getFloat​(java.lang.String key,
                                        java.lang.Float defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a Float associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getFloat in interface ImmutableConfiguration
        Overrides:
        getFloat in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated float if key is found and has valid format, default value otherwise.
      • getInt

        public int getInt​(java.lang.String key,
                          int defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a int associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getInt in interface ImmutableConfiguration
        Overrides:
        getInt in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated int.
      • getInteger

        public java.lang.Integer getInteger​(java.lang.String key,
                                            java.lang.Integer defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get an Integer associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getInteger in interface ImmutableConfiguration
        Overrides:
        getInteger in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated int if key is found and has valid format, default value otherwise.
      • getKeysInternal

        protected java.util.Iterator<java.lang.String> getKeysInternal()
        Description copied from class: AbstractHierarchicalConfiguration
        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.
        Overrides:
        getKeysInternal in class AbstractHierarchicalConfiguration<ImmutableNode>
        Returns:
        an iterator with the defined keys in this configuration
      • getKeysInternal

        protected java.util.Iterator<java.lang.String> getKeysInternal​(java.lang.String prefix)
        Description copied from class: AbstractHierarchicalConfiguration
        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.
        Overrides:
        getKeysInternal in class AbstractHierarchicalConfiguration<ImmutableNode>
        Parameters:
        prefix - the prefix of the keys to start with
        Returns:
        an iterator with the found keys
      • getList

        public java.util.List<java.lang.Object> getList​(java.lang.String key)
        Description copied from class: AbstractConfiguration
        Get a List of the values associated with the given configuration key. This method is different from the generic getList() method in that it does not recursively obtain all values stored for the specified property key. Rather, only the first level of the hierarchy is processed. So the resulting list may contain complex objects like arrays or collections - depending on the storage structure used by a concrete subclass. If the key doesn't map to an existing object, an empty List is returned.
        Specified by:
        getList in interface ImmutableConfiguration
        Overrides:
        getList in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        Returns:
        The associated List.
        See Also:
        AbstractConfiguration.getStringArray(String)
      • getLong

        public long getLong​(java.lang.String key,
                            long defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a long associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getLong in interface ImmutableConfiguration
        Overrides:
        getLong in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated long.
      • getLong

        public java.lang.Long getLong​(java.lang.String key,
                                      java.lang.Long defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a Long associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getLong in interface ImmutableConfiguration
        Overrides:
        getLong in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated long if key is found and has valid format, default value otherwise.
      • getProperties

        public java.util.Properties getProperties​(java.lang.String key)
        Description copied from interface: ImmutableConfiguration
        Get a list of properties associated with the given configuration key. This method expects the given key to have an arbitrary number of String values, each of which is of the form key=value. These strings are split at the equals sign, and the key parts will become keys of the returned Properties object, the value parts become values.
        Specified by:
        getProperties in interface ImmutableConfiguration
        Overrides:
        getProperties in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        Returns:
        The associated properties if key is found.
      • getShort

        public short getShort​(java.lang.String key,
                              short defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a short associated with the given configuration key.
        Specified by:
        getShort in interface ImmutableConfiguration
        Overrides:
        getShort in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated short.
      • getShort

        public java.lang.Short getShort​(java.lang.String key,
                                        java.lang.Short defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a Short associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getShort in interface ImmutableConfiguration
        Overrides:
        getShort in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated short if key is found and has valid format, default value otherwise.
      • getString

        public java.lang.String getString​(java.lang.String key,
                                          java.lang.String defaultValue)
        Description copied from interface: ImmutableConfiguration
        Get a string associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
        Specified by:
        getString in interface ImmutableConfiguration
        Overrides:
        getString in class AbstractConfiguration
        Parameters:
        key - The configuration key.
        defaultValue - The default value.
        Returns:
        The associated string if key is found and has valid format, default value otherwise.
      • subset

        public Configuration subset​(java.lang.String prefix)
        Description copied from class: BaseHierarchicalConfiguration
        Creates a new Configuration object containing all keys that start with the specified prefix. This implementation will return a BaseHierarchicalConfiguration object so that the structure of the keys will be saved. The nodes selected by the prefix (it is possible that multiple nodes are selected) are mapped to the root node of the returned configuration, i.e. their children and attributes will become children and attributes of the new root node. However, a value of the root node is only set if exactly one of the selected nodes contain a value (if multiple nodes have a value, there is simply no way to decide how these values are merged together). Note that the returned Configuration object is not connected to its source configuration: updates on the source configuration are not reflected in the subset and vice versa. The returned configuration uses the same Synchronizer as this configuration.
        Specified by:
        subset in interface Configuration
        Overrides:
        subset in class BaseHierarchicalConfiguration
        Parameters:
        prefix - the prefix of the keys for the subset
        Returns:
        a new configuration object representing the selected subset
        See Also:
        SubsetConfiguration
      • addNodesInternal

        protected void addNodesInternal​(java.lang.String key,
                                        java.util.Collection<? extends ImmutableNode> nodes)
        Description copied from class: AbstractHierarchicalConfiguration
        Actually adds a collection of new nodes to this configuration. This method is called by addNodes(). It can be overridden by subclasses that need to adapt this operation.
        Overrides:
        addNodesInternal in class AbstractHierarchicalConfiguration<ImmutableNode>
        Parameters:
        key - the key where the nodes are to be added; can be null, then they are added to the root node
        nodes - a collection with the Node objects to be added
      • configurationAt

        public HierarchicalConfiguration<ImmutableNode> configurationAt​(java.lang.String key,
                                                                        boolean supportUpdates)
        Description copied from class: BaseHierarchicalConfiguration

        Returns a hierarchical sub configuration object that wraps the configuration node specified by the given key. This method provides an easy means of accessing sub trees of a hierarchical configuration. In the returned configuration the sub tree can directly be accessed, it becomes the root node of this configuration. Because of this the passed in key must select exactly one configuration node; otherwise an IllegalArgumentException will be thrown.

        The difference between this method and the Configuration.subset(String) method is that subset() supports arbitrary subsets of configuration nodes while configurationAt() only returns a single sub tree. Please refer to the documentation of the SubnodeConfiguration class to obtain further information about sub configurations and when they should be used.

        With the supportUpdate flag the behavior of the returned sub configuration regarding updates of its parent configuration can be determined. If set to false, the configurations return on independent nodes structures. So changes made on one configuration cannot be seen by the other one. A value of true in contrast creates a direct connection between both configurations - they are then using the same underlying data structures as much as possible. There are however changes which break this connection; for instance, if the sub tree the sub configuration belongs to is completely removed from the parent configuration. If such a change happens, the sub configuration becomes detached from its parent. It can still be used in a normal way, but changes on it are not reflected by the parent and vice verse. Also, it is not possible to reattach a once detached sub configuration.

        The result of this implementation depends on the supportUpdates flag: If it is false, a plain BaseHierarchicalConfiguration is returned using the selected node as root node. This is suitable for read-only access to properties. Because the configuration returned in this case is not connected to the parent configuration, updates on properties made by one configuration are not reflected by the other one. A value of true for this parameter causes a tracked node to be created, and result is a SubnodeConfiguration based on this tracked node. This configuration is really connected to its parent, so that updated properties are visible on both.
        Specified by:
        configurationAt in interface HierarchicalConfiguration<ImmutableNode>
        Overrides:
        configurationAt in class BaseHierarchicalConfiguration
        Parameters:
        key - the key that selects the sub tree
        supportUpdates - a flag whether the returned sub configuration should be directly connected to its parent
        Returns:
        a hierarchical configuration that contains this sub tree
        See Also:
        SubnodeConfiguration
      • configurationsAt

        public java.util.List<HierarchicalConfiguration<ImmutableNode>> configurationsAt​(java.lang.String key)
        Description copied from class: BaseHierarchicalConfiguration
        Returns a list of sub configurations for all configuration nodes selected by the given key. This method will evaluate the passed in key (using the current ExpressionEngine) and then create a sub configuration for each returned node (like HierarchicalConfiguration.configurationAt(String) ). This is especially useful when dealing with list-like structures. As an example consider the configuration that contains data about database tables and their fields. If you need access to all fields of a certain table, you can simply do
         List fields = config.configurationsAt("tables.table(0).fields.field");
         for(Iterator it = fields.iterator(); it.hasNext();)
         {
             BaseHierarchicalConfiguration sub = (BaseHierarchicalConfiguration) it.next();
             // now the children and attributes of the field node can be
             // directly accessed
             String fieldName = sub.getString("name");
             String fieldType = sub.getString("type");
             ...
         
        The configuration objects returned are not connected to the parent configuration. This implementation creates sub configurations in the same way as described for BaseHierarchicalConfiguration.configurationAt(String).
        Specified by:
        configurationsAt in interface HierarchicalConfiguration<ImmutableNode>
        Overrides:
        configurationsAt in class BaseHierarchicalConfiguration
        Parameters:
        key - the key for selecting the desired nodes
        Returns:
        a list with hierarchical configuration objects; each configuration represents one of the nodes selected by the passed in key
      • clearTreeInternal

        protected java.lang.Object clearTreeInternal​(java.lang.String key)
        Description copied from class: AbstractHierarchicalConfiguration
        Actually clears the tree of elements referenced by the given key. This method is called by clearTree(). Subclasses that need to adapt this operation can override this method. This base implementation delegates to the node model.
        Overrides:
        clearTreeInternal in class AbstractHierarchicalConfiguration<ImmutableNode>
        Parameters:
        key - the key of the property to be removed
        Returns:
        an object with information about the nodes that have been removed (this is needed for firing a meaningful event of type CLEAR_TREE)
      • getMaxIndexInternal

        protected int getMaxIndexInternal​(java.lang.String key)
        Description copied from class: AbstractHierarchicalConfiguration
        Actually retrieves the maximum defined index for the given key. This method is called by getMaxIndex(). Subclasses that need to adapt this operation have to override this method.
        Overrides:
        getMaxIndexInternal in class AbstractHierarchicalConfiguration<ImmutableNode>
        Parameters:
        key - the key to be checked
        Returns:
        the maximum defined index for this key
      • interpolatedConfiguration

        public Configuration interpolatedConfiguration()
        Description copied from class: BaseHierarchicalConfiguration
        Returns a configuration with the same content as this configuration, but with all variables replaced by their actual values. This implementation is specific for hierarchical configurations. It clones the current configuration and runs a specialized visitor on the clone, which performs interpolation on the single configuration nodes.
        Overrides:
        interpolatedConfiguration in class BaseHierarchicalConfiguration
        Returns:
        a configuration with all variables interpolated
      • addEventListener

        public <T extends Event> void addEventListener​(EventType<T> eventType,
                                                       EventListener<? super T> listener)
        Description copied from interface: EventSource
        Adds an event listener for the specified event type. This listener is notified about events of this type and all its sub types.
        Specified by:
        addEventListener in interface EventSource
        Overrides:
        addEventListener in class BaseEventSource
        Type Parameters:
        T - the type of events processed by this listener
        Parameters:
        eventType - the event type (must not be null)
        listener - the listener to be registered (must not be null)
      • removeEventListener

        public <T extends Event> boolean removeEventListener​(EventType<T> eventType,
                                                             EventListener<? super T> listener)
        Description copied from interface: EventSource
        Removes the event listener registration for the given event type and listener. An event listener instance may be registered multiple times for different event types. Therefore, when removing a listener the event type of the registration in question has to be specified. The return value indicates whether a registration was removed. A value of false means that no such combination of event type and listener was found.
        Specified by:
        removeEventListener in interface EventSource
        Overrides:
        removeEventListener in class BaseEventSource
        Type Parameters:
        T - the type of events processed by this listener
        Parameters:
        eventType - the event type
        listener - the event listener to be removed
        Returns:
        a flag whether a listener registration was removed
      • getEventListeners

        public <T extends Event> java.util.Collection<EventListener<? super T>> getEventListeners​(EventType<T> eventType)
        Description copied from class: BaseEventSource
        Returns a collection with all event listeners of the specified event type that are currently registered at this object.
        Overrides:
        getEventListeners in class BaseEventSource
        Type Parameters:
        T - the event type
        Parameters:
        eventType - the event type object
        Returns:
        a collection with the event listeners of the specified event type (this collection is a snapshot of the currently registered listeners; it cannot be manipulated)
      • write

        public void write​(java.io.Writer writer)
                   throws ConfigurationException,
                          java.io.IOException
        Description copied from interface: FileBased
        Writes the content of this object to the given writer. Client code should not call this method directly, but use a FileHandler for writing data.
        Specified by:
        write in interface FileBased
        Parameters:
        writer - the writer
        Throws:
        ConfigurationException - if a non-I/O related problem occurs, e.g. the data read does not have the expected format
        java.io.IOException - if an I/O error occurs
      • read

        public void read​(java.io.Reader reader)
                  throws ConfigurationException,
                         java.io.IOException
        Description copied from interface: FileBased
        Reads the content of this object from the given reader. Client code should not call this method directly, but use a FileHandler for reading data.
        Specified by:
        read in interface FileBased
        Parameters:
        reader - the reader
        Throws:
        ConfigurationException - if a non-I/O related problem occurs, e.g. the data read does not have the expected format
        java.io.IOException - if an I/O error occurs