本文整理汇总了Java中javax.naming.ldap.SortKey类的典型用法代码示例。如果您正苦于以下问题:Java SortKey类的具体用法?Java SortKey怎么用?Java SortKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortKey类属于javax.naming.ldap包,在下文中一共展示了SortKey类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRequestControls
import javax.naming.ldap.SortKey; //导入依赖的package包/类
/**
* Set the standard request controls
*/
private void setRequestControls(byte[] cookie) throws TranslatorException {
List<Control> ctrl = new ArrayList<Control>();
SortKey[] keys = searchDetails.getSortKeys();
try {
if (keys != null) {
ctrl.add(new SortControl(keys, Control.NONCRITICAL));
}
if (this.executionFactory.usePagination()) {
ctrl.add(new PagedResultsControl(this.executionContext.getBatchSize(), cookie, Control.CRITICAL));
}
if (!ctrl.isEmpty()) {
this.ldapCtx.setRequestControls(ctrl.toArray(new Control[ctrl.size()]));
LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Sort/pagination controls were created successfully."); //$NON-NLS-1$
}
} catch (NamingException ne) {
final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.setControlsError") + //$NON-NLS-1$
" : "+ne.getExplanation(); //$NON-NLS-1$
throw new TranslatorException(ne, msg);
} catch(IOException e) {
throw new TranslatorException(e);
}
}
示例2: testSelectFrom1
import javax.naming.ldap.SortKey; //导入依赖的package包/类
/**
* Test a Query without criteria
*/
@Test public void testSelectFrom1() throws Exception {
LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People"); //$NON-NLS-1$
//-----------------------------------
// Set Expected SearchDetails Values
//-----------------------------------
String expectedContextName = "ou=people,dc=metamatrix,dc=com"; //$NON-NLS-1$
String expectedContextFilter = "(objectClass=*)"; //$NON-NLS-1$
List<String> expectedAttrNameList = new ArrayList<String>();
expectedAttrNameList.add("uid"); //$NON-NLS-1$
expectedAttrNameList.add("cn"); //$NON-NLS-1$
long expectedCountLimit = -1;
int expectedSearchScope = SearchControls.ONELEVEL_SCOPE;
SortKey[] expectedSortKeys = null;
helpTestSearchDetails(searchDetails, expectedContextName, expectedContextFilter, expectedAttrNameList,
expectedCountLimit, expectedSearchScope, expectedSortKeys);
}
示例3: testSelectFromWhere1
import javax.naming.ldap.SortKey; //导入依赖的package包/类
/**
* Test a Query with a criteria
*/
@Test public void testSelectFromWhere1() throws Exception {
LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People WHERE Name = 'R%'"); //$NON-NLS-1$
//-----------------------------------
// Set Expected SearchDetails Values
//-----------------------------------
String expectedContextName = "ou=people,dc=metamatrix,dc=com"; //$NON-NLS-1$
String expectedContextFilter = "(cn=R%)"; //$NON-NLS-1$
List<String> expectedAttrNameList = new ArrayList<String>();
expectedAttrNameList.add("uid"); //$NON-NLS-1$
expectedAttrNameList.add("cn"); //$NON-NLS-1$
long expectedCountLimit = -1;
int expectedSearchScope = SearchControls.ONELEVEL_SCOPE;
SortKey[] expectedSortKeys = null;
helpTestSearchDetails(searchDetails, expectedContextName, expectedContextFilter, expectedAttrNameList,
expectedCountLimit, expectedSearchScope, expectedSortKeys);
}
示例4: testEscaping
import javax.naming.ldap.SortKey; //导入依赖的package包/类
/**
* Test a Query with a criteria
*/
@Test public void testEscaping() throws Exception {
LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People WHERE Name = 'R*'"); //$NON-NLS-1$
//-----------------------------------
// Set Expected SearchDetails Values
//-----------------------------------
String expectedContextName = "ou=people,dc=metamatrix,dc=com"; //$NON-NLS-1$
String expectedContextFilter = "(cn=R\\2a)"; //$NON-NLS-1$
List<String> expectedAttrNameList = new ArrayList<String>();
expectedAttrNameList.add("uid"); //$NON-NLS-1$
expectedAttrNameList.add("cn"); //$NON-NLS-1$
long expectedCountLimit = -1;
int expectedSearchScope = SearchControls.ONELEVEL_SCOPE;
SortKey[] expectedSortKeys = null;
helpTestSearchDetails(searchDetails, expectedContextName, expectedContextFilter, expectedAttrNameList,
expectedCountLimit, expectedSearchScope, expectedSortKeys);
}
示例5: testNot
import javax.naming.ldap.SortKey; //导入依赖的package包/类
@Test public void testNot() throws Exception {
LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People WHERE not (Name like 'R%' or Name like 'S%')"); //$NON-NLS-1$
//-----------------------------------
// Set Expected SearchDetails Values
//-----------------------------------
String expectedContextName = "ou=people,dc=metamatrix,dc=com"; //$NON-NLS-1$
String expectedContextFilter = "(&(!(cn=R*))(!(cn=S*)))"; //$NON-NLS-1$
List<String> expectedAttrNameList = new ArrayList<String>();
expectedAttrNameList.add("uid"); //$NON-NLS-1$
expectedAttrNameList.add("cn"); //$NON-NLS-1$
long expectedCountLimit = -1;
int expectedSearchScope = SearchControls.ONELEVEL_SCOPE;
SortKey[] expectedSortKeys = null;
helpTestSearchDetails(searchDetails, expectedContextName, expectedContextFilter, expectedAttrNameList,
expectedCountLimit, expectedSearchScope, expectedSortKeys);
}
示例6: testGT
import javax.naming.ldap.SortKey; //导入依赖的package包/类
@Test public void testGT() throws Exception {
LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People WHERE Name > 'R'"); //$NON-NLS-1$
//-----------------------------------
// Set Expected SearchDetails Values
//-----------------------------------
String expectedContextName = "ou=people,dc=metamatrix,dc=com"; //$NON-NLS-1$
String expectedContextFilter = "(!(cn<=R))"; //$NON-NLS-1$
List<String> expectedAttrNameList = new ArrayList<String>();
expectedAttrNameList.add("uid"); //$NON-NLS-1$
expectedAttrNameList.add("cn"); //$NON-NLS-1$
long expectedCountLimit = -1;
int expectedSearchScope = SearchControls.ONELEVEL_SCOPE;
SortKey[] expectedSortKeys = null;
helpTestSearchDetails(searchDetails, expectedContextName, expectedContextFilter, expectedAttrNameList,
expectedCountLimit, expectedSearchScope, expectedSortKeys);
}
示例7: testLT
import javax.naming.ldap.SortKey; //导入依赖的package包/类
@Test public void testLT() throws Exception {
LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People WHERE Name < 'R'"); //$NON-NLS-1$
//-----------------------------------
// Set Expected SearchDetails Values
//-----------------------------------
String expectedContextName = "ou=people,dc=metamatrix,dc=com"; //$NON-NLS-1$
String expectedContextFilter = "(!(cn>=R))"; //$NON-NLS-1$
List<String> expectedAttrNameList = new ArrayList<String>();
expectedAttrNameList.add("uid"); //$NON-NLS-1$
expectedAttrNameList.add("cn"); //$NON-NLS-1$
long expectedCountLimit = -1;
int expectedSearchScope = SearchControls.ONELEVEL_SCOPE;
SortKey[] expectedSortKeys = null;
helpTestSearchDetails(searchDetails, expectedContextName, expectedContextFilter, expectedAttrNameList,
expectedCountLimit, expectedSearchScope, expectedSortKeys);
}
示例8: helpTestLike
import javax.naming.ldap.SortKey; //导入依赖的package包/类
private void helpTestLike(String query, String expectedContextFilter)
throws TranslatorException {
LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID FROM LdapModel.People WHERE " + query); //$NON-NLS-1$
// Set Expected SearchDetails Values
//-----------------------------------
String expectedContextName = "ou=people,dc=metamatrix,dc=com"; //$NON-NLS-1$
List<String> expectedAttrNameList = new ArrayList<String>();
expectedAttrNameList.add("uid"); //$NON-NLS-1$
long expectedCountLimit = -1;
int expectedSearchScope = SearchControls.ONELEVEL_SCOPE;
SortKey[] expectedSortKeys = null;
helpTestSearchDetails(searchDetails, expectedContextName, expectedContextFilter, expectedAttrNameList,
expectedCountLimit, expectedSearchScope, expectedSortKeys);
}
示例9: LDAPSearchDetails
import javax.naming.ldap.SortKey; //导入依赖的package包/类
/**
* Constructor
* @param name the context name
* @param searchScope the search scope
* @param filter the context filter
* @param attributeList the list of attributes
* @param keys
* @param limit
* @param elementList
*/
public LDAPSearchDetails(String name, int searchScope, String filter, SortKey[] keys, long limit, ArrayList elementList, int timeLimit) {
this.contextName = name;
this.searchScope = searchScope;
this.contextFilter = filter;
this.keys = keys;
this.limit = limit;
this.elementList = elementList;
this.timeLimit = timeLimit;
}
示例10: helpTestSearchDetails
import javax.naming.ldap.SortKey; //导入依赖的package包/类
/**
* Helper method for testing the provided LDAPSearchDetails against expected values
* @param searchDetails the LDAPSearchDetails object
* @param expectedContextName the expected context name
* @param expectedContextFilter the expected context filter string
* @param expectedAttrNameList list of expected attribute names
* @param expectedCountLimit the expected count limit
* @param expectedSearchScope the expected search scope
* @param expectedSortKeys the expected sortKeys list.
*/
public void helpTestSearchDetails(final LDAPSearchDetails searchDetails, final String expectedContextName,
final String expectedContextFilter, final List<String> expectedAttrNameList, final long expectedCountLimit,
final int expectedSearchScope, final SortKey[] expectedSortKeys) {
// Get all of the actual values
String contextName = searchDetails.getContextName();
String contextFilter = searchDetails.getContextFilter();
List<Column> attrList = searchDetails.getElementList();
long countLimit = searchDetails.getCountLimit();
int searchScope = searchDetails.getSearchScope();
SortKey[] sortKeys = searchDetails.getSortKeys();
// Compare actual with Expected
assertEquals(expectedContextName, contextName);
assertEquals(expectedContextFilter, contextFilter);
assertEquals(attrList.size(),expectedAttrNameList.size());
Iterator<Column> iter = attrList.iterator();
Iterator<String> eIter = expectedAttrNameList.iterator();
while(iter.hasNext()&&eIter.hasNext()) {
String actualName = iter.next().getSourceName();
String expectedName = eIter.next();
assertEquals(actualName, expectedName);
}
assertEquals(expectedCountLimit, countLimit);
assertEquals(expectedSearchScope, searchScope);
assertArrayEquals(expectedSortKeys, sortKeys);
}
示例11: testSortControlStringArrayBoolean002
import javax.naming.ldap.SortKey; //导入依赖的package包/类
/**
* @tests isCritical()
*/
public void testSortControlStringArrayBoolean002() throws Exception {
assertTrue(new SortControl("", true).isCritical());
assertFalse(new SortControl("", false).isCritical());
assertTrue(new SortControl(new String[0], true).isCritical());
assertFalse(new SortControl(new String[0], false).isCritical());
assertTrue(new SortControl(new SortKey[0], true).isCritical());
assertFalse(new SortControl(new SortKey[0], false).isCritical());
}
示例12: testEncodedValueOfSortControl001
import javax.naming.ldap.SortKey; //导入依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'
* </p>
* <p>
* Here we are testing if this method retrieves the control's ASN.1 BER
* encoded value. In this case we create a sort control using an array of
* sortkey.
* </p>
* <p>
* The expecting result is the control's ASN.1 BER encoded value.
* </p>
*/
public void testEncodedValueOfSortControl001() throws Exception {
SortKey[] sk = { new SortKey("pepe", false, "leo") };
SortControl sc = new SortControl(sk, true);
assertEquals("30 10 30 0e 04 04 70 65 70 65 80 03 6c 65 6f 81 01 ff",
toHexString(sc.getEncodedValue()));
}
示例13: getSortKeys
import javax.naming.ldap.SortKey; //导入依赖的package包/类
/**
* get the sort keys
* @return the sort keys
*/
public SortKey[] getSortKeys() {
return keys;
}