public abstract class FieldExpression extends Object implements Cloneable, Serializable
A FieldExpression represents a column or field that is returned in a SearchDocument
.
Each field expression can have an "alias" specified for it. If an "alias" is specified for the field expression, the name of
the field in the returned SearchDocument
will be the specified alias. If an alias is not specified,
then a default alias will be used.
Modifier and Type | Class and Description |
---|---|
protected static class |
FieldExpression.StringMode
Mode for serializing
FieldExpression to a string. |
Modifier and Type | Field and Description |
---|---|
protected String |
alias
The alias for this expression.
|
protected static FieldExpression[] |
EMPTY_ARRAY
Empty array of field expressions.
|
Modifier | Constructor and Description |
---|---|
protected |
FieldExpression()
Construct a new FieldExpression using the default alias.
|
|
FieldExpression(String alias)
Construct a new FieldExpression with an
alias . |
Modifier and Type | Method and Description |
---|---|
FieldExpression |
as(String aliasx)
Set the alias and return this FieldExpression.
|
FieldExpression |
clone() |
boolean |
containsAlias()
Returns true if an alias is specified for this expression.
|
static FieldExpression[] |
copyOf(FieldExpression[] args,
int length)
Create a copy of
args . |
boolean |
equals(Object other) |
abstract boolean |
equalsIgnoreAlias(FieldExpression other)
Returns
true if other is the same as this , with the exception of alias. |
protected static boolean |
equalsIgnoreAlias(FieldExpression a,
FieldExpression b)
Null safe equivalent to
a.equalsIgnoreAlias(b) |
String |
getAlias()
Get the alias.
|
String |
getDefaultAlias()
Get the default alias to use for this FieldExpression.
|
String |
getFieldName()
Get the field name for this expression.
|
abstract SchemaField.Type |
getType(Schema schema)
Resolve the type for this expression.
|
protected static FieldExpression |
handleFieldExpression(FieldExpressionHandler handler,
FieldExpression input) |
abstract boolean |
hasChildren()
Returns
true if this field expression has any sub FieldExpressions. |
int |
hashCode() |
abstract boolean |
isConstant()
Returns
true if this field expression evaluates to a constant value. |
protected static boolean |
isConstant(FieldExpression value) |
protected static void |
quote(StringBuilder buffer,
String text)
Add
text to buffer as quoted string. |
void |
rewrite(QueryHandler handler,
boolean recursive)
Rewrite any query objects in this FieldExpression using
handler . |
protected static void |
rewrite(QueryHandler handler,
boolean recursive,
FieldExpression input) |
abstract FieldExpression |
rewriteChildren(FieldExpressionHandler handler)
Traverse this FieldExpression using
handler to visit/rewrite direct child elements if this expression. |
void |
setAlias(String alias)
Set the alias.
|
String |
toString()
Return String representation of expression.
|
void |
toString(StringBuilder buffer)
Writes the string representation of this field expression to
buffer . |
protected abstract void |
toString(StringBuilder buffer,
FieldExpression.StringMode mode)
Writes the string representation of this field expression to
buffer . |
protected static final FieldExpression[] EMPTY_ARRAY
protected String alias
protected FieldExpression()
public FieldExpression(String alias)
alias
.public abstract SchemaField.Type getType(Schema schema)
public abstract boolean isConstant()
true
if this field expression evaluates to a constant value.public boolean containsAlias()
public final String getDefaultAlias()
public String getAlias()
SearchField
created from this expression.public void setAlias(String alias)
public FieldExpression as(String aliasx)
Useful for call chaining new ExpressionClass(arg).as("alias")
.
public String getFieldName()
This is used as a hint to the search engine to tie back to the schema. null may be returned if this expression contains no field. If this expression is composed of many fields, this can be either the "primary" field for the expression, or null.
public abstract boolean hasChildren()
true
if this field expression has any sub FieldExpressions.public abstract FieldExpression rewriteChildren(FieldExpressionHandler handler)
handler
to visit/rewrite direct child elements if this expression.
NOTE: this method traverses direct child expressions (if any) only.
public void rewrite(QueryHandler handler, boolean recursive)
handler
.public final String toString()
public final void toString(StringBuilder buffer)
buffer
.
NOTE: the alias will not be written to buffer by this function.
protected abstract void toString(StringBuilder buffer, FieldExpression.StringMode mode)
buffer
.
NOTE: the alias will not be written to buffer by this function.
protected static void quote(StringBuilder buffer, String text)
text
to buffer
as quoted string.
NOTE: value will only be quoted if it contains non-alphanumeric characters.
public abstract boolean equalsIgnoreAlias(FieldExpression other)
true
if other
is the same as this
, with the exception of alias.protected static boolean equalsIgnoreAlias(FieldExpression a, FieldExpression b)
a.equalsIgnoreAlias(b)
public FieldExpression clone()
protected static boolean isConstant(FieldExpression value)
protected static FieldExpression handleFieldExpression(FieldExpressionHandler handler, FieldExpression input)
protected static void rewrite(QueryHandler handler, boolean recursive, FieldExpression input)
public static final FieldExpression[] copyOf(FieldExpression[] args, int length)
args
.Copyright © 2018 Attivio, Inc. All Rights Reserved.
PATENT NOTICE: Attivio, Inc. Software Related Patents. With respect to the Attivio software product(s) being used, the following patents apply: Querying Joined Data Within A Search Engine Index: United States Patent No.(s): 8,073,840. Ordered Processing of Groups of Messages: U.S. Patent No.(s) 8,495,656. Signal processing approach to sentiment analysis for entities in documents: U.S. Patent No.(s) 8,725,494. Other U.S. and International Patents Pending.