Package org.jfree.xml.util
Class GenericObjectFactory
- java.lang.Object
-
- org.jfree.xml.util.GenericObjectFactory
-
public final class GenericObjectFactory extends java.lang.Object
The generic object factory contains all methods necessary to collect the property values needed to produce a fully instantiated object.
-
-
Field Summary
Fields Modifier and Type Field Description private AttributeDefinition[]
attributeDefinitions
Storage for the attribute definitions.private java.lang.Class
baseClass
The base class.private ConstructorDefinition[]
constructorDefinitions
Storage for the constructor definitions.private LookupDefinition[]
lookupDefinitions
Storage for the lookup definitions.private java.lang.String[]
orderedPropertyNames
The ordered property names.private PropertyDefinition[]
propertyDefinitions
Storage for the property definitions.private java.util.HashMap
propertyInfos
Storage for property info.private java.util.HashMap
propertyValues
Storage for property values.private java.lang.String
registerName
The register name.
-
Constructor Summary
Constructors Modifier Constructor Description GenericObjectFactory(java.lang.Class c, java.lang.String registerName, ConstructorDefinition[] constructors, PropertyDefinition[] propertyDefinitions, LookupDefinition[] lookupDefinitions, AttributeDefinition[] attributeDefinitions, java.lang.String[] orderedPropertyNames)
Creates a new generic object factory.private
GenericObjectFactory(GenericObjectFactory factory)
A copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
createObject()
Creates an object according to the definition.AttributeDefinition[]
getAttributeDefinitions()
Returns the attribute definitions.java.lang.Class
getBaseClass()
Returns the base class.ConstructorDefinition[]
getConstructorDefinitions()
Returns the constructor definitions.GenericObjectFactory
getInstance()
Returns a copy of this instance.LookupDefinition[]
getLookupDefinitions()
Returns the lookup definitions.java.lang.String[]
getOrderedPropertyNames()
Returns the property names.java.lang.Object
getProperty(java.lang.String name)
Returns the value of the specified property.PropertyDefinition
getPropertyDefinitionByPropertyName(java.lang.String propertyName)
Returns the property definition for the specified property name.PropertyDefinition
getPropertyDefinitionByTagName(java.lang.String tagName)
Returns a property definition for the specified tag name.PropertyDefinition[]
getPropertyDefinitions()
Returns the property definitions.private java.beans.PropertyDescriptor
getPropertyDescriptor(java.lang.String propertyName)
Returns a property descriptor.java.lang.String
getRegisterName()
Returns the register name.java.lang.Class
getTypeForTagName(java.lang.String tagName)
Returns the class for a tag name.private boolean
isAssignableOrPrimitive(java.lang.Class baseType, java.lang.Class valueType)
Returnstrue
if the base type is a primitive or assignable from the value type.private boolean
isConstructorProperty(java.lang.String propertyName)
Returnstrue
if the specified property is...boolean
isPropertyDefinition(java.lang.String propertyName)
Returns true if there is a property definition for the specified property name.void
readProperties(java.lang.Object object)
Reads the properties.void
setProperty(java.lang.String propertyName, java.lang.Object value)
Sets a property value.void
writeObjectProperties(java.lang.Object object)
Writes the properties for the object.
-
-
-
Field Detail
-
constructorDefinitions
private final ConstructorDefinition[] constructorDefinitions
Storage for the constructor definitions.
-
propertyDefinitions
private final PropertyDefinition[] propertyDefinitions
Storage for the property definitions.
-
lookupDefinitions
private final LookupDefinition[] lookupDefinitions
Storage for the lookup definitions.
-
attributeDefinitions
private final AttributeDefinition[] attributeDefinitions
Storage for the attribute definitions.
-
orderedPropertyNames
private final java.lang.String[] orderedPropertyNames
The ordered property names.
-
propertyInfos
private final java.util.HashMap propertyInfos
Storage for property info.
-
propertyValues
private final java.util.HashMap propertyValues
Storage for property values.
-
baseClass
private final java.lang.Class baseClass
The base class.
-
registerName
private final java.lang.String registerName
The register name.
-
-
Constructor Detail
-
GenericObjectFactory
public GenericObjectFactory(java.lang.Class c, java.lang.String registerName, ConstructorDefinition[] constructors, PropertyDefinition[] propertyDefinitions, LookupDefinition[] lookupDefinitions, AttributeDefinition[] attributeDefinitions, java.lang.String[] orderedPropertyNames) throws ObjectDescriptionException
Creates a new generic object factory.- Parameters:
c
- the class.registerName
- the (optional) name under which to register the class for any later lookup.constructors
- the constructor definitions.propertyDefinitions
- the property definitions.lookupDefinitions
- the lookup definitions.attributeDefinitions
- the attribute definitions.orderedPropertyNames
- the ordered property names.- Throws:
ObjectDescriptionException
- if there is a problem.
-
GenericObjectFactory
private GenericObjectFactory(GenericObjectFactory factory)
A copy constructor.- Parameters:
factory
- the factory to copy.
-
-
Method Detail
-
getInstance
public GenericObjectFactory getInstance()
Returns a copy of this instance.- Returns:
- a copy of this instance.
-
getRegisterName
public java.lang.String getRegisterName()
Returns the register name.- Returns:
- the register name.
-
getPropertyDescriptor
private java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String propertyName)
Returns a property descriptor.- Parameters:
propertyName
- the property name.- Returns:
- a property descriptor.
-
getTypeForTagName
public java.lang.Class getTypeForTagName(java.lang.String tagName) throws ObjectDescriptionException
Returns the class for a tag name.- Parameters:
tagName
- the tag name.- Returns:
- the class.
- Throws:
ObjectDescriptionException
- if there is a problem.
-
isPropertyDefinition
public boolean isPropertyDefinition(java.lang.String propertyName)
Returns true if there is a property definition for the specified property name.- Parameters:
propertyName
- the property name.- Returns:
- A boolean.
-
getPropertyDefinitionByPropertyName
public PropertyDefinition getPropertyDefinitionByPropertyName(java.lang.String propertyName) throws ObjectDescriptionException
Returns the property definition for the specified property name.- Parameters:
propertyName
- the property name.- Returns:
- the property definition.
- Throws:
ObjectDescriptionException
- if there is no such property for this object.
-
getPropertyDefinitionByTagName
public PropertyDefinition getPropertyDefinitionByTagName(java.lang.String tagName) throws ObjectDescriptionException
Returns a property definition for the specified tag name.- Parameters:
tagName
- the tag name.- Returns:
- the property definition.
- Throws:
ObjectDescriptionException
- if there is no such tag defined for this object.
-
getConstructorDefinitions
public ConstructorDefinition[] getConstructorDefinitions()
Returns the constructor definitions.- Returns:
- the constructor definitions.
-
getAttributeDefinitions
public AttributeDefinition[] getAttributeDefinitions()
Returns the attribute definitions.- Returns:
- the attribute definitions.
-
getPropertyDefinitions
public PropertyDefinition[] getPropertyDefinitions()
Returns the property definitions.- Returns:
- the property definitions.
-
getOrderedPropertyNames
public java.lang.String[] getOrderedPropertyNames()
Returns the property names.- Returns:
- the property names.
-
getLookupDefinitions
public LookupDefinition[] getLookupDefinitions()
Returns the lookup definitions.- Returns:
- the lookup definitions.
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
Returns the value of the specified property.- Parameters:
name
- the property name.- Returns:
- the property value.
-
createObject
public java.lang.Object createObject() throws ObjectDescriptionException
Creates an object according to the definition.- Returns:
- the object.
- Throws:
ObjectDescriptionException
- if there is a problem with the object description.
-
setProperty
public void setProperty(java.lang.String propertyName, java.lang.Object value) throws ObjectDescriptionException
Sets a property value.- Parameters:
propertyName
- the property name.value
- the property value.- Throws:
ObjectDescriptionException
- if there is a problem with the object description.
-
isAssignableOrPrimitive
private boolean isAssignableOrPrimitive(java.lang.Class baseType, java.lang.Class valueType)
Returnstrue
if the base type is a primitive or assignable from the value type.- Parameters:
baseType
- the base class.valueType
- the value class.- Returns:
- A boolean.
-
isConstructorProperty
private boolean isConstructorProperty(java.lang.String propertyName)
Returnstrue
if the specified property is...- Parameters:
propertyName
- the property name.- Returns:
- A boolean.
-
writeObjectProperties
public void writeObjectProperties(java.lang.Object object) throws ObjectDescriptionException
Writes the properties for the object.- Parameters:
object
- the object.- Throws:
ObjectDescriptionException
- if there is a problem.
-
readProperties
public void readProperties(java.lang.Object object) throws ObjectDescriptionException
Reads the properties.- Parameters:
object
- the object.- Throws:
ObjectDescriptionException
- if there is a problem.
-
getBaseClass
public java.lang.Class getBaseClass()
Returns the base class.- Returns:
- the base class.
-
-