Class BeanQuery
java.lang.Object
org.apache.juneau.commons.beanquery.BeanQuery
- Direct Known Subclasses:
BeanQueryRequest
A protocol-agnostic query request against a collection of beans: what to search, which columns to return, how to
sort, and which page to return (design §5.1, §5.3).
Every field is a plain raw value — there are no HTTP-binding annotations, no Optional,
no search map, no page string, and no parsed operators on this bean. A search and opts lives inside those single strings and is
decoded by a session when the query runs, not by this bean.
Fields
- search (
String) — the one search string. Top-level commas (outside parentheses) separate clauses; the first unescaped=separates a column from its raw$-expression (SearchExpressionParser); backslash escapes\,/\=/\\are literals. Columns combine withand. SeeClauseParser. - view (
String) — a comma-separated list of column names, in output order. - sort (
String) — a comma-separated list ofcolumn(ascending) orcolumn:desctokens (a trailing-/+is also accepted). - position (
Integer) — the 0-based first row of the page, ornull for the start. - limit (
Integer) — the page size, ornull for all rows. - opts (
String) — an open bag ofkey=valueclauses (same grammar assearch). The session readscountsand ignores unknown keys.
Construct with create(), which returns a BeanQuery.Builder that assembles these raw strings fluently:
Example:
BeanQuery
The HTTP-binding BeanQueryRequest (juneau-rest-common) extends this class and adds the
@Query bindings.
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds an immutableBeanQuery.static final classA group of cross-column conditions built withBeanQuery.Builder.or(Consumer),BeanQuery.Builder.and(Consumer), orBeanQuery.Builder.not(Consumer). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates aBeanQuery.Builderpre-populated with this query's current state, so individual settings can be changed or added without disturbing the rest.static BeanQuery.Buildercreate()Creates a newBeanQuery.Builder.booleangetLimit()The page size.getOpts()The one opts string (an open bag ofkey=valueclauses).The 0-based first row of the page.The one search string.getSort()The raw sort directive.getView()The raw view (column-selection) directive.inthashCode()Sets the page size.Sets the one opts string.setPosition(Integer value) Sets the 0-based first row of the page.Sets the one search string.Sets the raw sort directive.Sets the raw view (column-selection) directive.toString()
-
Constructor Details
-
BeanQuery
public BeanQuery()
-
-
Method Details
-
create
Creates a newBeanQuery.Builder.- Returns:
- A new builder.
-
getSearch
The one search string.- Returns:
- The search string, or
null if absent.
-
setSearch
Sets the one search string.- Parameters:
value- The search string. Can benull to unset.- Returns:
- This object.
-
getView
The raw view (column-selection) directive.- Returns:
- The view string, or
null if absent.
-
setView
Sets the raw view (column-selection) directive.- Parameters:
value- The view string. Can benull to unset.- Returns:
- This object.
-
getSort
The raw sort directive.- Returns:
- The sort string, or
null if absent.
-
setSort
Sets the raw sort directive.- Parameters:
value- The sort string. Can benull to unset.- Returns:
- This object.
-
getPosition
The 0-based first row of the page.- Returns:
- The position, or
null for the start of the results.
-
setPosition
Sets the 0-based first row of the page.- Parameters:
value- The position. Can benull to unset.- Returns:
- This object.
-
getLimit
The page size.- Returns:
- The limit, or
null for all rows.
-
setLimit
Sets the page size.- Parameters:
value- The limit. Can benull to unset (all rows).- Returns:
- This object.
-
getOpts
The one opts string (an open bag ofkey=valueclauses).- Returns:
- The opts string, or
null if absent.
-
setOpts
Sets the one opts string.- Parameters:
value- The opts string. Can benull to unset.- Returns:
- This object.
-
copy
Creates aBeanQuery.Builderpre-populated with this query's current state, so individual settings can be changed or added without disturbing the rest.getSearch()is re-parsed into the builder's item tree, so a new condition on an existing top-level column merges through$and(...) rather than being dropped or duplicated.- Returns:
- A new builder seeded from this query.
-
equals
-
hashCode
-
toString
-