use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.
the class QueryImpl method toString.
@Override
public String toString() {
StringBuilder buff = new StringBuilder();
buff.append("select ");
int i = 0;
for (ColumnImpl c : columns) {
if (i++ > 0) {
buff.append(", ");
}
buff.append(c);
}
buff.append(" from ").append(source);
if (constraint != null) {
buff.append(" where ").append(constraint);
}
if (orderings != null) {
buff.append(" order by ");
i = 0;
for (OrderingImpl o : orderings) {
if (i++ > 0) {
buff.append(", ");
}
buff.append(o);
}
}
return buff.toString();
}
use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.
the class QueryImpl method currentRow.
ResultRowImpl currentRow() {
int selectorCount = selectors.size();
Tree[] trees = new Tree[selectorCount];
for (int i = 0; i < selectorCount; i++) {
SelectorImpl s = selectors.get(i);
trees[i] = s.currentTree();
}
int columnCount = columns.length;
PropertyValue[] values = new PropertyValue[columnCount];
for (int i = 0; i < columnCount; i++) {
ColumnImpl c = columns[i];
values[i] = c.currentProperty();
}
PropertyValue[] orderValues;
if (orderings == null) {
orderValues = null;
} else {
int size = orderings.length;
orderValues = new PropertyValue[size];
for (int i = 0; i < size; i++) {
orderValues[i] = orderings[i].getOperand().currentProperty();
}
}
return new ResultRowImpl(this, trees, values, distinctColumns, orderValues);
}
use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.
the class QueryImpl method getColumnIndex.
static int getColumnIndex(ColumnImpl[] columns, String columnName) {
for (int i = 0, size = columns.length; i < size; i++) {
ColumnImpl c = columns[i];
String cn = c.getColumnName();
if (cn != null && cn.equals(columnName)) {
return i;
}
}
return -1;
}
use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.
the class ResultRowImpl method toString.
@Override
public String toString() {
StringBuilder buff = new StringBuilder();
for (String s : query.getSelectorNames()) {
String p = getPath(s);
if (p != null) {
buff.append(s).append(": ").append(p).append(" ");
}
}
ColumnImpl[] cols = query.getColumns();
for (int i = 0; i < values.length; i++) {
ColumnImpl c = cols[i];
String n = c.getColumnName();
if (n != null) {
buff.append(n).append(": ").append(values[i]).append(" ");
}
}
return buff.toString();
}
use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.
the class SQL2Parser method parseSelect.
private QueryImpl parseSelect() throws ParseException {
read("SELECT");
boolean distinct = readIf("DISTINCT");
ArrayList<ColumnOrWildcard> list = parseColumns();
if (supportSQL1) {
addColumnIfNecessary(list, QueryImpl.JCR_PATH, QueryImpl.JCR_PATH);
addColumnIfNecessary(list, QueryImpl.JCR_SCORE, QueryImpl.JCR_SCORE);
}
read("FROM");
SourceImpl source = parseSource();
ColumnImpl[] columnArray = resolveColumns(list);
ConstraintImpl constraint = null;
if (readIf("WHERE")) {
constraint = parseConstraint();
}
QueryImpl q = new QueryImpl(statement, source, constraint, columnArray, namePathMapper, settings);
q.setDistinct(distinct);
return q;
}
Aggregations