public class BeanCreateRule extends Rule
BeanCreateRule
is a Digester Rule for creating beans
from the betwixt XML metadata.
Modifier and Type | Field and Description |
---|---|
private boolean |
addedChildren
Have we added our child rules to the digester?
|
private Class |
beanClass
The type of the bean to create
|
private Context |
context
The Context used when evaluating Updaters
|
private boolean |
createdBean
In this begin-end loop did we actually create a new bean
|
private ElementDescriptor |
descriptor
The descriptor of this element
|
private static Log |
log
Logger
|
private boolean |
matchIDs
Use id's to match beans?
|
private String |
pathPrefix
The prefix added to digester rules
|
digester, namespaceURI
Modifier | Constructor and Description |
---|---|
|
BeanCreateRule(ElementDescriptor descriptor,
Class beanClass)
Convenience constructor which uses
ID's for matching. |
|
BeanCreateRule(ElementDescriptor descriptor,
Class beanClass,
boolean matchIDs)
Constructor uses standard qualified name.
|
private |
BeanCreateRule(ElementDescriptor descriptor,
Class beanClass,
Context context,
String pathPrefix,
boolean matchIDs)
Base constructor (used by other constructors).
|
|
BeanCreateRule(ElementDescriptor descriptor,
Class beanClass,
String pathPrefix)
Convenience constructor which uses
ID's for matching. |
|
BeanCreateRule(ElementDescriptor descriptor,
Class beanClass,
String pathPrefix,
boolean matchIDs)
Constructor taking a class.
|
|
BeanCreateRule(ElementDescriptor descriptor,
Context context,
String pathPrefix)
Convenience constructor which uses
ID's for match. |
|
BeanCreateRule(ElementDescriptor descriptor,
Context context,
String pathPrefix,
boolean matchIDs)
Constructor taking a context.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addChildRules()
Adds the rules to the digester for all child elements
|
protected void |
addChildRules(String prefix,
ElementDescriptor currentDescriptor)
Add child rules for given descriptor at given prefix
|
protected void |
addPrimitiveTypeRule(String path,
ElementDescriptor childDescriptor)
Adds a new Digester rule to process the text as a primitive type
|
protected void |
addRule(String path,
Rule rule)
Safely add a rule with given path.
|
void |
begin(Attributes attributes)
Process the beginning of this element.
|
protected Object |
createBean(Attributes attributes)
Factory method to create new bean instances
|
void |
end()
Process the end of this element.
|
void |
finish()
Tidy up.
|
protected BeanReader |
getBeanReader()
Get the associated bean reader.
|
protected Map |
getBeansById()
Get the map used to index beans (previously read in) by id.
|
protected ElementDescriptor |
getElementDescriptor(ElementDescriptor propertyDescriptor)
Allows the navigation from a reference to a property object to the descriptor defining what
the property is.
|
static void |
setLog(Log aLog)
Set log to be used by
BeanCreateRule instances |
String |
toString()
Return something meaningful for logging.
|
begin, body, body, end, getDigester, getNamespaceURI, setDigester, setNamespaceURI
private static Log log
private ElementDescriptor descriptor
private Context context
private boolean addedChildren
private boolean createdBean
private Class beanClass
private String pathPrefix
private boolean matchIDs
public BeanCreateRule(ElementDescriptor descriptor, Class beanClass, String pathPrefix)
ID's
for matching.descriptor
- the ElementDescriptor
describing the element mappedbeanClass
- the Class
to be createdpathPrefix
- the digester style pathpublic BeanCreateRule(ElementDescriptor descriptor, Class beanClass, String pathPrefix, boolean matchIDs)
descriptor
- the ElementDescriptor
describing the element mappedbeanClass
- the Class
to be createdpathPrefix
- the digester style pathmatchIDs
- should ID
/IDREF
's be used for matchingpublic BeanCreateRule(ElementDescriptor descriptor, Class beanClass)
ID's
for matching.descriptor
- the ElementDescriptor
describing the element mappedbeanClass
- the Class
to be createdpublic BeanCreateRule(ElementDescriptor descriptor, Class beanClass, boolean matchIDs)
descriptor
- the ElementDescriptor
describing the element mappedbeanClass
- the Class
to be createdmatchIDs
- should ID
/IDREF
's be used for matchingpublic BeanCreateRule(ElementDescriptor descriptor, Context context, String pathPrefix)
ID's
for match.descriptor
- the ElementDescriptor
describing the element mappedcontext
- the Context
to be used to evaluate expressionspathPrefix
- the digester path prefixpublic BeanCreateRule(ElementDescriptor descriptor, Context context, String pathPrefix, boolean matchIDs)
descriptor
- the ElementDescriptor
describing the element mappedcontext
- the Context
to be used to evaluate expressionspathPrefix
- the digester path prefixmatchIDs
- should ID
/IDREF
's be used for matchingprivate BeanCreateRule(ElementDescriptor descriptor, Class beanClass, Context context, String pathPrefix, boolean matchIDs)
descriptor
- the ElementDescriptor
describing the element mappedbeanClass
- the Class
of the bean to be createdcontext
- the Context
to be used to evaluate expressionspathPrefix
- the digester path prefixmatchIDs
- should ID
/IDREF
's be used for matchingpublic static void setLog(Log aLog)
BeanCreateRule
instancesaLog
- the Log
implementation for this class to log topublic void begin(Attributes attributes)
protected Object createBean(Attributes attributes)
attributes
- the Attributes
used to match ID/IDREF
protected void addChildRules()
protected void addChildRules(String prefix, ElementDescriptor currentDescriptor)
prefix
- add child rules at this (digester) path prefixcurrentDescriptor
- add child rules for this descriptorprotected BeanReader getBeanReader()
BeanReader
protected ElementDescriptor getElementDescriptor(ElementDescriptor propertyDescriptor)
propertyDescriptor
- find descriptor for property object referenced by this descriptorprotected void addPrimitiveTypeRule(String path, ElementDescriptor childDescriptor)
path
- digester path where this rule will be attachedchildDescriptor
- update this ElementDescriptor
with the body textprotected void addRule(String path, Rule rule)
path
- the digester path to add rule atrule
- the Rule
to addprotected Map getBeansById()