de.smartics.properties.impl.config.domain.key.envapp
Class AbstractDefinitionConfigParser<T extends PropertiesDefinitionContext>

Package class diagram package AbstractDefinitionConfigParser
java.lang.Object
  extended by de.smartics.properties.impl.config.domain.key.envapp.AbstractDefinitionConfigParser<T>
Type Parameters:
T - the type of context returned by the parser.
All Implemented Interfaces:
DefinitionConfigParser<T>
Direct Known Subclasses:
EnvAppDefinitionConfigParser, TenantUserDefinitionConfigParser

public abstract class AbstractDefinitionConfigParser<T extends PropertiesDefinitionContext>
     
     
extends Object
implements DefinitionConfigParser<T>

Base implementation for parsing a definition.xml file for properties.


Field Summary
protected  org.jdom.Namespace namespace
          The namespace of definition files parsed by this parser.
 
Constructor Summary
protected AbstractDefinitionConfigParser(org.jdom.Namespace namespace)
          Default constructor.
 
Method Summary
protected static String norm(String text)
          Normalizes the text.
 T parse(Class<?> type)
          Convenience method using a class' class loader to locate the configuration file to parse the configuration file at PropertiesContext.DEFINITION_FILE.
 T parse(de.smartics.util.lang.classpath.ClassPathContext context)
          Parses the configuration file at PropertiesContext.DEFINITION_FILE.
protected  ApplicationId readApplication(org.jdom.Element rootNode)
          Parses application information.
protected  EnvironmentId readEnvironment(org.jdom.Element rootNode)
          Parses environment information.
protected  PropertyResourceMatchers readFiles(String systemId, org.jdom.Element rootNode)
          Parsed the map of files from the given element.
protected abstract  ConfigurationKey<?> readKey(org.jdom.Element element)
          Parses the configuration key.
protected  Set<String> readSet(org.jdom.Element rootNode, String setGi, String elementGi)
          Parses a set.
protected  Set<String> readSet(org.jdom.Element rootNode, String setGi, String elementGi, Set<String> defaultSet)
          Parses a set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.smartics.properties.spi.config.definition.DefinitionConfigParser
parse
 

Field Detail

namespace

protected final org.jdom.Namespace namespace
The namespace of definition files parsed by this parser.

Constructor Detail

AbstractDefinitionConfigParser

protected AbstractDefinitionConfigParser(org.jdom.Namespace namespace)
Default constructor.

Parameters:
namespace - the namespace of definition files parsed by this parser.
Method Detail

parse

public final T parse(Class<?> type)
                                                  throws ConfigException
Convenience method using a class' class loader to locate the configuration file to parse the configuration file at PropertiesContext.DEFINITION_FILE.

Specified by:
parse in interface DefinitionConfigParser<T extends PropertiesDefinitionContext>
Parameters:
type - the type whose class loader to use to locate the configuration file.
Returns:
the read configuration, never null.
Throws:
ConfigException - on any problem loading the file.

parse

public final T parse(de.smartics.util.lang.classpath.ClassPathContext context)
                                                  throws ConfigException
Parses the configuration file at PropertiesContext.DEFINITION_FILE.

Specified by:
parse in interface DefinitionConfigParser<T extends PropertiesDefinitionContext>
Parameters:
context - the class loader with its context to use to locate the configuration file.
Returns:
the read configuration, never null.
Throws:
ConfigException - on any problem loading the file.

readSet

protected final Set<String> readSet(org.jdom.Element rootNode,
                                    String setGi,
                                    String elementGi)
Parses a set.

Parameters:
rootNode - the root node that contains the set.
setGi - the name of the element that is the set.
elementGi - the name of the elements within the set.
Returns:
the parsed set.

readSet

protected final Set<String> readSet(org.jdom.Element rootNode,
                                    String setGi,
                                    String elementGi,
                                    Set<String> defaultSet)
Parses a set.

Parameters:
rootNode - the root node that contains the set.
setGi - the name of the element that is the set.
elementGi - the name of the elements within the set.
defaultSet - the set to return if no set is found within the root node.
Returns:
the parsed set.

readFiles

protected final PropertyResourceMatchers readFiles(String systemId,
                                                   org.jdom.Element rootNode)
                                            throws ConfigException
Parsed the map of files from the given element.

Parameters:
systemId - the identifier of the configuration file that is parsed.
rootNode - the node within which the files are.
Returns:
the map of files.
Throws:
ConfigException - if the configuration is not valid.

readKey

protected abstract ConfigurationKey<?> readKey(org.jdom.Element element)
Parses the configuration key.

Parameters:
element - the element within which the elements of the key are located.
Returns:
the configuration key.

readEnvironment

protected final EnvironmentId readEnvironment(org.jdom.Element rootNode)
Parses environment information.

Parameters:
rootNode - the element to parse from.
Returns:
the environment information.

readApplication

protected final ApplicationId readApplication(org.jdom.Element rootNode)
Parses application information.

Parameters:
rootNode - the element to parse from.
Returns:
the application information.

norm

protected static final String norm(String text)
Normalizes the text.

Parameters:
text - the text to normalize.
Returns:
null if text is blank, the text otherwise.


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