当前位置: 首页>>代码示例>>Java>>正文


Java ValueComparisonExpression类代码示例

本文整理汇总了Java中com.redhat.lightblue.query.ValueComparisonExpression的典型用法代码示例。如果您正苦于以下问题:Java ValueComparisonExpression类的具体用法?Java ValueComparisonExpression怎么用?Java ValueComparisonExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ValueComparisonExpression类属于com.redhat.lightblue.query包,在下文中一共展示了ValueComparisonExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: translateValueComparisonExpression

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
private DBObject translateValueComparisonExpression(FieldTreeNode context, EntityMetadata md, ValueComparisonExpression expr,MutablePath fullPath) {
    FieldInfo finfo=resolveFieldForQuery(context,fullPath.immutableCopy(),expr.getField());       
    Type t = finfo.fieldMd.getType();

    Object value = expr.getRvalue().getValue();
    if (expr.getOp() == BinaryComparisonOperator._eq
            || expr.getOp() == BinaryComparisonOperator._neq) {
        if (!t.supportsEq() && value != null) {
            throw Error.get(ERR_INVALID_COMPARISON, expr.toString());
        }
    } else if (!t.supportsOrdering()) {
        throw Error.get(ERR_INVALID_COMPARISON, expr.toString());
    }
    Object valueObject = DocTranslator.filterBigNumbers(t.cast(value));
    if (finfo.field.equals(ID_PATH)) {
        valueObject = DocTranslator.createIdFrom(valueObject);
    }
    if (expr.getOp() == BinaryComparisonOperator._eq) {
        return new BasicDBObject(translatePath(finfo.field), valueObject);
    } else {
        return new BasicDBObject(translatePath(finfo.field),
                new BasicDBObject(BINARY_COMPARISON_OPERATOR_MAP.get(expr.getOp()), valueObject));
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:25,代码来源:ExpressionTranslator.java

示例2: itrValueComparisonExpression

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Override
protected Filter itrValueComparisonExpression(ValueComparisonExpression query, Path path){
    String attributeName = fieldNameTranslator.translateFieldName(query.getField());
    String rValue = query.getRvalue().getValue().toString();

    switch(query.getOp()){
        case _eq:
            return Filter.createEqualityFilter(attributeName, rValue);
        case _neq:
            return Filter.createNOTFilter(Filter.createEqualityFilter(attributeName, rValue));
        case _gte:
            return Filter.createGreaterOrEqualFilter(attributeName, rValue);
        case _lte:
            return Filter.createLessOrEqualFilter(attributeName, rValue);
        case _gt: //aka. !lte
            return Filter.createNOTFilter(Filter.createLessOrEqualFilter(attributeName, rValue));
        case _lt: //aka. !gte
            return Filter.createNOTFilter(Filter.createGreaterOrEqualFilter(attributeName, rValue));
        default:
            throw new UnsupportedOperationException("Unsupported operation: " + query.getOp());
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:23,代码来源:FilterBuilder.java

示例3: rewrite

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Override
public QueryExpression rewrite(QueryExpression q) {
    UnaryLogicalExpression le = dyncast(UnaryLogicalExpression.class, q);
    if (le != null && le.getOp() == UnaryLogicalOperator._not) {
        ValueComparisonExpression vce = dyncast(ValueComparisonExpression.class, le.getQuery());
        if (vce != null) {
            return new ValueComparisonExpression(vce.getField(), vce.getOp().negate(), vce.getRvalue());
        } else {
            FieldComparisonExpression fce = dyncast(FieldComparisonExpression.class, le.getQuery());
            if (fce != null) {
                return new FieldComparisonExpression(fce.getField(), fce.getOp().negate(), fce.getRfield());
            } else {
                NaryValueRelationalExpression nre = dyncast(NaryValueRelationalExpression.class, le.getQuery());
                if (nre != null) {
                    return new NaryValueRelationalExpression(nre.getField(), nre.getOp().negate(), nre.getValues());
                } else {
                    NaryFieldRelationalExpression nfe = dyncast(NaryFieldRelationalExpression.class, le.getQuery());
                    if (nfe != null) {
                        return new NaryFieldRelationalExpression(nfe.getField(), nfe.getOp().negate(), nfe.getRfield());
                    }
                }
            }
        }
    }
    return q;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:27,代码来源:EliminateNOT.java

示例4: getInstance

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
public static QueryEvaluator getInstance(QueryExpression expr,
                                         FieldTreeNode context) {
    QueryEvaluator ret = null;
    if (expr instanceof ValueComparisonExpression) {
        return new ValueComparisonEvaluator((ValueComparisonExpression) expr, context);
    } else if (expr instanceof FieldComparisonExpression) {
        return new FieldComparisonEvaluator((FieldComparisonExpression) expr, context);
    } else if (expr instanceof RegexMatchExpression) {
        return new RegexEvaluator((RegexMatchExpression) expr, context);
    } else if (expr instanceof NaryValueRelationalExpression) {
        return new NaryValueRelationalExpressionEvaluator((NaryValueRelationalExpression) expr, context);
    } else if (expr instanceof NaryFieldRelationalExpression) {
        return new NaryFieldRelationalExpressionEvaluator((NaryFieldRelationalExpression) expr, context);
    } else if (expr instanceof UnaryLogicalExpression) {
        return new UnaryLogicalExpressionEvaluator((UnaryLogicalExpression) expr, context);
    } else if (expr instanceof NaryLogicalExpression) {
        return new NaryLogicalExpressionEvaluator((NaryLogicalExpression) expr, context);
    } else if (expr instanceof ArrayContainsExpression) {
        return new ArrayContainsEvaluator((ArrayContainsExpression) expr, context);
    } else if (expr instanceof ArrayMatchExpression) {
        return new ArrayMatchEvaluator((ArrayMatchExpression) expr, context);
    }
    return ret;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:25,代码来源:QueryEvaluator.java

示例5: equals

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
private boolean equals(QueryExpression q, QueryExpression w) {
    if (q.getClass().equals(w.getClass())) {
        if (q instanceof ValueComparisonExpression) {
            return equals((ValueComparisonExpression) q, (ValueComparisonExpression) w);
        } else if (q instanceof FieldComparisonExpression) {
            return equals((FieldComparisonExpression) q, (FieldComparisonExpression) w);
        } else if (q instanceof RegexMatchExpression) {
            return equals((RegexMatchExpression) q, (RegexMatchExpression) w);
        } else if (q instanceof NaryValueRelationalExpression) {
            return equals((NaryValueRelationalExpression) q, (NaryValueRelationalExpression) w);
        } else if (q instanceof UnaryLogicalExpression) {
            return equals((UnaryLogicalExpression) q, (UnaryLogicalExpression) w);
        } else if (q instanceof NaryLogicalExpression) {
            return equals((NaryLogicalExpression) q, (NaryLogicalExpression) w);
        } else if (q instanceof ArrayContainsExpression) {
            return equals((ArrayContainsExpression) q, (ArrayContainsExpression) w);
        } else if (q instanceof ArrayMatchExpression) {
            return equals((ArrayMatchExpression) q, (ArrayMatchExpression) w);
        }
    }
    return false;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:23,代码来源:QueryRewriterTest.java

示例6: updateQueryFieldRoleTest

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Test
public void updateQueryFieldRoleTest() throws Exception {
    UpdateRequest req = new UpdateRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setReturnFields(null);
    req.setQuery(new ValueComparisonExpression(new Path("field1"), BinaryComparisonOperator._eq, new Value("x")));
    req.setClientId(new RestClientIdentification(Arrays.asList("test-update")));

    mockCrudController.updateResponse = new CRUDUpdateResponse();
    Response response = mediator.update(req);
    Assert.assertEquals(OperationStatus.ERROR, response.getStatus());

    req.setQuery(new ValueComparisonExpression(new Path("field2"), BinaryComparisonOperator._eq, new Value("x")));
    response = mediator.update(req);
    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:17,代码来源:MediatorTest.java

示例7: findQueryFieldRoleTest

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Test
public void findQueryFieldRoleTest() throws Exception {
    FindRequest req = new FindRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setQuery(new ValueComparisonExpression(new Path("field1"), BinaryComparisonOperator._eq, new Value("x")));
    req.setClientId(new RestClientIdentification(Arrays.asList("test-find")));

    mockCrudController.findResponse = new CRUDFindResponse();
    mockCrudController.findCb=ctx->ctx.setDocumentStream(new ListDocumentStream<DocCtx>(new ArrayList<DocCtx>()));
    Response response = mediator.find(req);
    Assert.assertEquals(OperationStatus.ERROR, response.getStatus());

    req.setQuery(new ValueComparisonExpression(new Path("field2"), BinaryComparisonOperator._eq, new Value("x")));
    response = mediator.find(req);
    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:17,代码来源:MediatorTest.java

示例8: appendObjectType

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
/**
 * Appends objectType:X to the query
 */
public static QueryExpression appendObjectType(QueryExpression q,String entityName) {
    QueryExpression ot=new ValueComparisonExpression(DocTranslator.OBJECT_TYPE,BinaryComparisonOperator._eq,new Value(entityName));
    if(q==null) {
        return ot;
    } if(q instanceof NaryLogicalExpression &&
         ((NaryLogicalExpression)q).getOp()==NaryLogicalOperator._and) {
        List<QueryExpression> l=new ArrayList<>(((NaryLogicalExpression)q).getQueries());
        l.add(ot);
        return new NaryLogicalExpression(NaryLogicalOperator._and,l);
    } else {
        return new NaryLogicalExpression(NaryLogicalOperator._and,q,ot);
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:17,代码来源:ExpressionTranslator.java

示例9: translate

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
/**
 * @param context The field tree node for the latest enclosing context (array of elemMatch, or top level node)
 * @param query The query to translate
 * @param emd The metadata
 * @param fullPath Current full path
 */
private DBObject translate(FieldTreeNode context, QueryExpression query, EntityMetadata emd, MutablePath fullPath) {
    DBObject ret;
    try {
        if (query instanceof ArrayContainsExpression) {
            ret = translateArrayContains(context, emd, (ArrayContainsExpression) query,fullPath);
        } else if (query instanceof ArrayMatchExpression) {
            ret = translateArrayElemMatch(context, emd, (ArrayMatchExpression) query, emd, fullPath);
        } else if (query instanceof FieldComparisonExpression) {
            ret = translateFieldComparison(context, emd, (FieldComparisonExpression) query, fullPath);
        } else if (query instanceof NaryLogicalExpression) {
            ret = translateNaryLogicalExpression(context, emd, (NaryLogicalExpression) query, emd, fullPath);
        } else if (query instanceof NaryValueRelationalExpression) {
            ret = translateNaryValueRelationalExpression(context, emd, (NaryValueRelationalExpression) query,fullPath);
        } else if (query instanceof NaryFieldRelationalExpression) {
            ret = translateNaryFieldRelationalExpression(context, emd, (NaryFieldRelationalExpression) query,fullPath);
        } else if (query instanceof RegexMatchExpression) {
            ret = translateRegexMatchExpression(context, emd, (RegexMatchExpression) query, emd, fullPath);
        } else if (query instanceof UnaryLogicalExpression) {
            ret = translateUnaryLogicalExpression(context, emd, (UnaryLogicalExpression) query, emd, fullPath);
        } else {
            ret = translateValueComparisonExpression(context, emd, (ValueComparisonExpression) query,fullPath);
        }
    } catch (NeedsJS x) {
        // We can't translate the query, we have to write a $where query
        // But we can't do that if we're in an arrayElemMatch
        if(fullPath.isEmpty()) {
            JSQueryTranslator tx=new JSQueryTranslator(emd);
            ret=new BasicDBObject("$where",tx.translateQuery(query).toString());
        } else
            throw x; // Continue unroll stack
    }
    return ret;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:40,代码来源:ExpressionTranslator.java

示例10: testbuild_ValueComparisonExpression_Equals

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Test
public void testbuild_ValueComparisonExpression_Equals(){
    QueryExpression query = new ValueComparisonExpression(
            new Path("somekey"), BinaryComparisonOperator._eq, new Value("somevalue"));

    Filter filter = new FilterBuilder(new TrivialLdapFieldNameTranslator()).build(query);
    assertEquals("(somekey=somevalue)", filter.toString());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:9,代码来源:FilterBuilderTest.java

示例11: testbuild_ValueComparisonExpression_NotEquals

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Test
public void testbuild_ValueComparisonExpression_NotEquals(){
    QueryExpression query = new ValueComparisonExpression(
            new Path("somekey"), BinaryComparisonOperator._neq, new Value("somevalue"));

    Filter filter = new FilterBuilder(new TrivialLdapFieldNameTranslator()).build(query);
    assertEquals("(!(somekey=somevalue))", filter.toString());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:9,代码来源:FilterBuilderTest.java

示例12: testbuild_ValueComparisonExpression_GTE

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Test
public void testbuild_ValueComparisonExpression_GTE(){
    QueryExpression query = new ValueComparisonExpression(
            new Path("somekey"), BinaryComparisonOperator._gte, new Value("somevalue"));

    Filter filter = new FilterBuilder(new TrivialLdapFieldNameTranslator()).build(query);
    assertEquals("(somekey>=somevalue)", filter.toString());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:9,代码来源:FilterBuilderTest.java

示例13: testbuild_ValueComparisonExpression_GT

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Test
public void testbuild_ValueComparisonExpression_GT(){
    QueryExpression query = new ValueComparisonExpression(
            new Path("somekey"), BinaryComparisonOperator._gt, new Value("somevalue"));

    Filter filter = new FilterBuilder(new TrivialLdapFieldNameTranslator()).build(query);
    assertEquals("(!(somekey<=somevalue))", filter.toString());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:9,代码来源:FilterBuilderTest.java

示例14: testbuild_ValueComparisonExpression_LTE

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Test
public void testbuild_ValueComparisonExpression_LTE(){
    QueryExpression query = new ValueComparisonExpression(
            new Path("somekey"), BinaryComparisonOperator._lte, new Value("somevalue"));

    Filter filter = new FilterBuilder(new TrivialLdapFieldNameTranslator()).build(query);
    assertEquals("(somekey<=somevalue)", filter.toString());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:9,代码来源:FilterBuilderTest.java

示例15: testbuild_ValueComparisonExpression_LT

import com.redhat.lightblue.query.ValueComparisonExpression; //导入依赖的package包/类
@Test
public void testbuild_ValueComparisonExpression_LT(){
    QueryExpression query = new ValueComparisonExpression(
            new Path("somekey"), BinaryComparisonOperator._lt, new Value("somevalue"));

    Filter filter = new FilterBuilder(new TrivialLdapFieldNameTranslator()).build(query);
    assertEquals("(!(somekey>=somevalue))", filter.toString());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:9,代码来源:FilterBuilderTest.java


注:本文中的com.redhat.lightblue.query.ValueComparisonExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。