de.smartics.properties.spi.config.definition
Class DefinitionKeyHelper

Package class diagram package DefinitionKeyHelper
java.lang.Object
  extended by de.smartics.properties.spi.config.definition.DefinitionKeyHelper
All Implemented Interfaces:
Serializable

@ThreadSafe
public final class DefinitionKeyHelper
     
     
extends Object
implements Serializable

Derives a ConfigurationKey from a path found in a definition file.

See Also:
Serialized Form

Constructor Summary
DefinitionKeyHelper()
          Convenience constructor using the default TLDs and not registering any environments, nodes or groups.
DefinitionKeyHelper(PropertiesDefinitionContext context)
          Default constructor.
 
Method Summary
 ConfigurationKey parse(String pathWithFile)
          Parses the given path to create a configuration key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefinitionKeyHelper

public DefinitionKeyHelper()
Convenience constructor using the default TLDs and not registering any environments, nodes or groups.


DefinitionKeyHelper

public DefinitionKeyHelper(PropertiesDefinitionContext context)
                    throws NullPointerException
Default constructor.

Parameters:
context - the context to evaluate the configuration keys from properties file paths.
Throws:
NullPointerException - if context is null.
Method Detail

parse

public ConfigurationKey parse(String pathWithFile)
                       throws IllegalArgumentException
Parses the given path to create a configuration key.

The expected syntax is as follows:

  1. /environment
  2. /environment/node
  3. /environment/node/group
  4. /environment/node/group/application
  5. /environment/node/group/application/version
  6. /environment/group
  7. /environment/group/application
  8. /environment/group/application/version
  9. /group
  10. /group/application
  11. /group/application/version

A file ending with properties following the path will be chopped.

The parser has to determine whether a part of the path is a environment, a node or a group. Since a node is always prefixed by an environment only the following two cases have to be dealt with:

  1. environment vs. group
  2. node vs. group

groups start with

  1. A TLD as registered by default by PropertiesDefinitionContext.DEFAULT_TLDS or explicitly registered with PropertiesDefinitionContext
  2. Two letters followed by a dot (.)
  3. Any sequence of characters that is explicitly registered as a group in the definition.xml file

environments and nodes do not start as groups except they are explicitly registered in the definition.xml file.

Parameters:
pathWithFile - the path to parse.
Returns:
the configuration key.
Throws:
IllegalArgumentException - if the given path is not valid according to the rules given above.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.