/** * Set the implicit type of the given value to the given class. */ protected static void setImplicitType(Value val, Class<?> expected) { // we never expect a pc type, so no need to worry about metadata if (val.getType() == TYPE_OBJECT) val.setImplicitType(expected); }
/** * Set the implicit type of the given value to the given class. */ protected static void setImplicitType(Value val, Class<?> expected) { // we never expect a pc type, so no need to worry about metadata if (val.getType() == TYPE_OBJECT) val.setImplicitType(expected); }
/** * Set the implicit type of the given value to the given class. */ protected static void setImplicitType(Value val, Class expected) { // we never expect a pc type, so no need to worry about metadata if (val.getType() == TYPE_OBJECT) val.setImplicitType(expected); }
public Class getType() { if (_exps != null && _type == null) { if (_exps.projections.length == 0) return _candidate.getDescribedType(); if (_exps.projections.length == 1) return _exps.projections[0].getType(); } return _type; }
public Class getType() { if (_exps != null && _type == null) { if (_exps.projections.length == 0) return _candidate.getDescribedType(); if (_exps.projections.length == 1) return _exps.projections[0].getType(); } return _type; }
/** * Set the implicit type of the given value to the given class. */ protected static void setImplicitType(Value val, Class<?> expected) { // we never expect a pc type, so no need to worry about metadata if (val.getType() == TYPE_OBJECT) val.setImplicitType(expected); }
/** * Set the implicit type of the given value to the given class. */ protected static void setImplicitType(Value val, Class<?> expected) { // we never expect a pc type, so no need to worry about metadata if (val.getType() == TYPE_OBJECT) val.setImplicitType(expected); }
public Class getType() { if (_exps != null && _type == null) { if (_exps.projections.length == 0) return _candidate.getDescribedType(); if (_exps.projections.length == 1) return _exps.projections[0].getType(); } return _type; }
public Class getType() { if (_exps != null) { if (_exps.projections.length == 0) return _candidate.getDescribedType(); if (_exps.projections.length == 1) return _exps.projections[0].getType(); } return _type; }
public Class getType() { if (_exps != null && _type == null) { if (_exps.projections.length == 0) return _candidate.getDescribedType(); if (_exps.projections.length == 1) return _exps.projections[0].getType(); } return _type; }
/** * Throw proper exception if given value is a collection/map/array. */ protected void assertNotContainer(Value val, StoreQuery q) { // variables represent container elements, not the container itself if (val.isVariable()) return; Class<?> type; if (val instanceof Path) { FieldMetaData fmd = ((Path) val).last(); type = (fmd == null) ? val.getType() : fmd.getDeclaredType(); } else type = val.getType(); switch (JavaTypes.getTypeCode(type)) { case JavaTypes.ARRAY: case JavaTypes.COLLECTION: case JavaTypes.MAP: throw new UserException(_loc.get("container-projection", q.getContext().getQueryString())); } }
/** * Throw proper exception if given value is a collection/map/array. */ protected void assertNotContainer(Value val, StoreQuery q) { // variables represent container elements, not the container itself if (val.isVariable()) return; Class type; if (val instanceof Path) { FieldMetaData fmd = ((Path) val).last(); type = (fmd == null) ? val.getType() : fmd.getDeclaredType(); } else type = val.getType(); switch (JavaTypes.getTypeCode(type)) { case JavaTypes.ARRAY: case JavaTypes.COLLECTION: case JavaTypes.MAP: throw new UserException(_loc.get("container-projection", q.getContext().getQueryString())); } }
/** * Throw proper exception if given value is a collection/map/array. */ protected void assertNotContainer(Value val, StoreQuery q) { // variables represent container elements, not the container itself if (val.isVariable()) return; Class<?> type; if (val instanceof Path) { FieldMetaData fmd = ((Path) val).last(); type = (fmd == null) ? val.getType() : fmd.getDeclaredType(); } else type = val.getType(); switch (JavaTypes.getTypeCode(type)) { case JavaTypes.ARRAY: case JavaTypes.COLLECTION: case JavaTypes.MAP: throw new UserException(_loc.get("container-projection", q.getContext().getQueryString())); } }
/** * Throw proper exception if given value is a collection/map/array. */ protected void assertNotContainer(Value val, StoreQuery q) { // variables represent container elements, not the container itself if (val.isVariable()) return; Class<?> type; if (val instanceof Path) { FieldMetaData fmd = ((Path) val).last(); type = (fmd == null) ? val.getType() : fmd.getDeclaredType(); } else type = val.getType(); switch (JavaTypes.getTypeCode(type)) { case JavaTypes.ARRAY: case JavaTypes.COLLECTION: case JavaTypes.MAP: throw new UserException(_loc.get("container-projection", q.getContext().getQueryString())); } }
/** * Throw proper exception if given value is a collection/map/array. */ protected void assertNotContainer(Value val, StoreQuery q) { // variables represent container elements, not the container itself if (val.isVariable()) return; Class<?> type; if (val instanceof Path) { FieldMetaData fmd = ((Path) val).last(); type = (fmd == null) ? val.getType() : fmd.getDeclaredType(); } else type = val.getType(); switch (JavaTypes.getTypeCode(type)) { case JavaTypes.ARRAY: case JavaTypes.COLLECTION: case JavaTypes.MAP: throw new UserException(_loc.get("container-projection", q.getContext().getQueryString())); } }
protected static void setImplicitTypes(Value val1, Value val2, Class<?> expected, Resolver resolver) { Class<?> c1 = val1.getType(); Class<?> c2 = val2.getType(); boolean o1 = c1 == TYPE_OBJECT; boolean o2 = c2 == TYPE_OBJECT; if (o1 && !o2) { val1.setImplicitType(c2); if (val1.getMetaData() == null && !val1.isXPath()) val1.setMetaData(val2.getMetaData()); } else if (!o1 && o2) { val2.setImplicitType(c1); if (val2.getMetaData() == null && !val1.isXPath()) val2.setMetaData(val1.getMetaData()); } else if (o1 && o2 && expected != null) { // we never expect a pc type, so don't bother with metadata val1.setImplicitType(expected); val2.setImplicitType(expected); } else if (isNumeric(val1.getType()) != isNumeric(val2.getType())) { if (resolver.getConfiguration().getCompatibilityInstance(). getQuotedNumbersInQueries()) convertTypesQuotedNumbers(val1, val2); else convertTypes(val1, val2); } // convertLiteralToAvoidCast(val1, val2); }
protected static void setImplicitTypes(Value val1, Value val2, Class<?> expected, Resolver resolver) { Class<?> c1 = val1.getType(); Class<?> c2 = val2.getType(); boolean o1 = c1 == TYPE_OBJECT; boolean o2 = c2 == TYPE_OBJECT; if (o1 && !o2) { val1.setImplicitType(c2); if (val1.getMetaData() == null && !val1.isXPath()) val1.setMetaData(val2.getMetaData()); } else if (!o1 && o2) { val2.setImplicitType(c1); if (val2.getMetaData() == null && !val1.isXPath()) val2.setMetaData(val1.getMetaData()); } else if (o1 && o2 && expected != null) { // we never expect a pc type, so don't bother with metadata val1.setImplicitType(expected); val2.setImplicitType(expected); } else if (isNumeric(val1.getType()) != isNumeric(val2.getType())) { if (resolver.getConfiguration().getCompatibilityInstance(). getQuotedNumbersInQueries()) convertTypesQuotedNumbers(val1, val2); else convertTypes(val1, val2); } // convertLiteralToAvoidCast(val1, val2); }
public DataStoreExecutor(ExpressionStoreQuery q, ClassMetaData meta, boolean subclasses, ExpressionParser parser, Object parsed) { _metas = q.getIndependentExpressionCandidates(meta, subclasses); if (_metas.length == 0) throw new UserException(_loc.get("query-unmapped", meta)); _meta = meta; _subs = subclasses; _parser = parser; _facts = new ExpressionFactory[_metas.length]; for (int i = 0; i < _facts.length; i++) _facts[i] = q.getExpressionFactory(_metas[i]); _exps = new QueryExpressions[_metas.length]; for (int i = 0; i < _exps.length; i++) _exps[i] = parser.eval(parsed, q, _facts[i], _metas[i]); if (_exps[0].projections.length == 0) _projTypes = StoreQuery.EMPTY_CLASSES; else { _projTypes = new Class[_exps[0].projections.length]; for (int i = 0; i < _exps[0].projections.length; i++) { assertNotContainer(_exps[0].projections[i], q); _projTypes[i] = _exps[0].projections[i].getType(); } } }
public InMemoryExecutor(ExpressionStoreQuery q, ClassMetaData candidate, boolean subclasses, ExpressionParser parser, Object parsed, InMemoryExpressionFactory factory) { _meta = candidate; _subs = subclasses; _factory = factory; _exps = new QueryExpressions[] { parser.eval(parsed, q, _factory, _meta) }; if (_exps[0].projections.length == 0) _projTypes = StoreQuery.EMPTY_CLASSES; else { AssertNoVariablesExpressionVisitor novars = new AssertNoVariablesExpressionVisitor(q.getContext()); _projTypes = new Class[_exps[0].projections.length]; for (int i = 0; i < _exps[0].projections.length; i++) { _projTypes[i] = _exps[0].projections[i].getType(); assertNotContainer(_exps[0].projections[i], q); _exps[0].projections[i].acceptVisit(novars); } for (int i = 0; i < _exps[0].grouping.length; i++) _exps[0].grouping[i].acceptVisit(novars); } }
public InMemoryExecutor(ExpressionStoreQuery q, ClassMetaData candidate, boolean subclasses, ExpressionParser parser, Object parsed, InMemoryExpressionFactory factory) { _meta = candidate; _subs = subclasses; _factory = factory; _exps = new QueryExpressions[] { parser.eval(parsed, q, _factory, _meta) }; if (_exps[0].projections.length == 0) _projTypes = StoreQuery.EMPTY_CLASSES; else { AssertNoVariablesExpressionVisitor novars = new AssertNoVariablesExpressionVisitor(q.getContext()); _projTypes = new Class[_exps[0].projections.length]; for (int i = 0; i < _exps[0].projections.length; i++) { _projTypes[i] = _exps[0].projections[i].getType(); assertNotContainer(_exps[0].projections[i], q); _exps[0].projections[i].acceptVisit(novars); } for (int i = 0; i < _exps[0].grouping.length; i++) _exps[0].grouping[i].acceptVisit(novars); } }