Package org.apache.commons.digester3
Class ObjectCreateRule
- java.lang.Object
-
- org.apache.commons.digester3.Rule
-
- org.apache.commons.digester3.ObjectCreateRule
-
public class ObjectCreateRule extends Rule
Rule implementation that creates a new object and pushes it onto the object stack. When the element is complete, the object will be popped
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ObjectCreateRule.DeferredConstructionCallback
private static class
ObjectCreateRule.ProxyManager
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
attributeName
The attribute containing an override class name if it is present.protected java.lang.String
className
The Java class name of the object to be created.protected java.lang.Class<?>
clazz
The Java class of the object to be created.private java.lang.Class<?>[]
constructorArgumentTypes
The constructor argument types.private java.lang.Object[]
defaultConstructorArguments
The explictly specified default constructor arguments which may be overridden by CallParamRules.private ObjectCreateRule.ProxyManager
proxyManager
Helper object for managing proxies.
-
Constructor Summary
Constructors Constructor Description ObjectCreateRule(java.lang.Class<?> clazz)
Construct an object create rule with the specified class.ObjectCreateRule(java.lang.String className)
Construct an object create rule with the specified class name.ObjectCreateRule(java.lang.String attributeName, java.lang.Class<?> clazz)
Construct an object create rule with the specified class and an optional attribute name containing an override.ObjectCreateRule(java.lang.String className, java.lang.String attributeName)
Construct an object create rule with the specified class name and an optional attribute name containing an override.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
begin(java.lang.String namespace, java.lang.String name, org.xml.sax.Attributes attributes)
This method is called when the beginning of a matching XML element is encountered.private static void
convertTo(java.lang.Class<?>[] types, java.lang.Object[] array)
void
end(java.lang.String namespace, java.lang.String name)
This method is called when the end of a matching XML element is encountered.void
setConstructorArgumentTypes(java.lang.Class<?>... constructorArgumentTypes)
Allows users to specify constructor argument types.void
setDefaultConstructorArguments(java.lang.Object... constructorArguments)
Allows users to specify default constructor arguments.java.lang.String
toString()
-
Methods inherited from class org.apache.commons.digester3.Rule
body, finish, getDigester, getNamespaceURI, setDigester, setNamespaceURI
-
-
-
-
Field Detail
-
attributeName
protected java.lang.String attributeName
The attribute containing an override class name if it is present.
-
clazz
protected java.lang.Class<?> clazz
The Java class of the object to be created.
-
className
protected java.lang.String className
The Java class name of the object to be created.
-
constructorArgumentTypes
private java.lang.Class<?>[] constructorArgumentTypes
The constructor argument types.- Since:
- 3.2
-
defaultConstructorArguments
private java.lang.Object[] defaultConstructorArguments
The explictly specified default constructor arguments which may be overridden by CallParamRules.- Since:
- 3.2
-
proxyManager
private ObjectCreateRule.ProxyManager proxyManager
Helper object for managing proxies.- Since:
- 3.2
-
-
Constructor Detail
-
ObjectCreateRule
public ObjectCreateRule(java.lang.String className)
Construct an object create rule with the specified class name.- Parameters:
className
- Java class name of the object to be created
-
ObjectCreateRule
public ObjectCreateRule(java.lang.Class<?> clazz)
Construct an object create rule with the specified class.- Parameters:
clazz
- Java class name of the object to be created
-
ObjectCreateRule
public ObjectCreateRule(java.lang.String className, java.lang.String attributeName)
Construct an object create rule with the specified class name and an optional attribute name containing an override.- Parameters:
className
- Java class name of the object to be createdattributeName
- Attribute name which, if present, contains an override of the class name to create
-
ObjectCreateRule
public ObjectCreateRule(java.lang.String attributeName, java.lang.Class<?> clazz)
Construct an object create rule with the specified class and an optional attribute name containing an override.- Parameters:
attributeName
- Attribute name which, if present, contains anclazz
- Java class name of the object to be created override of the class name to create
-
-
Method Detail
-
setConstructorArgumentTypes
public void setConstructorArgumentTypes(java.lang.Class<?>... constructorArgumentTypes)
Allows users to specify constructor argument types.- Parameters:
constructorArgumentTypes
- the constructor argument types- Since:
- 3.2
-
setDefaultConstructorArguments
public void setDefaultConstructorArguments(java.lang.Object... constructorArguments)
Allows users to specify default constructor arguments. If a default/no-arg constructor is not available for the target class, these arguments will be used to create the proxy object. For any argument not supplied by aCallParamRule
, the corresponding item from this array will be used to construct the final object as well.- Parameters:
constructorArguments
- the default constructor arguments.- Since:
- 3.2
-
begin
public void begin(java.lang.String namespace, java.lang.String name, org.xml.sax.Attributes attributes) throws java.lang.Exception
This method is called when the beginning of a matching XML element is encountered.- Overrides:
begin
in classRule
- Parameters:
namespace
- the namespace URI of the matching element, or an empty string if the parser is not namespace aware or the element has no namespacename
- the local name if the parser is namespace aware, or just the element name otherwiseattributes
- The attribute list of this element- Throws:
java.lang.Exception
- if any error occurs
-
end
public void end(java.lang.String namespace, java.lang.String name) throws java.lang.Exception
This method is called when the end of a matching XML element is encountered.- Overrides:
end
in classRule
- Parameters:
namespace
- the namespace URI of the matching element, or an empty string if the parser is not namespace aware or the element has no namespacename
- the local name if the parser is namespace aware, or just the element name otherwise- Throws:
java.lang.Exception
- if any error occurs
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
convertTo
private static void convertTo(java.lang.Class<?>[] types, java.lang.Object[] array)
-
-