estivate.core.ast.parser.TableParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of estivate Show documentation
Show all versions of estivate Show documentation
Estivate fills pojo from HTML with CSS Query Syntax and annotations
The newest version!
package estivate.core.ast.parser;
import java.lang.annotation.Annotation;
import estivate.annotations.Table;
import estivate.core.ast.EstivateAST;
import estivate.core.ast.ExpressionAST;
import estivate.core.ast.QueryAST;
import estivate.core.ast.lang.TableQueryAST;
import estivate.core.ast.parser.EstivateParser.AnnotationParser;
import estivate.utils.AnnotationsUtils;
/**
* Parse {@link Table} annotation
*
* @author Benoit Theunissen
*
*/
public class TableParser implements AnnotationParser {
public static final TableParser INSTANCE = new TableParser();
public static final Class TYPE = Table.class;
public void parseAnnotation(EstivateAST ast, Annotation[] annotations) {
Table annotation = AnnotationsUtils.find(annotations, TYPE);
if (annotation != null) {
ast.addQuery(parse(annotation));
}
}
public void parseAnnotation(ExpressionAST ast, Annotation[] annotations) {
Table annotation = AnnotationsUtils.find(annotations, TYPE);
if (annotation != null) {
ast.setOptional(annotation.optional());
ast.addQuery(parse(annotation));
}
}
public static QueryAST parse(Table annotation) {
TableQueryAST query = new TableQueryAST();
query.setRowSelector(annotation.rowSelect());
query.setUnique(true);
query.setIndex(annotation.index());
query.setFirst(annotation.first());
query.setLast(annotation.last());
query.setQueryString(SelectParser.or(annotation.select(), annotation.value()));
SelectParser.validate(query);
return query;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy