Package org.simpleframework.xml.core
Class ParameterFactory
- java.lang.Object
-
- org.simpleframework.xml.core.ParameterFactory
-
class ParameterFactory extends java.lang.Object
TheParameterFactory
object is used to create instances of theParameter
object. Each parameter created can be used to validate against the annotated fields and methods to ensure that the annotations are compatible.The
Parameter
objects created by this are selected using the XML annotation type. If the annotation type is not known the factory will throw an exception, otherwise a parameter instance is created that will expose the properties of the annotation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ParameterFactory.ParameterBuilder
TheParameterBuilder
is used to create a constructor that can be used to instantiate the correct parameter for the XML annotation specified.
-
Constructor Summary
Constructors Constructor Description ParameterFactory(Support support)
Constructor for theParameterFactory
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ParameterFactory.ParameterBuilder
getBuilder(java.lang.annotation.Annotation label)
Creates an entry that is used to select the constructor for the parameter.private java.lang.reflect.Constructor
getConstructor(java.lang.annotation.Annotation label)
Creates a constructor that is used to instantiate the parameter used to represent the specified annotation.Parameter
getInstance(java.lang.reflect.Constructor factory, java.lang.annotation.Annotation label, int index)
Creates aParameter
using the provided constructor and the XML annotation.Parameter
getInstance(java.lang.reflect.Constructor factory, java.lang.annotation.Annotation label, java.lang.annotation.Annotation entry, int index)
Creates aParameter
using the provided constructor and the XML annotation.
-
-
-
Field Detail
-
format
private final Format format
This format contains the style which is used to create names.
-
-
Constructor Detail
-
ParameterFactory
public ParameterFactory(Support support)
Constructor for theParameterFactory
object. This factory is used for creating parameters within a constructor. Parameters can be annotated in the same way as methods or fields, this object is used to create such parameters.- Parameters:
support
- this contains various support functions
-
-
Method Detail
-
getInstance
public Parameter getInstance(java.lang.reflect.Constructor factory, java.lang.annotation.Annotation label, int index) throws java.lang.Exception
Creates aParameter
using the provided constructor and the XML annotation. The parameter produced contains all information related to the constructor parameter. It knows the name of the XML entity, as well as the type.- Parameters:
factory
- this is the constructor the parameter exists inlabel
- represents the XML annotation for the contactindex
- the index of the parameter in the constructor- Returns:
- returns the parameter instantiated for the field
- Throws:
java.lang.Exception
-
getInstance
public Parameter getInstance(java.lang.reflect.Constructor factory, java.lang.annotation.Annotation label, java.lang.annotation.Annotation entry, int index) throws java.lang.Exception
Creates aParameter
using the provided constructor and the XML annotation. The parameter produced contains all information related to the constructor parameter. It knows the name of the XML entity, as well as the type.- Parameters:
factory
- this is the constructor the parameter exists inlabel
- represents the XML annotation for the contactentry
- this is the entry annotation for the parameterindex
- the index of the parameter in the constructor- Returns:
- returns the parameter instantiated for the field
- Throws:
java.lang.Exception
-
getConstructor
private java.lang.reflect.Constructor getConstructor(java.lang.annotation.Annotation label) throws java.lang.Exception
Creates a constructor that is used to instantiate the parameter used to represent the specified annotation. The constructor created by this method takes three arguments, a constructor, an annotation, and the parameter index.- Parameters:
label
- the XML annotation representing the label- Returns:
- returns a constructor for instantiating the parameter
- Throws:
java.lang.Exception
- thrown if the annotation is not supported
-
getBuilder
private ParameterFactory.ParameterBuilder getBuilder(java.lang.annotation.Annotation label) throws java.lang.Exception
Creates an entry that is used to select the constructor for the parameter. Each parameter must implement a constructor that takes a constructor, and annotation, and the index of the parameter. If the annotation is not know this method throws an exception.- Parameters:
label
- the XML annotation used to create the parameter- Returns:
- this returns the entry used to create a constructor
- Throws:
java.lang.Exception
-
-