Class ModelAssembler

java.lang.Object
org.simpleframework.xml.core.ModelAssembler

class ModelAssembler extends Object
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
    attribute    
 
 
The 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 Details

    • builder

      private final ExpressionBuilder builder
      This is used to parse the XPath expressions in the order
    • format

      private final Format format
      This is the format that is used to style the order values.
    • detail

      private final Detail detail
      This is the type this this is assembling the model for.
  • Constructor Details

    • ModelAssembler

      public ModelAssembler(ExpressionBuilder builder, Detail detail, Support support) throws Exception
      Constructor for the ModelAssembler 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 expressions
      detail - this contains the details for the assembler
      support - this contains various support functions
      Throws:
      Exception
  • Method Details

    • assemble

      public void assemble(Model model, Order order) throws Exception
      This is used to assemble the model by perform registrations based on the Order 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 on
      order - this is the order specified by the class
      Throws:
      Exception
    • assembleElements

      private void assembleElements(Model model, Order order) throws Exception
      This is used to assemble the model by perform registrations based on the Order 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 on
      order - this is the order specified by the class
      Throws:
      Exception
    • assembleAttributes

      private void assembleAttributes(Model model, Order order) throws Exception
      This is used to assemble the model by perform registrations based on the Order 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 on
      order - this is the order specified by the class
      Throws:
      Exception
    • registerAttributes

      private void registerAttributes(Model model, Expression path) throws Exception
      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 with
      path - this is the expression to be evaluated
      Throws:
      Exception
    • registerAttribute

      private void registerAttribute(Model model, Expression path) throws Exception
      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 in
      path - this is the path referencing the attribute
      Throws:
      Exception
    • registerElements

      private void registerElements(Model model, Expression path) throws Exception
      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 with
      path - this is the expression to be evaluated
      Throws:
      Exception
    • registerElement

      private void registerElement(Model model, Expression path) throws Exception
      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 in
      path - this is the expression referencing the element
      Throws:
      Exception