public class StringProperty<E extends CharSequence> extends BaseProperty<E> implements ComparableProperty<E>
String type is an any type inherited from CharSequence
.
Provides basic string functions like like(String)
, concat(Object...)
, upper()
and contains(String)
}.
Example:
ObjectSelect.query(Artist.class)
.where(Artist.FIRST_NAME.trim().concat(Artist.LAST_NAME.trim()).length().gt(30))
org.apache.cayenne.exp.property
expressionSupplier, name, type
Modifier | Constructor and Description |
---|---|
protected |
StringProperty(String name,
Expression expression,
Class<E> type)
Constructs a new property with the given name and expression
|
Modifier and Type | Method and Description |
---|---|
StringProperty<E> |
alias(String alias)
Creates alias with different name for this property
|
StringProperty<String> |
concat(Object... args)
Arguments will be converted as follows:
if argument is a
BaseProperty than its expression will be used
if argument is a Expression than it will be used as is
all other values will be converted to String
|
Expression |
contains(String substring)
Creates an expression for a database "LIKE" query with the value converted to a pattern matching anywhere in the
String.
|
Expression |
containsIgnoreCase(String value)
Same as
contains(String) , only using case-insensitive
comparison. |
StringProperty<E> |
enclosing() |
Expression |
endsWith(String value)
Creates an expression for a database "LIKE" query with the value
converted to a pattern matching the tail of a String.
|
Expression |
endsWithIgnoreCase(String value)
Same as
endsWith(String) , only using case-insensitive
comparison. |
NumericProperty<Integer> |
length() |
Expression |
like(String pattern) |
Expression |
like(String pattern,
char escapeChar) |
Expression |
like(StringProperty<?> pattern) |
Expression |
likeIgnoreCase(String pattern) |
Expression |
likeIgnoreCase(StringProperty<?> pattern) |
NumericProperty<Integer> |
locate(String string) |
NumericProperty<Integer> |
locate(StringProperty<? extends String> property) |
StringProperty<String> |
lower() |
Expression |
nlike(String value) |
Expression |
nlike(StringProperty<?> value) |
Expression |
nlikeIgnoreCase(String value) |
Expression |
nlikeIgnoreCase(StringProperty<?> value) |
Expression |
startsWith(String value)
Creates an expression for a database "LIKE" query with the value converted to a pattern matching the beginning of
a String.
|
Expression |
startsWithIgnoreCase(String value)
Same as
startsWith(String) , only using case-insensitive
comparison. |
StringProperty<String> |
substring(int offset,
int length) |
StringProperty<String> |
substring(NumericProperty<?> offset,
NumericProperty<?> length) |
StringProperty<String> |
trim() |
StringProperty<String> |
upper() |
asc, ascInsensitive, ascInsensitives, ascs, count, countDistinct, desc, descInsensitive, descInsensitives, descs, eq, eq, equals, function, function, getAlias, getExpression, getFrom, getFromAll, getName, getType, hashCode, in, in, in, isFalse, isNotNull, isNull, isTrue, ne, ne, nin, nin, nin, operator, operator, path, setIn, setInAll
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
between, between, gt, gt, gte, gte, lt, lt, lte, lte, max, min
getAlias, getExpression, getName, getType
protected StringProperty(String name, Expression expression, Class<E> type)
name
- of the property (will be used as alias for the expression)expression
- expression for propertytype
- of the propertyPropertyFactory.createString(String, Expression, Class)
public Expression like(String pattern)
pattern
- a pattern matching property value. Pattern may include "_" and
"%" wildcard symbols to match any single character or a
sequence of characters. To prevent "_" and "%" from being
treated as wildcards, they need to be escaped and escape char
passed with like(String, char)
method.public Expression like(StringProperty<?> pattern)
pattern
- a pattern matching property value. Pattern may include "_" and
"%" wildcard symbols to match any single character or a
sequence of characters.public Expression like(String pattern, char escapeChar)
pattern
- a properly escaped pattern matching property value. Pattern
may include "_" and "%" wildcard symbols to match any single
character or a sequence of characters.escapeChar
- an escape character used in the pattern to escape "%" and "_".public Expression likeIgnoreCase(String pattern)
public Expression likeIgnoreCase(StringProperty<?> pattern)
public Expression nlike(String value)
public Expression nlike(StringProperty<?> value)
public Expression nlikeIgnoreCase(String value)
public Expression nlikeIgnoreCase(StringProperty<?> value)
public Expression contains(String substring)
substring
- a String to match against property value. "_" and "%" symbols
are NOT treated as wildcards and are escaped when converted to
a LIKE expression.public Expression startsWith(String value)
value
- a String to match against property value. "_" and "%" symbols
are NOT treated as wildcards and are escaped when converted to
a LIKE expression.public Expression endsWith(String value)
value
- a String to match against property value. "_" and "%" symbols
are NOT treated as wildcards and are escaped when converted to
a LIKE expression.public Expression containsIgnoreCase(String value)
contains(String)
, only using case-insensitive
comparison.public Expression startsWithIgnoreCase(String value)
startsWith(String)
, only using case-insensitive
comparison.public Expression endsWithIgnoreCase(String value)
endsWith(String)
, only using case-insensitive
comparison.public NumericProperty<Integer> length()
public NumericProperty<Integer> locate(String string)
public NumericProperty<Integer> locate(StringProperty<? extends String> property)
public StringProperty<String> trim()
public StringProperty<String> upper()
public StringProperty<String> lower()
public StringProperty<String> concat(Object... args)
Arguments will be converted as follows:
BaseProperty
than its expression will be usedExpression
than it will be used as is Usage:
Property<String> fullName = Artist.FIRST_NAME.concat(" ", Artist.SECOND_NAME);
public StringProperty<String> substring(int offset, int length)
public StringProperty<String> substring(NumericProperty<?> offset, NumericProperty<?> length)
public StringProperty<E> alias(String alias)
alias
in class BaseProperty<E extends CharSequence>
public StringProperty<E> enclosing()
enclosing
in class BaseProperty<E extends CharSequence>
Copyright © 2001–2021 Apache Cayenne. All rights reserved.