/** * 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 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 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 <code>read</code> method will read the XML element list from * the provided node and deserialize its children as entry types. * This will deserialize each entry type as a primitive value. In * order to do this the parent string provided forms the element. * * @param node this is the XML element that is to be deserialized * @param list this is the array to read the array values in to * * @return this returns the item to attach to the object contact */ public Object read(InputNode node, Object list) throws Exception{ int length = Array.getLength(list); for(int pos = 0; true; pos++) { Position line = node.getPosition(); InputNode next = node.getNext(); if(next == null) { return list; } if(pos >= length){ throw new ElementException("Array length missing or incorrect for %s at %s", type, line); } Array.set(list, pos, root.read(next)); } }
/** * The <code>readResolve</code> method is used to determine if there * is a resolution method which can be used to substitute the object * deserialized. The resolve method is used when an object wishes * to provide a substitute within the deserialized object graph. * This acts as an equivalent to the Java Object Serialization * <code>readResolve</code> method for the object deserialization. * * @param node the XML element object provided as a replacement * @param source the type of the object that is being deserialized * @param caller this is used to invoke the callback methods * * @return this returns a replacement for the deserialized object */ private Object readResolve(InputNode node, Object source, Caller caller) throws Exception { if(source != null) { Position line = node.getPosition(); Object value = caller.resolve(source); Class expect = type.getType(); Class real = value.getClass(); if(!expect.isAssignableFrom(real)) { throw new ElementException("Type %s does not match %s at %s", real, expect, line); } return value; } return source; }
/** * This <code>read</code> method will read the XML element list from * the provided node and deserialize its children as entry types. * This will deserialize each entry type as a primitive value. In * order to do this the parent string provided forms the element. * * @param node this is the XML element that is to be deserialized * @param list this is the array to read the array values in to * * @return this returns the item to attach to the object contact */ public Object read(InputNode node, Object list) throws Exception{ int length = Array.getLength(list); for(int pos = 0; true; pos++) { Position line = node.getPosition(); InputNode next = node.getNext(); if(next == null) { return list; } if(pos >= length){ throw new ElementException("Array length missing or incorrect for %s at %s", type, line); } Array.set(list, pos, root.read(next)); } }
/** * This <code>read</code> method will read the XML element list from * the provided node and deserialize its children as entry types. * This will deserialize each entry type as a primitive value. In * order to do this the parent string provided forms the element. * * @param node this is the XML element that is to be deserialized * @param list this is the array to read the array values in to * * @return this returns the item to attach to the object contact */ public Object read(InputNode node, Object list) throws Exception{ int length = Array.getLength(list); for(int pos = 0; true; pos++) { Position line = node.getPosition(); InputNode next = node.getNext(); if(next == null) { return list; } if(pos >= length){ throw new ElementException("Array length missing or incorrect for %s at %s", type, line); } Array.set(list, pos, root.read(next)); } }
/** * The <code>readResolve</code> method is used to determine if there * is a resolution method which can be used to substitute the object * deserialized. The resolve method is used when an object wishes * to provide a substitute within the deserialized object graph. * This acts as an equivalent to the Java Object Serialization * <code>readResolve</code> method for the object deserialization. * * @param node the XML element object provided as a replacement * @param source the type of the object that is being deserialized * @param caller this is used to invoke the callback methods * * @return this returns a replacement for the deserialized object */ private Object readResolve(InputNode node, Object source, Caller caller) throws Exception { if(source != null) { Position line = node.getPosition(); Object value = caller.resolve(source); Class expect = type.getType(); Class real = value.getClass(); if(!expect.isAssignableFrom(real)) { throw new ElementException("Type %s does not match %s at %s", real, expect, line); } return value; } return source; }
/** * This <code>read</code> method will read the XML element list from * the provided node and deserialize its children as entry types. * This ensures each entry type is deserialized as a root type, that * is, its <code>Root</code> annotation must be present and the * name of the entry element must match that root element name. * * @param node this is the XML element that is to be deserialized * @param list this is the array that is to be deserialized * * @return this returns the item to attach to the object contact */ public Object read(InputNode node, Object list) throws Exception{ int length = Array.getLength(list); for(int pos = 0; true; pos++) { Position line = node.getPosition(); InputNode next = node.getNext(); if(next == null) { return list; } if(pos >= length){ throw new ElementException("Array length missing or incorrect for %s at %s", type, line); } read(next, list, pos); } }
/** * This is used to acquire the dependent type for the annotated * list. This will simply return the type that the collection is * composed to hold. This must be a serializable type, that is, * a type that is annotated with the <code>Root</code> class. * * @return this returns the component type for the collection */ public Type getDependent() throws Exception { Contact contact = getContact(); if(item == void.class) { item = contact.getDependent(); } if(item == null) { throw new ElementException("Unable to determine generic type for %s", contact); } return new ClassType(item); }
/** * This <code>read</code> method will read the XML element list from * the provided node and deserialize its children as entry types. * This ensures each entry type is deserialized as a root type, that * is, its <code>Root</code> annotation must be present and the * name of the entry element must match that root element name. * * @param node this is the XML element that is to be deserialized * @param list this is the array that is to be deserialized * * @return this returns the item to attach to the object contact */ public Object read(InputNode node, Object list) throws Exception{ int length = Array.getLength(list); for(int pos = 0; true; pos++) { Position line = node.getPosition(); InputNode next = node.getNext(); if(next == null) { return list; } if(pos >= length){ throw new ElementException("Array length missing or incorrect for %s at %s", type, line); } read(next, list, pos); } }
/** * This is used to validate the individual elements within the * model. Validation is done be acquiring all the elements and * determining if they are null. If they are null this means that * an ordering has been imposed on a non-existing element. * * @param type this is the type this model is created for */ private void validateElements(Class type) throws Exception { Set<String> keys = elements.keySet(); for(String name : keys) { ModelList list = models.get(name); Label label = elements.get(name); if(list == null && label == null) { throw new ElementException("Ordered element '%s' does not exist in %s", name, type); } if(list != null && label != null) { if(!list.isEmpty()) { throw new ElementException("Element '%s' is also a path name in %s", name, type); } } if(expression != null) { expression.getElement(name); // prime cache } } }
/** * This <code>read</code> method will read the XML element list from * the provided node and deserialize its children as entry types. * This ensures each entry type is deserialized as a root type, that * is, its <code>Root</code> annotation must be present and the * name of the entry element must match that root element name. * * @param node this is the XML element that is to be deserialized * @param list this is the array that is to be deserialized * * @return this returns the item to attach to the object contact */ public Object read(InputNode node, Object list) throws Exception{ int length = Array.getLength(list); for(int pos = 0; true; pos++) { Position line = node.getPosition(); InputNode next = node.getNext(); if(next == null) { return list; } if(pos >= length){ throw new ElementException("Array length missing or incorrect for %s at %s", type, line); } read(next, list, pos); } }
/** * This is used to acquire the dependent type for the annotated * list. This will simply return the type that the collection is * composed to hold. This must be a serializable type, that is, * a type that is annotated with the <code>Root</code> class. * * @return this returns the component type for the collection */ public Type getDependent() throws Exception { Contact contact = getContact(); if(item == void.class) { item = contact.getDependent(); } if(item == null) { throw new ElementException("Unable to determine generic type for %s", contact); } return new ClassType(item); }
/** * This is used to validate the individual elements within the * model. Validation is done be acquiring all the elements and * determining if they are null. If they are null this means that * an ordering has been imposed on a non-existing element. * * @param type this is the type this model is created for */ private void validateElements(Class type) throws Exception { Set<String> keys = elements.keySet(); for(String name : keys) { ModelList list = models.get(name); Label label = elements.get(name); if(list == null && label == null) { throw new ElementException("Ordered element '%s' does not exist in %s", name, type); } if(list != null && label != null) { if(!list.isEmpty()) { throw new ElementException("Element '%s' is also a path name in %s", name, type); } } if(expression != null) { expression.getElement(name); // prime cache } } }
/** * This is used to acquire the dependent type for the annotated * list. This will simply return the type that the collection is * composed to hold. This must be a serializable type, that is, * a type that is annotated with the <code>Root</code> class. * * @return this returns the component type for the collection */ public Type getDependent() throws Exception { Contact contact = getContact(); if(item == void.class) { item = contact.getDependent(); } if(item == null) { throw new ElementException("Unable to determine generic type for %s", contact); } return new ClassType(item); }
/** * This is used to validate the individual elements within the * model. Validation is done be acquiring all the elements and * determining if they are null. If they are null this means that * an ordering has been imposed on a non-existing element. * * @param type this is the type this model is created for */ private void validateElements(Class type) throws Exception { Set<String> keys = elements.keySet(); for(String name : keys) { ModelList list = models.get(name); Label label = elements.get(name); if(list == null && label == null) { throw new ElementException("Ordered element '%s' does not exist in %s", name, type); } if(list != null && label != null) { if(!list.isEmpty()) { throw new ElementException("Element '%s' is also a path name in %s", name, type); } } if(expression != null) { expression.getElement(name); // prime cache } } }
throw new ElementException("Path section '%s[%s]' is out of sequence in %s", name, index, type);
throw new ElementException("Path section '%s[%s]' is out of sequence in %s", name, index, type);
/** * Validates the data read from the XML document by checking that when <code>MaxRetries</code> is supplied * <code>RetryInterval</code> contains positive non zero value. * * @throws Exception When the read XML is not valid */ @Validate public void validate() throws Exception { if (maxRetries > -1) if (fixedInterval <= 0) throw new ValueRequiredException( "ReceptionAwareness/RetryInterval must have positive non zero value if MaxRetries is set"); else if (!Utils.isNullOrEmpty(flexibleIntervalsText)) throw new ElementException("Invalid combination of MaxRetries and WaitIntervals settings"); // Create the array of intervals and check also that the specified intervals are valid calculateIntervals(); }