Class ModelAssembler


  • class ModelAssembler
    extends java.lang.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:
    Order
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ExpressionBuilder builder
      This is used to parse the XPath expressions in the order
      private Detail detail
      This is the type this this is assembling the model for.
      private Format format
      This is the format that is used to style the order values.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assemble​(Model model, Order order)
      This is used to assemble the model by perform registrations based on the Order annotation.
      private void assembleAttributes​(Model model, Order order)
      This is used to assemble the model by perform registrations based on the Order annotation.
      private void assembleElements​(Model model, Order order)
      This is used to assemble the model by perform registrations based on the Order 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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 Detail

      • ModelAssembler

        public ModelAssembler​(ExpressionBuilder builder,
                              Detail detail,
                              Support support)
                       throws java.lang.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:
        java.lang.Exception
    • Method Detail

      • assemble

        public void assemble​(Model model,
                             Order order)
                      throws java.lang.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:
        java.lang.Exception
      • assembleElements

        private void assembleElements​(Model model,
                                      Order order)
                               throws java.lang.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:
        java.lang.Exception
      • assembleAttributes

        private void assembleAttributes​(Model model,
                                        Order order)
                                 throws java.lang.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:
        java.lang.Exception
      • registerAttributes

        private void registerAttributes​(Model model,
                                        Expression path)
                                 throws java.lang.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:
        java.lang.Exception
      • registerAttribute

        private void registerAttribute​(Model model,
                                       Expression path)
                                throws java.lang.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:
        java.lang.Exception
      • registerElements

        private void registerElements​(Model model,
                                      Expression path)
                               throws java.lang.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:
        java.lang.Exception
      • registerElement

        private void registerElement​(Model model,
                                     Expression path)
                              throws java.lang.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:
        java.lang.Exception