com.orientechnologies.orient.core.sql.parser.ONestedProjectionItem Maven / Gradle / Ivy
/* Generated By:JJTree: Do not edit this line. OExpansionItem.java Version 4.3 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultInternal;
import java.util.Map;
public class ONestedProjectionItem extends SimpleNode {
protected boolean exclude = false;
protected boolean star = false;
protected OExpression expression;
protected boolean rightWildcard = false;
protected ONestedProjection expansion;
protected OIdentifier alias;
public ONestedProjectionItem(int id) {
super(id);
}
public ONestedProjectionItem(OrientSql p, int id) {
super(p, id);
}
@Override
public ONestedProjectionItem copy() {
ONestedProjectionItem result = new ONestedProjectionItem(-1);
result.exclude = exclude;
result.star = star;
result.expression = expression == null ? null : expression.copy();
result.rightWildcard = rightWildcard;
result.expansion = expansion == null ? null : expansion.copy();
result.alias = alias == null ? null : alias.copy();
return result;
}
/**
* given a property name, calculates if this property name matches this nested projection item,
* eg.
*
*
* - this is a *, so it matches any property name
*
- the field name for this projection item is the same as the input property name
*
- this item has a wildcard and the partial field is a prefix of the input property name
*
*
* @param propertyName
* @return
*/
public boolean matches(String propertyName) {
if (star) {
return true;
}
if (expression != null) {
String fieldString = expression.getDefaultAlias().getStringValue();
if (fieldString.equals(propertyName)) {
return true;
}
if (rightWildcard && propertyName.startsWith(fieldString)) {
return true;
}
}
return false;
}
@Override
public void toString(Map