Package org.jfree.xml.generator
Class ModelBuilder
- java.lang.Object
-
- org.jfree.xml.generator.ModelBuilder
-
public final class ModelBuilder extends java.lang.ObjectA model builder. This class performs the work of creating a class description model from a set of source files.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.PropertieshandlerMappingThe handler mapping.private static ModelBuilderinstanceThe single instance.
-
Constructor Summary
Constructors Modifier Constructor Description privateModelBuilder()Creates a single instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttributeHandlers(java.util.Properties p)Adds attribute handlers.DescriptionModelbuildModel(SourceCollector c, DescriptionModel model)Builds a model from the classes provided by theSourceCollector.private booleancontains(java.lang.Class[] cAll, java.lang.Class c)Checks, whether the classcis contained in the given class array.private ClassDescriptioncreateClassDescription(java.beans.BeanInfo beanInfo, ClassDescription parent)Creates aClassDescriptionobject for the specified bean info.PropertyInfocreateSimplePropertyInfo(java.beans.PropertyDescriptor pd)Creates aPropertyInfoobject from aPropertyDescriptor.private java.lang.Class[]fillModel(java.lang.Class[] classes, DescriptionModel model)Updates the model to contain the given classes.private voidfillSuperClasses(DescriptionModel model)Fills the super class for all object descriptions of the model.private java.lang.Class[]findElementTypes(DescriptionModel model)private java.lang.StringgetHandlerClass(java.lang.Class c)Returns the class name for the attribute handler for a property of the specified class.static ModelBuildergetInstance()Returns the single instance of this class.private booleanisAttributeProperty(java.lang.Class c)Checks, whether the given class can be handled as attribute.static booleanisValidMethod(java.lang.reflect.Method method)Checks, whether the given method can be called from the generic object factory.
-
-
-
Field Detail
-
instance
private static ModelBuilder instance
The single instance.
-
handlerMapping
private java.util.Properties handlerMapping
The handler mapping.
-
-
Method Detail
-
getInstance
public static ModelBuilder getInstance()
Returns the single instance of this class.- Returns:
- the single instance of this class.
-
addAttributeHandlers
public void addAttributeHandlers(java.util.Properties p)
Adds attribute handlers.- Parameters:
p- the handlers.
-
buildModel
public DescriptionModel buildModel(SourceCollector c, DescriptionModel model)
Builds a model from the classes provided by theSourceCollector.The
DescriptionGeneratorclass invokes this.- Parameters:
c- the source collector.model- the model under construction (nullpermitted).- Returns:
- The completed model.
-
findElementTypes
private java.lang.Class[] findElementTypes(DescriptionModel model)
-
fillSuperClasses
private void fillSuperClasses(DescriptionModel model)
Fills the super class for all object descriptions of the model. The super class is only filled, if the object's super class is contained in the model.- Parameters:
model- the model which should get its superclasses updated.
-
fillModel
private java.lang.Class[] fillModel(java.lang.Class[] classes, DescriptionModel model)Updates the model to contain the given classes.- Parameters:
classes- a list of classes which should be part of the model.model- the model which is updated- Returns:
- A list of super classes which should also be contained in the model.
-
createClassDescription
private ClassDescription createClassDescription(java.beans.BeanInfo beanInfo, ClassDescription parent)
Creates aClassDescriptionobject for the specified bean info.- Parameters:
beanInfo- the bean info.parent- the parent class description.- Returns:
- The class description.
-
isValidMethod
public static boolean isValidMethod(java.lang.reflect.Method method)
Checks, whether the given method can be called from the generic object factory.- Parameters:
method- the method descriptor- Returns:
- true, if the method is not null and public, false otherwise.
-
createSimplePropertyInfo
public PropertyInfo createSimplePropertyInfo(java.beans.PropertyDescriptor pd)
Creates aPropertyInfoobject from aPropertyDescriptor.- Parameters:
pd- the property descriptor.- Returns:
- the property info (
nullpossible).
-
isAttributeProperty
private boolean isAttributeProperty(java.lang.Class c)
Checks, whether the given class can be handled as attribute. All primitive types can be attributes as well as all types which have a custom attribute handler defined.- Parameters:
c- the class which should be checked- Returns:
- true, if the class can be handled as attribute, false otherwise.
-
getHandlerClass
private java.lang.String getHandlerClass(java.lang.Class c)
Returns the class name for the attribute handler for a property of the specified class.- Parameters:
c- the class for which to search an attribute handler- Returns:
- the handler class or null, if this class cannot be handled as attribute.
-
contains
private boolean contains(java.lang.Class[] cAll, java.lang.Class c)Checks, whether the classcis contained in the given class array.- Parameters:
cAll- the list of all classesc- the class to be searched- Returns:
- true, if the class is contained in the array, false otherwise.
-
-