Package org.simpleframework.xml.core
Class ModelAssembler
java.lang.Object
org.simpleframework.xml.core.ModelAssembler
The
ModelAssembler
is used to assemble the model
using registrations based on the specified order. The order of
elements and attributes is specified by an Order
annotation. For order, all attributes within an XPath expression
must be valid attribute references, for example
some[1]/path/@attribute path/to/@attribute attributeThe above expressions are all legal references. The final reference specifies an attribute that is not within an XPath expression. If the '@' character is missing from attribute orderings an exception is thrown to indicate this.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ExpressionBuilder
This is used to parse the XPath expressions in the orderprivate final Detail
This is the type this this is assembling the model for.private final Format
This is the format that is used to style the order values. -
Constructor Summary
ConstructorsConstructorDescriptionModelAssembler
(ExpressionBuilder builder, Detail detail, Support support) Constructor for theModelAssembler
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This is used to assemble the model by perform registrations based on theOrder
annotation.private void
assembleAttributes
(Model model, Order order) This is used to assemble the model by perform registrations based on theOrder
annotation.private void
assembleElements
(Model model, Order order) This is used to assemble the model by perform registrations based on theOrder
annotation.private void
registerAttribute
(Model model, Expression path) This will register the attribute specified in the path within the provided model.private void
registerAttributes
(Model model, Expression path) This is used to perform registrations using an expression.private void
registerElement
(Model model, Expression path) This is used to register the element within the specified model.private void
registerElements
(Model model, Expression path) This is used to perform registrations using an expression.
-
Field Details
-
builder
This is used to parse the XPath expressions in the order -
format
This is the format that is used to style the order values. -
detail
This is the type this this is assembling the model for.
-
-
Constructor Details
-
ModelAssembler
Constructor for theModelAssembler
object. If no order has been specified for the schema class then this will perform no registrations on the specified model.- Parameters:
builder
- this is the builder for XPath expressionsdetail
- this contains the details for the assemblersupport
- this contains various support functions- Throws:
Exception
-
-
Method Details
-
assemble
This is used to assemble the model by perform registrations based on theOrder
annotation. The initial registrations performed by this establish the element and attribute order for serialization of the schema class.- Parameters:
model
- the model to perform registrations onorder
- this is the order specified by the class- Throws:
Exception
-
assembleElements
This is used to assemble the model by perform registrations based on theOrder
annotation. The initial registrations performed by this establish the element and attribute order for serialization of the schema class.- Parameters:
model
- the model to perform registrations onorder
- this is the order specified by the class- Throws:
Exception
-
assembleAttributes
This is used to assemble the model by perform registrations based on theOrder
annotation. The initial registrations performed by this establish the element and attribute order for serialization of the schema class.- Parameters:
model
- the model to perform registrations onorder
- this is the order specified by the class- Throws:
Exception
-
registerAttributes
This is used to perform registrations using an expression. Each segment in the expression will create a new model and the final segment of the expression is the attribute.- Parameters:
model
- the model to register the attribute withpath
- this is the expression to be evaluated- Throws:
Exception
-
registerAttribute
This will register the attribute specified in the path within the provided model. Registration here will ensure that the attribute is ordered so that it is placed within the document in a required position.- Parameters:
model
- this is the model to register the attribute inpath
- this is the path referencing the attribute- Throws:
Exception
-
registerElements
This is used to perform registrations using an expression. Each segment in the expression will create a new model and the final segment of the expression is the element.- Parameters:
model
- the model to register the element withpath
- this is the expression to be evaluated- Throws:
Exception
-
registerElement
This is used to register the element within the specified model. To ensure the order does not conflict with expressions the index of the ordered path is checked. If the order comes before an expected order then an exception is thrown. For example, take the following expressions.path[1]/element path[3]/element path[2]/element
In the above the order of appearance of the expressions does not match the indexes of the paths. This causes a conflict. To ensure such a situation does not arise this is checked.- Parameters:
model
- this is the model to register the element inpath
- this is the expression referencing the element- Throws:
Exception
-