org.jvnet.hk2.config
Class ConfigModel

java.lang.Object
  extended by org.jvnet.hk2.config.ConfigModel

public final class ConfigModel
extends Object

Describes the configuration model for a particular class (called "target type" in this class.) TODO: we need to remember if element values are single-valued or multi-valued.

Author:
Kohsuke Kawaguchi

Nested Class Summary
static class ConfigModel.Node
           
static class ConfigModel.Property
           
 
Field Summary
 Holder<Class> classHolder
          Deferred reference to the class object that can load the configurable type
 Holder<ClassLoader> classLoaderHolder
          Deferred reference to the class loader that loaded the injector.
 Inhabitant<? extends ConfigInjector> injector
          Reference to the ConfigInjector used to inject values to objects of this model.
 String key
          If this model has any property that works as a key.
 String keyedAs
          Fully-qualified name under which this type is indexed.
 String targetTypeName
          Fully-qualified name of the target type that this injector works on.
 
Constructor Summary
ConfigModel(DomDocument document, Inhabitant<? extends ConfigInjector> injector, Map<String,List<String>> description, ServiceLocator locator)
           
 
Method Summary
 String camelCaseToXML(String camelCase)
           
 ConfigModel.Property findIgnoreCase(String xmlName)
          Finds the ConfigModel.Property from either elements or attributes.
 Set<String> getAttributeNames()
          Returns the set of possible attributes names on this configuration model.
 Method getDuckMethod(Method method)
          Obtains the duck method implementation from a method on the ConfigBeanProxy-derived interface.
 ConfigModel.Property getElement(String elementName)
          Returns the Property model for an element associated with this model or null of the element name is not known,
 ConfigModel.Property getElementFromXMlName(String xmlName)
           
 Set<String> getElementNames()
          Returns the list of all posible elements names on this model
 Set<String> getLeafElementNames()
          Returns the list of all the leaf attribute names on this model
 Map<String,List<String>> getMetadata()
           
<T extends ConfigBeanProxy>
Class<T>
getProxyType()
          Return the proxy type for this model
 String getTagName()
          getter for tagName
 ConfigModel.Property toProperty(Method method)
          Obtain XML names (like "abc-def") from strings like "getAbcDef" and "hasAbcDef".
 String trimPrefix(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

injector

public final Inhabitant<? extends ConfigInjector> injector
Reference to the ConfigInjector used to inject values to objects of this model.


classLoaderHolder

public final Holder<ClassLoader> classLoaderHolder
Deferred reference to the class loader that loaded the injector. This classloader can also load the configurable object.


classHolder

public final Holder<Class> classHolder
Deferred reference to the class object that can load the configurable type


targetTypeName

public final String targetTypeName
Fully-qualified name of the target type that this injector works on.


keyedAs

public final String keyedAs
Fully-qualified name under which this type is indexed. This is the class name where the key property is defined.

Null if this type is not keyed.


key

public final String key
If this model has any property that works as a key.

See Also:
ConfigMetadata.KEY
Constructor Detail

ConfigModel

public ConfigModel(DomDocument document,
                   Inhabitant<? extends ConfigInjector> injector,
                   Map<String,List<String>> description,
                   ServiceLocator locator)
Parameters:
description - The description of the model as written in the inhabitants file.
Method Detail

getTagName

public String getTagName()
getter for tagName

Returns:
the element name of this model itself, if this element can appear globally Otherwise null

getAttributeNames

public Set<String> getAttributeNames()
Returns the set of possible attributes names on this configuration model.

Returns:
the set of all possible attributes names on this model

getProxyType

public <T extends ConfigBeanProxy> Class<T> getProxyType()
Return the proxy type for this model

Type Parameters:
T - the proxy type
Returns:
the class object for this proxy type

getLeafElementNames

public Set<String> getLeafElementNames()
Returns the list of all the leaf attribute names on this model

Returns:
the list of all leaf attribute names.

getElementNames

public Set<String> getElementNames()
Returns the list of all posible elements names on this model

Returns:
the list of all posible elements names.

getElement

public ConfigModel.Property getElement(String elementName)
Returns the Property model for an element associated with this model or null of the element name is not known,

Parameters:
elementName - element name identifying the property
Returns:
the Property instance describing the element

getElementFromXMlName

public ConfigModel.Property getElementFromXMlName(String xmlName)

getMetadata

public Map<String,List<String>> getMetadata()

getDuckMethod

public Method getDuckMethod(Method method)
                     throws ClassNotFoundException,
                            NoSuchMethodException
Obtains the duck method implementation from a method on the ConfigBeanProxy-derived interface.

Throws:
ClassNotFoundException
NoSuchMethodException

toProperty

public ConfigModel.Property toProperty(Method method)
Obtain XML names (like "abc-def") from strings like "getAbcDef" and "hasAbcDef".

The conversion rule uses the model to find a good match.


trimPrefix

public String trimPrefix(String name)

camelCaseToXML

public String camelCaseToXML(String camelCase)

findIgnoreCase

public ConfigModel.Property findIgnoreCase(String xmlName)
Finds the ConfigModel.Property from either elements or attributes.

Parameters:
xmlName - XML name to be searched.
Returns:
null if none is found.


Copyright © 2013 Oracle Corporation. All Rights Reserved.