/** * This is used to register a <code>Model</code> for this builder. * Registration of a model creates a tree of models that is used * to represent an XML structure. Each model can contain elements * and attributes associated with a type. * * @param path this is the path of the model to be resolved * * @return this returns the model that was registered */ private Model create(Expression path) throws Exception { Model model = root; while(model != null) { String prefix = path.getPrefix(); String name = path.getFirst(); int index = path.getIndex(); if(name != null) { model = model.register(name, prefix, index); } if(!path.isPath()) { break; } path = path.getPath(1); } return model; }
/** * This is used to register a <code>Model</code> for this builder. * Registration of a model creates a tree of models that is used * to represent an XML structure. Each model can contain elements * and attributes associated with a type. * * @param path this is the path of the model to be resolved * * @return this returns the model that was registered */ private Model create(Expression path) throws Exception { Model model = root; while(model != null) { String prefix = path.getPrefix(); String name = path.getFirst(); int index = path.getIndex(); if(name != null) { model = model.register(name, prefix, index); } if(!path.isPath()) { break; } path = path.getPath(1); } return model; }
/** * This is used to register a <code>Model</code> for this builder. * Registration of a model creates a tree of models that is used * to represent an XML structure. Each model can contain elements * and attributes associated with a type. * * @param path this is the path of the model to be resolved * * @return this returns the model that was registered */ private Model create(Expression path) throws Exception { Model model = root; while(model != null) { String prefix = path.getPrefix(); String name = path.getFirst(); int index = path.getIndex(); if(name != null) { model = model.register(name, prefix, index); } if(!path.isPath()) { break; } path = path.getPath(1); } return model; }
model.register(name, prefix, index);
model.register(name, prefix, index);
/** * This is used when all details from a field have been gathered * and a <code>Label</code> implementation needs to be created. * This will build a label instance based on the field annotation. * If a label with the same name was already inserted then it is * ignored and the value for that field will not be serialized. * * @param field the field the annotation was extracted from * @param label this is the label representing a field or method * @param map this is used to collect the label instance created * * @throws Exception thrown if the label can not be created */ private void process(Contact field, Label label, LabelMap map) throws Exception { Expression expression = label.getExpression(); String path = label.getPath(); Model model = root; if(!expression.isEmpty()) { model = register(expression); } resolver.register(label); model.register(label); map.put(path, label); }
model.register(name, prefix, index);
/** * This is used when all details from a field have been gathered * and a <code>Label</code> implementation needs to be created. * This will build a label instance based on the field annotation. * If a label with the same name was already inserted then it is * ignored and the value for that field will not be serialized. * * @param field the field the annotation was extracted from * @param label this is the label representing a field or method * @param map this is used to collect the label instance created * * @throws Exception thrown if the label can not be created */ private void process(Contact field, Label label, LabelMap map) throws Exception { Expression expression = label.getExpression(); String path = label.getPath(); Model model = root; if(!expression.isEmpty()) { model = register(expression); } resolver.register(label); model.register(label); map.put(path, label); }
/** * This is used when all details from a field have been gathered * and a <code>Label</code> implementation needs to be created. * This will build a label instance based on the field annotation. * If a label with the same name was already inserted then it is * ignored and the value for that field will not be serialized. * * @param field the field the annotation was extracted from * @param label this is the label representing a field or method * @param map this is used to collect the label instance created * * @throws Exception thrown if the label can not be created */ private void process(Contact field, Label label, LabelMap map) throws Exception { Expression expression = label.getExpression(); String path = label.getPath(); Model model = root; if(!expression.isEmpty()) { model = register(expression); } resolver.register(label); model.register(label); map.put(path, label); }
/** * 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. * * @param model the model to register the element with * @param path this is the expression to be evaluated */ private void registerElements(Model model, Expression path) throws Exception { String prefix = path.getPrefix(); String name = path.getFirst(); int index = path.getIndex(); if(name != null) { Model next = model.register(name, prefix, index); Expression child = path.getPath(1); if(path.isPath()) { registerElements(next, child); } } registerElement(model, path); }
/** * 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. * * @param model the model to register the element with * @param path this is the expression to be evaluated */ private void registerElements(Model model, Expression path) throws Exception { String prefix = path.getPrefix(); String name = path.getFirst(); int index = path.getIndex(); if(name != null) { Model next = model.register(name, prefix, index); Expression child = path.getPath(1); if(path.isPath()) { registerElements(next, child); } } registerElement(model, path); }
/** * 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. * * @param model the model to register the element with * @param path this is the expression to be evaluated */ private void registerElements(Model model, Expression path) throws Exception { String prefix = path.getPrefix(); String name = path.getFirst(); int index = path.getIndex(); if(name != null) { Model next = model.register(name, prefix, index); Expression child = path.getPath(1); if(path.isPath()) { registerElements(next, child); } } registerElement(model, path); }
/** * 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. * * @param model the model to register the attribute with * @param path this is the expression to be evaluated */ private void registerAttributes(Model model, Expression path) throws Exception { String prefix = path.getPrefix(); String name = path.getFirst(); int index = path.getIndex(); if(path.isPath()) { Model next = model.register(name, prefix, index); Expression child = path.getPath(1); if(next == null) { throw new PathException("Element '%s' does not exist in %s", name, detail); } registerAttributes(next, child); } else { registerAttribute(model, path); } }
/** * 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. * * @param model the model to register the attribute with * @param path this is the expression to be evaluated */ private void registerAttributes(Model model, Expression path) throws Exception { String prefix = path.getPrefix(); String name = path.getFirst(); int index = path.getIndex(); if(path.isPath()) { Model next = model.register(name, prefix, index); Expression child = path.getPath(1); if(next == null) { throw new PathException("Element '%s' does not exist in %s", name, detail); } registerAttributes(next, child); } else { registerAttribute(model, path); } }
/** * 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. * * @param model the model to register the attribute with * @param path this is the expression to be evaluated */ private void registerAttributes(Model model, Expression path) throws Exception { String prefix = path.getPrefix(); String name = path.getFirst(); int index = path.getIndex(); if(path.isPath()) { Model next = model.register(name, prefix, index); Expression child = path.getPath(1); if(next == null) { throw new PathException("Element '%s' does not exist in %s", name, detail); } registerAttributes(next, child); } else { registerAttribute(model, path); } }
/** * 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 text(Contact field, Annotation type) throws Exception { Label label = support.getLabel(field, type); Expression expression = label.getExpression(); String path = label.getPath(); Model model = root; if(!expression.isEmpty()) { model = register(expression); } if(texts.get(path) != null) { throw new TextException("Multiple text annotations in %s", type); } resolver.register(label); model.register(label); texts.put(path, 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 text(Contact field, Annotation type) throws Exception { Label label = support.getLabel(field, type); Expression expression = label.getExpression(); String path = label.getPath(); Model model = root; if(!expression.isEmpty()) { model = register(expression); } if(texts.get(path) != null) { throw new TextException("Multiple text annotations in %s", type); } resolver.register(label); model.register(label); texts.put(path, 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 text(Contact field, Annotation type) throws Exception { Label label = support.getLabel(field, type); Expression expression = label.getExpression(); String path = label.getPath(); Model model = root; if(!expression.isEmpty()) { model = register(expression); } if(texts.get(path) != null) { throw new TextException("Multiple text annotations in %s", type); } resolver.register(label); model.register(label); texts.put(path, label); }