本文整理汇总了Java中org.apache.directory.api.ldap.model.message.SearchResultEntry类的典型用法代码示例。如果您正苦于以下问题:Java SearchResultEntry类的具体用法?Java SearchResultEntry怎么用?Java SearchResultEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchResultEntry类属于org.apache.directory.api.ldap.model.message包,在下文中一共展示了SearchResultEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addResponse
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Adds a response.
*
* @param response
* the response to add
* @return
* true (as per the general contract of the Collection.add method).
*/
public boolean addResponse( DsmlDecorator<? extends Response> response )
{
if ( response instanceof SearchResultEntry )
{
( ( SearchResponse ) getDecorated() ).addSearchResultEntry(
( SearchResultEntryDsml ) response );
}
else if ( response instanceof SearchResultReference )
{
( ( SearchResponse ) getDecorated() ).addSearchResultReference(
( SearchResultReferenceDsml ) response );
}
else if ( response instanceof SearchResultDone )
{
( ( SearchResponse ) getDecorated() ).setSearchResultDone(
( SearchResultDoneDsml ) response );
}
else
{
throw new IllegalArgumentException( "Unidentified search resp type" );
}
return responses.add( response );
}
示例2: testResponseWithDnAttribute
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with dn Attribute
*/
@Test
public void testResponseWithDnAttribute()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( SearchResultEntryTest.class.getResource( "response_with_dn_attribute.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResponseDsml searchResponseDsml = ( SearchResponseDsml )
parser.getBatchResponse().getCurrentResponse();
SearchResponse response = ( SearchResponse ) searchResponseDsml.getDecorated();
SearchResultEntry searchResultEntry = response.getSearchResultEntryList().get( 0 );
assertEquals( "dc=example,dc=com", searchResultEntry.getObjectName().toString() );
}
示例3: testResponseWithRequestId
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a Response with the (optional) requestID attribute
*/
@Test
public void testResponseWithRequestId()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( SearchResultEntryTest.class.getResource( "response_with_requestID_attribute.xml" )
.openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
.getDecorated() )
.getCurrentSearchResultEntry();
assertEquals( 456, searchResultEntry.getMessageId() );
}
示例4: getEntry
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Entry getEntry() throws LdapException
{
if ( isEntry() )
{
return ( ( SearchResultEntry ) response ).getEntry();
}
if ( isReferral() )
{
Referral referral = ( ( SearchResultReference ) response ).getReferral();
throw new LdapReferralException( referral.getLdapUrls() );
}
throw new LdapException();
}
示例5: removeResponse
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Removes a response.
*
* @param response
* the response to remove
* @return
* true if this list contained the specified element.
*/
public boolean removeResponse( DsmlDecorator<? extends Response> response )
{
if ( response instanceof SearchResultEntry )
{
( ( SearchResponse ) getDecorated() ).removeSearchResultEntry(
( SearchResultEntryDsml ) response );
}
else if ( response instanceof SearchResultReference )
{
( ( SearchResponse ) getDecorated() ).removeSearchResultReference(
( SearchResultReferenceDsml ) response );
}
else if ( response instanceof SearchResultDone )
{
if ( response.equals( ( ( SearchResponse ) getDecorated() ).getSearchResultDone() ) )
{
( ( SearchResponse ) getDecorated() ).setSearchResultDone( null );
}
}
else
{
throw new IllegalArgumentException( "Unidentified search resp type" );
}
return responses.remove( response );
}
示例6: testResponseWith1Control
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with a (optional) Control element
*/
@Test
public void testResponseWith1Control()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( SearchResultEntryTest.class.getResource( "response_with_1_control.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResponse searchResponse = ( SearchResponse )
parser.getBatchResponse().getCurrentResponse().getDecorated();
SearchResultEntry searchResultEntry =
searchResponse.getCurrentSearchResultEntry();
Map<String, Control> controls =
searchResponse.getCurrentSearchResultEntry().getControls();
assertEquals( 1, searchResultEntry.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.643" );
assertNotNull( control );
assertTrue( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
assertEquals( "Some text", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}
示例7: testResponseWith1ControlEmptyValue
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with a (optional) Control element with empty value
*/
@Test
public void testResponseWith1ControlEmptyValue()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( SearchResultEntryTest.class.getResource( "response_with_1_control_empty_value.xml" )
.openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResponse searchResponse = ( SearchResponse )
parser.getBatchResponse().getCurrentResponse().getDecorated();
SearchResultEntry searchResultEntry =
searchResponse.getCurrentSearchResultEntry();
Map<String, Control> controls = searchResultEntry.getControls();
assertEquals( 1, searchResultEntry.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.643" );
assertNotNull( control );
assertTrue( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
assertFalse( ( ( DsmlControl<?> ) control ).hasValue() );
}
示例8: testResponseWith2Controls
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with 2 (optional) Control elements
*/
@Test
public void testResponseWith2Controls()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( SearchResultEntryTest.class.getResource( "response_with_2_controls.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResponse searchResponse = ( SearchResponse )
parser.getBatchResponse().getCurrentResponse().getDecorated();
SearchResultEntry searchResultEntry =
searchResponse.getCurrentSearchResultEntry();
Map<String, Control> controls = searchResultEntry.getControls();
assertEquals( 2, searchResultEntry.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.789" );
assertNotNull( control );
assertFalse( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.789", control.getOid() );
assertEquals( "Some other text", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}
示例9: testResponseWith3ControlsWithoutValue
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with 3 (optional) Control elements without value
*/
@Test
public void testResponseWith3ControlsWithoutValue()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( SearchResultEntryTest.class.getResource( "response_with_3_controls_without_value.xml" )
.openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResponse searchResponse = ( SearchResponse )
parser.getBatchResponse().getCurrentResponse().getDecorated();
SearchResultEntry searchResultEntry =
searchResponse.getCurrentSearchResultEntry();
Map<String, Control> controls = searchResultEntry.getControls();
assertEquals( 3, searchResultEntry.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.456" );
assertNotNull( control );
assertTrue( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.456", control.getOid() );
assertFalse( ( ( DsmlControl<?> ) control ).hasValue() );
}
示例10: testResponseWith1Attr0Value
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with 1 Attr 0 Value
*/
@Test
public void testResponseWith1Attr0Value()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput(
SearchResultEntryTest.class.getResource( "response_with_1_attr_0_value.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
.getDecorated() )
.getCurrentSearchResultEntry();
Entry entry = searchResultEntry.getEntry();
assertEquals( 1, entry.size() );
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "dc", attribute.getUpId() );
}
示例11: testResponseWith1Attr1Value
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with 1 Attr 1 Value
*/
@Test
public void testResponseWith1Attr1Value()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput(
SearchResultEntryTest.class.getResource( "response_with_1_attr_1_value.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
.getDecorated() )
.getCurrentSearchResultEntry();
Entry entry = searchResultEntry.getEntry();
assertEquals( 1, entry.size() );
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "dc", attribute.getUpId() );
Iterator<Value> valueIterator = attribute.iterator();
assertTrue( valueIterator.hasNext() );
Value value = valueIterator.next();
assertEquals( "example", value.getValue() );
}
示例12: testResponseWith1Attr1Base64Value
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with 1 Attr 1 Base64 Value
*/
@Test
public void testResponseWith1Attr1Base64Value()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( SearchResultEntryTest.class.getResource( "response_with_1_attr_1_base64_value.xml" )
.openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
.getDecorated() )
.getCurrentSearchResultEntry();
Entry entry = searchResultEntry.getEntry();
assertEquals( 1, entry.size() );
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "cn", attribute.getUpId() );
assertEquals( 1, attribute.size() );
Iterator<Value> valueIterator = attribute.iterator();
assertTrue( valueIterator.hasNext() );
Value value = valueIterator.next();
String expected = new String( new byte[]
{ 'E', 'm', 'm', 'a', 'n', 'u', 'e', 'l', ' ', 'L', ( byte ) 0xc3, ( byte ) 0xa9, 'c', 'h', 'a', 'r', 'n',
'y' }, StandardCharsets.UTF_8 );
assertEquals( expected, value.getValue() );
}
示例13: testResponseWith1Attr1EmptyValue
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with 1 Attr 1 empty Value
*/
@Test
public void testResponseWith1Attr1EmptyValue()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( SearchResultEntryTest.class.getResource( "response_with_1_attr_1_empty_value.xml" )
.openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
.getDecorated() )
.getCurrentSearchResultEntry();
Entry entry = searchResultEntry.getEntry();
assertEquals( 1, entry.size() );
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "dc", attribute.getUpId() );
assertEquals( 1, attribute.size() );
Iterator<Value> valueIterator = attribute.iterator();
assertTrue( valueIterator.hasNext() );
Value value = valueIterator.next();
assertEquals( "", value.getValue() );
}
示例14: testResponseWith1Attr2Value
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* Test parsing of a response with 1 Attr 2 Value
*/
@Test
public void testResponseWith1Attr2Value()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput(
SearchResultEntryTest.class.getResource( "response_with_1_attr_2_value.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
SearchResultEntry searchResultEntry = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse()
.getDecorated() )
.getCurrentSearchResultEntry();
Entry entry = searchResultEntry.getEntry();
assertEquals( 1, entry.size() );
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "objectclass", attribute.getUpId() );
assertEquals( 2, attribute.size() );
Iterator<Value> valueIterator = attribute.iterator();
assertTrue( valueIterator.hasNext() );
Value value = valueIterator.next();
assertEquals( "top", value.getValue() );
assertTrue( valueIterator.hasNext() );
value = valueIterator.next();
assertEquals( "domain", value.getValue() );
assertFalse( valueIterator.hasNext() );
}
示例15: get
import org.apache.directory.api.ldap.model.message.SearchResultEntry; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Entry get() throws CursorException
{
if ( !searchCursor.available() )
{
throw new InvalidCursorPositionException();
}
try
{
do
{
if ( response instanceof SearchResultEntry )
{
return ( ( SearchResultEntry ) response ).getEntry();
}
if ( response instanceof SearchResultReference )
{
throw new LdapReferralException( ( ( SearchResultReference ) response ).getReferral().getLdapUrls() );
}
}
while ( next() && !( response instanceof SearchResultDone ) );
}
catch ( LdapReferralException lre )
{
throw new CursorLdapReferralException( lre );
}
catch ( Exception e )
{
throw new CursorException( e );
}
return null;
}