org.riotfamily.common.beans.xml
Class GenericBeanDefinitionParser

java.lang.Object
  extended by org.riotfamily.common.beans.xml.AbstractGenericBeanDefinitionParser
      extended by org.riotfamily.common.beans.xml.GenericBeanDefinitionParser
All Implemented Interfaces:
BeanDefinitionParser

public class GenericBeanDefinitionParser
extends AbstractGenericBeanDefinitionParser

Since:
6.5
Author:
Carsten Woelk [cwoelk at neteye dot de]

Field Summary
 String aliasAttribute
           
static String DEFAULT_ALIAS_ATTRIBUTE
           
 
Fields inherited from class org.riotfamily.common.beans.xml.AbstractGenericBeanDefinitionParser
ID_ATTRIBUTE
 
Constructor Summary
GenericBeanDefinitionParser(Class<?> beanClass)
           
GenericBeanDefinitionParser(String className)
           
 
Method Summary
 GenericBeanDefinitionParser addReference(String attributeName)
           
 GenericBeanDefinitionParser addTranslation(String attributeName, String property)
           
protected  void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
          Parse the supplied Element and populate the supplied BeanDefinitionBuilder as required.
protected  String extractPropertyName(String attributeName)
          Extract a JavaBean property name from the supplied attribute name.
protected  boolean isEligibleAttribute(String attributeName)
          Determine whether the given attribute is eligible for being turned into a corresponding bean property value.
protected  void postProcess(BeanDefinitionBuilder beanDefinition, Element element)
          Hook method that derived classes can implement to inspect/change a bean definition after parsing is complete.
protected  void postProcess(BeanDefinitionBuilder beanDefinition, ParserContext parserContext, Element element)
          Hook method that derived classes can implement to inspect/change a bean definition after parsing is complete.
protected  String resolveAlias(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
          Resolve the alias for the supplied BeanDefinition.
 void setAliasAttribute(String aliasAttribute)
           
 
Methods inherited from class org.riotfamily.common.beans.xml.AbstractGenericBeanDefinitionParser
doParse, parse, parseInternal, postProcessComponentDefinition, registerBeanDefinition, resolveAliases, resolveId, setDecorate, shouldFireEvents, shouldGenerateId, shouldGenerateIdAsFallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ALIAS_ATTRIBUTE

public static final String DEFAULT_ALIAS_ATTRIBUTE
See Also:
Constant Field Values

aliasAttribute

public String aliasAttribute
Constructor Detail

GenericBeanDefinitionParser

public GenericBeanDefinitionParser(Class<?> beanClass)

GenericBeanDefinitionParser

public GenericBeanDefinitionParser(String className)
Method Detail

addTranslation

public GenericBeanDefinitionParser addTranslation(String attributeName,
                                                  String property)

addReference

public GenericBeanDefinitionParser addReference(String attributeName)

setAliasAttribute

public void setAliasAttribute(String aliasAttribute)

resolveAlias

protected String resolveAlias(Element element,
                              AbstractBeanDefinition definition,
                              ParserContext parserContext)
Description copied from class: AbstractGenericBeanDefinitionParser
Resolve the alias for the supplied BeanDefinition. The returned String may contain multiple bean-names separated by commas, semicolons or spaces. The default implementation returns null

Overrides:
resolveAlias in class AbstractGenericBeanDefinitionParser

doParse

protected final void doParse(Element element,
                             ParserContext parserContext,
                             BeanDefinitionBuilder builder)
Parse the supplied Element and populate the supplied BeanDefinitionBuilder as required.

This implementation maps any attributes present on the supplied element to PropertyValue instances, and adds them to the builder.

The extractPropertyName(String) method is used to reconcile the name of an attribute with the name of a JavaBean property.

Overrides:
doParse in class AbstractGenericBeanDefinitionParser
Parameters:
element - the XML element being parsed
parserContext - the object encapsulating the current state of the parsing process
builder - used to define the BeanDefinition
See Also:
extractPropertyName(String)

isEligibleAttribute

protected boolean isEligibleAttribute(String attributeName)
Determine whether the given attribute is eligible for being turned into a corresponding bean property value.

The default implementation considers any attribute as eligible, except for the "id" and "name" attributes.

Parameters:
attributeName - the attribute name taken straight from the XML element being parsed (never null)

extractPropertyName

protected String extractPropertyName(String attributeName)
Extract a JavaBean property name from the supplied attribute name.

The default implementation first looks for a translation set via addTranslation(String, String). If no translation is found, the Conventions.attributeNameToPropertyName(String) method to perform the extraction.

The name returned must obey the standard JavaBean property name conventions. For example for a class with a setter method 'setBingoHallFavourite(String)', the name returned had better be 'bingoHallFavourite' (with that exact casing).

Parameters:
attributeName - the attribute name taken straight from the XML element being parsed (never null)
Returns:
the extracted JavaBean property name (must never be null)

postProcess

protected void postProcess(BeanDefinitionBuilder beanDefinition,
                           ParserContext parserContext,
                           Element element)
Hook method that derived classes can implement to inspect/change a bean definition after parsing is complete.

The default implementation delegates to the postProcess version without ParserContext argument.

Parameters:
beanDefinition - the parsed (and probably totally defined) bean definition being built
parserContext - the object encapsulating the current state of the parsing process
element - the XML element that was the source of the bean definition's metadata

postProcess

protected void postProcess(BeanDefinitionBuilder beanDefinition,
                           Element element)
Hook method that derived classes can implement to inspect/change a bean definition after parsing is complete.

The default implementation does nothing.

Parameters:
beanDefinition - the parsed (and probably totally defined) bean definition being built
element - the XML element that was the source of the bean definition's metadata