@Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { boolean b = _value.evaluate(context) == QueryService.UNDEFINED; return Boolean.valueOf(_is_defined ? !b : b); }
Object evaluateIndexKey(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { if (((AbstractIndex) _index).isMapType()) { // assert _path.getType() == OQLLexerTokenTypes.METHOD_INV; // Get the map key & value. both need to be passed as index key. CompiledValue mapKey = ((MapIndexable) this._path).getMapLookupKey(); return new Object[] {this._key.evaluate(context), mapKey.evaluate(context)}; } else { return _key.evaluate(context); } }
@Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { return negateObject(_value.evaluate(context)); }
@Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { Object evaluatedPath = this.indxInfo._path.evaluate(context); return evaluate(context, evaluatedPath); }
@Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { return minus(_value.evaluate(context)); }
@Override public Object evaluate(ExecutionContext context) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException { Object evaluatedPath = this.indxInfo._path.evaluate(context); Boolean result = (Boolean) super.evaluate(context, evaluatedPath); if (result.booleanValue()) { result = (Boolean) TypeUtils.compare(evaluatedPath, this.condnKey, this.condnOp); } return result; }
@Test public void testEvaluatesFalseWhenIntegerNotInCollection() throws Exception { Collection collection = new ArrayList(); collection.add(1); collection.add(2); when(elm.evaluate(isA(ExecutionContext.class))).thenReturn(3); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(collection); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertFalse((Boolean) result); }
@Test public void testEvaluatesTrueWhenIntegerInIntegerCollection() throws Exception { Collection collection = new ArrayList(); collection.add(1); collection.add(2); when(elm.evaluate(isA(ExecutionContext.class))).thenReturn(1); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(collection); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testEvaluatesTrueWithLongArrayMatchingAndIntegerElement() throws Exception { long[] longValues = new long[] {1, 2, 3}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn(new Integer(1)); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(longValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testEvaluatesTrueForFloatAgainstShortArray() throws Exception { short[] shortValues = new short[] {1, 1}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn(new Float(1.0)); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(shortValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testEvaluatesTrueForIntegerAgainstShortArray() throws Exception { short[] shortValues = new short[] {1, 2}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn(new Integer(1)); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(shortValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testEvaluatesTrueWithByteArrayMatchingByteElement() throws Exception { byte[] byteValues = new byte[] {1, 2, 3}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn((Byte.valueOf("1"))); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(byteValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testEvaluatesTrueForShortAgainstShortArray() throws Exception { short[] shortValues = new short[] {1, 2}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn(1); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(shortValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testEvaluatesTrueWithBooleanArrayMatchingBooleanFalseElement() throws Exception { boolean[] booleanValues = new boolean[] {false, false}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn(false); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(booleanValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testEvaluatesTrueWithSecondElementOfLongArrayMatchingLongElement() throws Exception { long[] longValues = new long[] {1, 2, 3}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn(2L); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(longValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testEvaluatesTrueWithLongArrayMatchingAndDoubleElement() throws Exception { long[] longValues = new long[] {1, 2, 3}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn(1D); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(longValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testEvaluatesFalseForStringAgainstShortArray() throws Exception { short[] shortValues = new short[] {1, 1}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn("1"); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(shortValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertFalse((Boolean) result); }
@Test public void testEvaluatesTrueWithCharArrayMatchingCharElement() throws Exception { char[] charValues = new char[] {'a', 'b', '1'}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn('a'); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(charValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertTrue((Boolean) result); }
@Test public void testStringDoesNotMatchCharElements() throws Exception { char[] charValues = new char[] {'a', 'b', '1'}; when(elm.evaluate(isA(ExecutionContext.class))).thenReturn("a"); when(colln.evaluate(isA(ExecutionContext.class))).thenReturn(charValues); CompiledIn compiledIn = new CompiledIn(elm, colln); Object result = compiledIn.evaluate(context); assertFalse((Boolean) result); }
private void createDerivedJoinResultsFromCC(String theCallingIndexReceiverId, CompiledComparison cc, ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { if (isCompiledPath(cc._right) && matchingPathIds(theCallingIndexReceiverId, cc._left)) { evaluateDerivedJoin(context, cc._right, new CompiledLiteral(cc._left.evaluate(context)), cc.getOperator()); } else if (isCompiledPath(cc._left) && matchingPathIds(theCallingIndexReceiverId, cc._right)) { evaluateDerivedJoin(context, cc._left, new CompiledLiteral(cc._right.evaluate(context)), cc.getOperator()); } }