Skip to contentPackage: CriteriaBuilder
CriteriaBuilder
Coverage
1: /*
2: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.sessions;
19:
20: import cz.cvut.kbss.jopa.model.query.criteria.CriteriaQuery;
21: import cz.cvut.kbss.jopa.model.query.criteria.Expression;
22: import cz.cvut.kbss.jopa.model.query.criteria.Order;
23: import cz.cvut.kbss.jopa.model.query.criteria.ParameterExpression;
24: import cz.cvut.kbss.jopa.model.query.criteria.Path;
25:
26: /**
27: * Used to construct criteria queries, compound selections, expressions, predicates, orderings.
28: */
29: public interface CriteriaBuilder extends PredicateFactory {
30:
31: /**
32: * Create a CriteriaQuery object with the specified result type.
33: *
34: * @param resultClass type of the query result
35: * @return criteria query object
36: */
37: <T> CriteriaQuery<T> createQuery(Class<T> resultClass);
38:
39: /**
40: * Create an expression that returns the absolute value of its argument.
41: *
42: * @param x expression
43: * @return absolute value
44: */
45: <N extends Number> Expression<N> abs(Expression<N> x);
46:
47: /**
48: * Create an expression that returns the smallest (closest to negative infinity) numeric value that is greater than
49: * or equal to the argument and is equal to a mathematical integer.
50: *
51: * @param x expression
52: * @return ceiling value
53: */
54: <N extends Number> Expression<N> ceil(Expression<N> x);
55:
56: /**
57: * Create an expression that returns the largest (closest to positive infinity) numeric value that is less than or
58: * equal to the argument and is equal to a mathematical integer.
59: *
60: * @param x expression
61: * @return floor value
62: */
63: <N extends Number> Expression<N> floor(Expression<N> x);
64:
65: /**
66: * Create an aggregate expression applying the count operation. Return type of count function in SPARQL is
67: * xsd:integer which JOPA internally represents as Integer.
68: *
69: * @param x expression representing input value to count operation
70: * @return count expression
71: */
72: Expression<Integer> count(Expression<?> x);
73:
74: /**
75: * Create expression to return length of a string.
76: *
77: * @param x string expression
78: * @return length expression
79: */
80: Expression<Integer> length(Expression<String> x);
81:
82: /**
83: * Create a parameter expression.
84: *
85: * @param paramClass parameter class
86: * @return parameter expression
87: */
88: <T> ParameterExpression<T> parameter(Class<T> paramClass);
89:
90: /**
91: * Create a parameter expression with the given name.
92: *
93: * @param paramClass parameter class
94: * @param name name that can be used to refer to the parameter
95: * @return parameter expression
96: */
97: <T> ParameterExpression<T> parameter(Class<T> paramClass, String name);
98:
99: /**
100: * Create an expression for a literal.
101: *
102: * @param value value represented by the expression
103: * @return expression literal
104: */
105: <T> Expression<T> literal(T value);
106:
107: /**
108: * Create an expression for a string literal with language tag.
109: *
110: * @param value string value represented by the expression
111: * @param languageTag string language tag
112: * @return expression literal
113: */
114: Expression<String> literal(String value, String languageTag);
115:
116: /**
117: * Create expression for converting a string to lowercase.
118: *
119: * @param x string expression
120: * @return expression to convert to lowercase
121: */
122: Expression<String> lower(Expression<String> x);
123:
124: /**
125: * Create expression for converting a string to uppercase.
126: *
127: * @param x string expression
128: * @return expression to convert to uppercase
129: */
130: Expression<String> upper(Expression<String> x);
131:
132: /**
133: * Create expression for extracting language tag from a string literal.
134: *
135: * @param x String-valued attribute
136: * @return Expression to extract language tag
137: */
138: Expression<String> lang(Path<String> x);
139:
140: /**
141: * Create an ordering by the ascending value of the expression.
142: *
143: * @param x expression used to define the ordering
144: * @return ascending ordering corresponding to the expression
145: */
146: Order asc(Expression<?> x);
147:
148: /**
149: * Create an ordering by the descending value of the expression.
150: *
151: * @param x expression used to define the ordering
152: * @return descending ordering corresponding to the expression
153: */
154: Order desc(Expression<?> x);
155: }