/** * This method is used to extract the annotations associated with * the type. Annotations extracted include the <code>Root</code> * annotation and the <code>Namespace</code> annotation as well as * other annotations that are used to describe the type. * * @param type this is the type to extract the annotations from */ private void extract(Class type) { for(Annotation label : labels) { if(label instanceof Namespace) { namespace(label); } if(label instanceof NamespaceList) { scope(label); } if(label instanceof Root) { root(label); } if(label instanceof Order) { order(label); } if(label instanceof Default) { access(label); } } }
/** * This is used to assemble the model by perform registrations * based on the <code>Order</code> annotation. The initial * registrations performed by this establish the element and * attribute order for serialization of the schema class. * * @param model the model to perform registrations on * @param order this is the order specified by the class */ private void assembleAttributes(Model model, Order order) throws Exception { for(String value : order.attributes()) { Expression path = builder.build(value); if(!path.isAttribute() && path.isPath()) { throw new PathException("Ordered attribute '%s' references an element in %s", path, detail); } if(!path.isPath()) { Style style = format.getStyle(); String name = style.getAttribute(value); model.registerAttribute(name); } else { registerAttributes(model, path); } } }
/** * This is used to assemble the model by perform registrations * based on the <code>Order</code> annotation. The initial * registrations performed by this establish the element and * attribute order for serialization of the schema class. * * @param model the model to perform registrations on * @param order this is the order specified by the class */ private void assembleElements(Model model, Order order) throws Exception { for(String value : order.elements()) { Expression path = builder.build(value); if(path.isAttribute()) { throw new PathException("Ordered element '%s' references an attribute in %s", path, detail); } registerElements(model, path); } }
/** * This is used to validate the configuration of the scanned class. * If a <code>Text</code> annotation has been used with elements * then validation will fail and an exception will be thrown. * * @param type this is the object type that is being scanned */ public void validate(Class type) throws Exception { Order order = scanner.getOrder(); validateUnions(type); validateElements(type, order); validateAttributes(type, order); validateModel(type); validateText(type); validateTextList(type); }
/** * This is used to validate the configuration of the scanned class. * If an ordered element is specified but does not refer to an * existing element then this will throw an exception. * * @param type this is the object type that is being scanned * @param order this is the order that is to be validated */ private void validateElements(Class type, Order order) throws Exception { if(order != null) { for(String name : order.elements()) { if(!isElement(name)) { throw new ElementException("Ordered element '%s' missing for %s", name, type); } } } }
/** * This is used to validate the configuration of the scanned class. * If an ordered attribute is specified but does not refer to an * existing attribute then this will throw an exception. * * @param type this is the object type that is being scanned * @param order this is the order that is to be validated */ private void validateAttributes(Class type, Order order) throws Exception { if(order != null) { for(String name : order.attributes()) { if(!isAttribute(name)) { throw new AttributeException("Ordered attribute '%s' missing in %s", name, type); } } } }
/** * This is used to acquire the optional order annotation to provide * order to the elements and attributes for the generated XML. This * acts as an override to the order provided by the declaration of * the types within the object. * * @param type this is the type to be scanned for the order */ public void assemble(Class type) throws Exception { Order order = scanner.getOrder(); if(order != null) { assembler.assemble(root, order); } }
/** * This returns the order annotation used to determine the order * of serialization of attributes and elements. The order is a * class level annotation that can be used only once per class * XML schema. If none exists then this will return null. * of the class processed by this scanner. * * @return this returns the name of the object being scanned */ public Order getOrder() { return detail.getOrder(); }
/** * This returns the order annotation used to determine the order * of serialization of attributes and elements. The order is a * class level annotation that can be used only once per class * XML schema. If none exists then this will return null. * of the class processed by this scanner. * * @return this returns the name of the object being scanned */ public Order getOrder() { return order; }
/** * This is used to acquire the <code>Order</code> annotation for * the class schema. The order annotation defines the order that * the elements and attributes should appear within the document. * Providing order in this manner makes the resulting XML more * predictable. If no order is provided, appearance is random. * * @return this returns the order, if any, defined for the class */ public Order getOrder() { return scanner.getOrder(); }
/** * This returns the order annotation used to determine the order * of serialization of attributes and elements. The order is a * class level annotation that can be used only once per class * XML schema. If none exists then this will return null. * of the class processed by this scanner. * * @return this returns the name of the object being scanned */ Order getOrder();
/** * This is used to acquire the <code>Order</code> annotation for * the class schema. The order annotation defines the order that * the elements and attributes should appear within the document. * Providing order in this manner makes the resulting XML more * predictable. If no order is provided, appearance is random. * * @return this returns the order, if any, defined for the class */ public Order getOrder() { return null; }
/** * This is used to assemble the model by perform registrations * based on the <code>Order</code> annotation. The initial * registrations performed by this establish the element and * attribute order for serialization of the schema class. * * @param model the model to perform registrations on * @param order this is the order specified by the class */ public void assemble(Model model, Order order) throws Exception { assembleElements(model, order); assembleAttributes(model, order); }
/** * This is used to acquire the <code>Order</code> annotation for * the class schema. The order annotation defines the order that * the elements and attributes should appear within the document. * Providing order in this manner makes the resulting XML more * predictable. If no order is provided, appearance is random. * * @return this returns the order, if any, defined for the class */ Order getOrder();