net.beandocument
Class BeanElementFactory

java.lang.Object
  extended bynet.beandocument.BeanElementFactory

public class BeanElementFactory
extends java.lang.Object

Helper class to analyze a bean for its behavior and data and generate the corresponding element types

Author:
Jens Scheffler

Constructor Summary
protected BeanElementFactory()
          Constructs a new analyzer
 
Method Summary
 void addElementMapping(java.lang.Class match, java.lang.Class handler)
          Adds a handler class to the content element handlers list.
 void addExcludeFilter(BeanContentFilter filter)
          Adds an exclude filter to the set of member exclusion filters
 void addIncludeFilter(BeanContentFilter filter)
          Adds an include filter to the set of member inclusion filters
 BeanNodeList evaluateChilds(BeanBaseNode parent, java.lang.Object bean)
          Evaluates the provided bean and captures all retrievable element from it as node list containing all elements.
 boolean filterOK(BeanBaseNode parent, java.lang.Object bean, java.lang.String name, java.lang.Object value)
          Checks if the given element applies to all required filters which were defined for the document.
 BeanElement getElementForObject(BeanBaseNode parent, java.lang.String name, java.lang.Object bean)
          Analyzes the given object and created + returns the correct Element matching to the requested object
 void setMaxDepth(int max)
          Sets the maximum evaluation depth for element nodes
protected  void setOwner(BeanDocument owner)
          Sets the owner for the factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanElementFactory

protected BeanElementFactory()
Constructs a new analyzer

Method Detail

evaluateChilds

public BeanNodeList evaluateChilds(BeanBaseNode parent,
                                   java.lang.Object bean)
Evaluates the provided bean and captures all retrievable element from it as node list containing all elements.

Parameters:
parent - Parent element for the new created element list
bean - Object to evaluate
Returns:
NodeList with generated elements from the object properties

getElementForObject

public BeanElement getElementForObject(BeanBaseNode parent,
                                       java.lang.String name,
                                       java.lang.Object bean)
Analyzes the given object and created + returns the correct Element matching to the requested object

Parameters:
parent - Parent node to pass as parent for construction new elements
name - Name for the new Element to create
bean - Object to evaluate and create element from
Returns:
Correct BeanElement instance matching to requested parameters

addElementMapping

public void addElementMapping(java.lang.Class match,
                              java.lang.Class handler)
                       throws java.lang.IllegalArgumentException
Adds a handler class to the content element handlers list.

Parameters:
match - Class of which the bean need to be instance of. If null, the default handler will be overridden.
handler - Handler class which will generate the element. This must me subclass of BeanElement
Throws:
java.lang.IllegalArgumentException - if hander is invalid

setOwner

protected void setOwner(BeanDocument owner)
Sets the owner for the factory

Parameters:
owner - Owner document for this instance

setMaxDepth

public void setMaxDepth(int max)
Sets the maximum evaluation depth for element nodes

Parameters:
max - Maximum depth to evaluate

addIncludeFilter

public void addIncludeFilter(BeanContentFilter filter)
Adds an include filter to the set of member inclusion filters

Parameters:
filter - Filter to add to the filter chain

addExcludeFilter

public void addExcludeFilter(BeanContentFilter filter)
Adds an exclude filter to the set of member exclusion filters

Parameters:
filter - Filter to add to the filter chain

filterOK

public boolean filterOK(BeanBaseNode parent,
                        java.lang.Object bean,
                        java.lang.String name,
                        java.lang.Object value)
Checks if the given element applies to all required filters which were defined for the document.

Parameters:
parent - Parent element for the new content elements
bean - Bean which contains the content which is evaluated
name - Name of the member
value - Value of the member
Returns:
Flag if the member applies for all filters and is OK.