本文整理汇总了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());
}
示例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;
}
示例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());
}
}
示例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;
}
}