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


Java CompositeSortKey类代码示例

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


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

示例1: testCompositeSortKey

import com.redhat.lightblue.query.CompositeSortKey; //导入依赖的package包/类
@Test
public void testCompositeSortKey(){
    String fieldName1 = "fakeField1";
    String fieldName2 = "fakeField2";

    Sort sort = new CompositeSortKey(
            Arrays.asList(
                    new SortKey(new Path(fieldName1), true),
                    new SortKey(new Path(fieldName2), false))
            );

    com.unboundid.ldap.sdk.controls.SortKey[] translatedSorts = new SortTranslator(new TrivialLdapFieldNameTranslator()).translate(sort);

    assertNotNull(translatedSorts);
    assertEquals(2, translatedSorts.length);

    com.unboundid.ldap.sdk.controls.SortKey translatedSort1 = translatedSorts[0];
    assertNotNull(translatedSort1);
    assertEquals(fieldName1, translatedSort1.getAttributeName());
    assertTrue(translatedSort1.reverseOrder());

    com.unboundid.ldap.sdk.controls.SortKey translatedSort2 = translatedSorts[1];
    assertNotNull(translatedSort2);
    assertEquals(fieldName2, translatedSort2.getAttributeName());
    assertFalse(translatedSort2.reverseOrder());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:27,代码来源:SortTranslatorTest.java

示例2: translateCompositeSortKey

import com.redhat.lightblue.query.CompositeSortKey; //导入依赖的package包/类
private DBObject translateCompositeSortKey(CompositeSortKey sort) {
    DBObject ret = null;
    for (SortKey key : sort.getKeys()) {
        if (ret == null) {
            ret = translateSortKey(key);
        } else {
            ret.put(translatePath(key.getField()), key.isDesc() ? -1 : 1);
        }
    }
    return ret;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:12,代码来源:ExpressionTranslator.java

示例3: doTranslate

import com.redhat.lightblue.query.CompositeSortKey; //导入依赖的package包/类
private void doTranslate(Sort sort, List<com.unboundid.ldap.sdk.controls.SortKey> results){
    if(sort instanceof CompositeSortKey){
        CompositeSortKey comoposite = (CompositeSortKey) sort;
        for(Sort subSort : comoposite.getKeys()){
            doTranslate(subSort, results);
        }
    }
    else if(sort instanceof SortKey){
        SortKey key = (SortKey) sort;
        results.add(new com.unboundid.ldap.sdk.controls.SortKey(fieldNameTranslator.translateFieldName(key.getField()), key.isDesc()));
    }
    else{
        throw new IllegalArgumentException("Unsupported Sort type: " + sort.getClass().getName());
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:16,代码来源:SortTranslator.java

示例4: buildSortFields

import com.redhat.lightblue.query.CompositeSortKey; //导入依赖的package包/类
/**
 * Build sort field info starting from the given metadata context
 */
public static SortFieldInfo[] buildSortFields(Sort sort, FieldTreeNode context) {
    if (sort instanceof SortKey) {
        return new SortFieldInfo[]{getSortField(((SortKey) sort).getField(), context, ((SortKey) sort).isDesc())};
    } else {
        List<SortKey> keys = ((CompositeSortKey) sort).getKeys();
        SortFieldInfo[] arr = new SortFieldInfo[keys.size()];
        int i = 0;
        for (SortKey key : keys) {
            arr[i++] = getSortField(key.getField(), context, key.isDesc());
        }
        return arr;
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:17,代码来源:SortFieldInfo.java


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