/** * This is used to process the <code>Text</code> annotations that * are present in the scanned class. This will set the text label * for the class and an ensure that if there is more than one * text label within the class an exception is thrown. * * @param field the field the annotation was extracted from * @param type the annotation extracted from the field * * @throws Exception if there is more than one text annotation */ private void version(Contact field, Annotation type) throws Exception { Label label = support.getLabel(field, type); if(version != null) { throw new AttributeException("Multiple version annotations in %s", type); } version = label; }
/** * This is used to process the <code>Text</code> annotations that * are present in the scanned class. This will set the text label * for the class and an ensure that if there is more than one * text label within the class an exception is thrown. * * @param field the field the annotation was extracted from * @param type the annotation extracted from the field * * @throws Exception if there is more than one text annotation */ private void version(Contact field, Annotation type) throws Exception { Label label = support.getLabel(field, type); if(version != null) { throw new AttributeException("Multiple version annotations in %s", type); } version = label; }
/** * This is used to process the <code>Text</code> annotations that * are present in the scanned class. This will set the text label * for the class and an ensure that if there is more than one * text label within the class an exception is thrown. * * @param field the field the annotation was extracted from * @param type the annotation extracted from the field * * @throws Exception if there is more than one text annotation */ private void version(Contact field, Annotation type) throws Exception { Label label = support.getLabel(field, type); if(version != null) { throw new AttributeException("Multiple version annotations in %s", type); } version = label; }
/** * 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 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 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 register an XML entity within the model. The * registration process has the affect of telling the model that * it will contain a specific, named, XML entity. It also has * the affect of ordering them within the model, such that the * first registered entity is the first iterated over. * * @param label this is the label to register with the model */ public void registerAttribute(Label label) throws Exception { String name = label.getName(); if(attributes.get(name) != null) { throw new AttributeException("Duplicate annotation of name '%s' on %s", name, label); } attributes.put(name, label); }
/** * This is used to register an XML entity within the model. The * registration process has the affect of telling the model that * it will contain a specific, named, XML entity. It also has * the affect of ordering them within the model, such that the * first registered entity is the first iterated over. * * @param label this is the label to register with the model */ public void registerAttribute(Label label) throws Exception { String name = label.getName(); if(attributes.get(name) != null) { throw new AttributeException("Duplicate annotation of name '%s' on %s", name, label); } attributes.put(name, label); }
/** * This is used to register an XML entity within the model. The * registration process has the affect of telling the model that * it will contain a specific, named, XML entity. It also has * the affect of ordering them within the model, such that the * first registered entity is the first iterated over. * * @param label this is the label to register with the model */ public void registerAttribute(Label label) throws Exception { String name = label.getName(); if(attributes.get(name) != null) { throw new AttributeException("Duplicate annotation of name '%s' on %s", name, label); } attributes.put(name, label); }
/** * This is used to validate the individual attributes within the * model. Validation is done be acquiring all the attributes and * determining if they are null. If they are null this means that * an ordering has been imposed on a non-existing attribute. * * @param type this is the type this model is created for */ private void validateAttributes(Class type) throws Exception { Set<String> keys = attributes.keySet(); for(String name : keys) { Label label = attributes.get(name); if(label == null) { throw new AttributeException("Ordered attribute '%s' does not exist in %s", name, type); } if(expression != null) { expression.getAttribute(name); // prime cache } } }
/** * This is used to validate the individual attributes within the * model. Validation is done be acquiring all the attributes and * determining if they are null. If they are null this means that * an ordering has been imposed on a non-existing attribute. * * @param type this is the type this model is created for */ private void validateAttributes(Class type) throws Exception { Set<String> keys = attributes.keySet(); for(String name : keys) { Label label = attributes.get(name); if(label == null) { throw new AttributeException("Ordered attribute '%s' does not exist in %s", name, type); } if(expression != null) { expression.getAttribute(name); // prime cache } } }
/** * This is used to validate the individual attributes within the * model. Validation is done be acquiring all the attributes and * determining if they are null. If they are null this means that * an ordering has been imposed on a non-existing attribute. * * @param type this is the type this model is created for */ private void validateAttributes(Class type) throws Exception { Set<String> keys = attributes.keySet(); for(String name : keys) { Label label = attributes.get(name); if(label == null) { throw new AttributeException("Ordered attribute '%s' does not exist in %s", name, type); } if(expression != null) { expression.getAttribute(name); // prime cache } } }
/** * Creates a <code>Converter</code> that can convert an attribute * to a double value. This requires the context object used for * the current instance of XML serialization being performed. * * @param context this is context object used for serialization * * @return this returns the converted for this attribute object */ public Converter getConverter(Context context) throws Exception { String ignore = getEmpty(context); Type type = getContact(); if(!context.isFloat(type)) { throw new AttributeException("Cannot use %s to represent %s", label, type); } return new Primitive(context, type, ignore); }
/** * Creates a <code>Converter</code> that can convert an attribute * to a double value. This requires the context object used for * the current instance of XML serialization being performed. * * @param context this is context object used for serialization * * @return this returns the converted for this attribute object */ public Converter getConverter(Context context) throws Exception { String ignore = getEmpty(context); Type type = getContact(); if(!context.isFloat(type)) { throw new AttributeException("Cannot use %s to represent %s", label, type); } return new Primitive(context, type, ignore); }
/** * Creates a <code>Converter</code> that can convert an attribute * to a double value. This requires the context object used for * the current instance of XML serialization being performed. * * @param context this is context object used for serialization * * @return this returns the converted for this attribute object */ public Converter getConverter(Context context) throws Exception { String ignore = getEmpty(context); Type type = getContact(); if(!context.isFloat(type)) { throw new AttributeException("Cannot use %s to represent %s", label, type); } return new Primitive(context, type, ignore); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the key value from * * @return this returns the value deserialized from the node */ public Object read(InputNode node) throws Exception { Position line = node.getPosition(); Class expect = type.getType(); String name = entry.getKey(); if(name == null) { name = context.getName(expect); } if(entry.isAttribute()) { throw new AttributeException("Can not have %s as an attribute for %s at %s", expect, entry, line); } return read(node, name); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the key value from * * @return this returns the value deserialized from the node */ public Object read(InputNode node) throws Exception { Position line = node.getPosition(); Class expect = type.getType(); String name = entry.getKey(); if(name == null) { name = context.getName(expect); } if(entry.isAttribute()) { throw new AttributeException("Can not have %s as an attribute for %s at %s", expect, entry, line); } return read(node, name); }
/** * This <code>readAttribute</code> method is used for deserialization * of the provided node object using a delegate converter. This is * typically another <code>Composite</code> converter, or if the * node is an attribute a <code>Primitive</code> converter. When * the delegate converter has completed the deserialized value is * assigned to the contact. * * @param node this is the node that contains the contact value * @param source the type of the object that is being deserialized * @param section this is the section to read the attribute from * @param map this is the map that contains the label objects */ private void readAttribute(InputNode node, Object source, Section section, LabelMap map) throws Exception { String name = node.getName(); String path = section.getAttribute(name); Label label = map.getLabel(path); if(label == null) { Position line = node.getPosition(); Class expect = context.getType(type, source); if(map.isStrict(context) && revision.isEqual()) { throw new AttributeException("Attribute '%s' does not have a match in %s at %s", path, expect, line); } } else { readInstance(node, source, label); } }
/** * This <code>validateAttribute</code> method performs a validation * of the provided node object using a delegate converter. This is * typically another <code>Composite</code> converter, or if the * node is an attribute a <code>Primitive</code> converter. If this * fails validation then an exception is thrown to report the issue. * * @param node this is the node that contains the contact value * @param section this is the section to validate this attribute in * @param map this is the map that contains the label objects */ private void validateAttribute(InputNode node, Section section, LabelMap map) throws Exception { Position line = node.getPosition(); String name = node.getName(); String path = section.getAttribute(name); Label label = map.getLabel(path); if(label == null) { Class expect = type.getType(); if(map.isStrict(context) && revision.isEqual()) { throw new AttributeException("Attribute '%s' does not exist for %s at %s", path, expect, line); } } else { validate(node, label); } }
/** * This <code>validateAttribute</code> method performs a validation * of the provided node object using a delegate converter. This is * typically another <code>Composite</code> converter, or if the * node is an attribute a <code>Primitive</code> converter. If this * fails validation then an exception is thrown to report the issue. * * @param node this is the node that contains the contact value * @param section this is the section to validate this attribute in * @param map this is the map that contains the label objects */ private void validateAttribute(InputNode node, Section section, LabelMap map) throws Exception { Position line = node.getPosition(); String name = node.getName(); String path = section.getAttribute(name); Label label = map.getLabel(path); if(label == null) { Class expect = type.getType(); if(map.isStrict(context) && revision.isEqual()) { throw new AttributeException("Attribute '%s' does not exist for %s at %s", path, expect, line); } } else { validate(node, label); } }