本文整理汇总了Java中org.apache.directory.api.ldap.model.entry.Attribute.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.iterator方法的具体用法?Java Attribute.iterator怎么用?Java Attribute.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.ldap.model.entry.Attribute
的用法示例。
在下文中一共展示了Attribute.iterator方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIterator
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Test method iterator()
*/
@Test
public void testIterator() throws LdapException
{
Attribute attr1 = new DefaultAttribute( atCN );
attr1.add( "a", "b", "c" );
Iterator<Value> iter = attr1.iterator();
assertTrue( iter.hasNext() );
String[] values = new String[]
{ "a", "b", "c" };
int pos = 0;
for ( Value val : attr1 )
{
assertTrue( val instanceof Value );
assertEquals( values[pos++], val.getValue() );
}
}
示例2: testIterator2
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Test method getAll()
*/
@Test
public void testIterator2() throws LdapException
{
Attribute attr = new DefaultAttribute( atEMail );
Iterator<Value> iterator = attr.iterator();
assertFalse( iterator.hasNext() );
attr.add( nullStringValue );
iterator = attr.iterator();
assertTrue( iterator.hasNext() );
Value value = iterator.next();
assertEquals( nullStringValue, value );
attr.clear();
iterator = attr.iterator();
assertFalse( iterator.hasNext() );
attr.add( "a", "b", "c" );
iterator = attr.iterator();
assertTrue( iterator.hasNext() );
assertEquals( "a", iterator.next().getValue() );
assertEquals( "b", iterator.next().getValue() );
assertEquals( "c", iterator.next().getValue() );
assertFalse( iterator.hasNext() );
}
示例3: testRequestWith1AttrWithoutValue
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Test parsing of a request with an Attr elements with value
*/
@Test
public void testRequestWith1AttrWithoutValue()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_1_attr_without_value.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Entry entry = addRequest.getEntry();
assertEquals( 1, entry.size() );
// Getting the Attribute
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "objectclass", attribute.getUpId() );
// Getting the Value
Iterator<Value> valueIterator = attribute.iterator();
assertFalse( valueIterator.hasNext() );
}
示例4: testRequestWith1AttrEmptyValue
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Test parsing of a request with an Attr elements with empty value
*/
@Test
public void testRequestWith1AttrEmptyValue()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_1_attr_empty_value.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Entry entry = addRequest.getEntry();
assertEquals( 1, entry.size() );
// Getting the Attribute
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "objectclass", attribute.getUpId() );
// Getting the Value
Iterator<Value> valueIterator = attribute.iterator();
assertFalse( valueIterator.hasNext() );
}
示例5: testRequestWith1AttrWithValue
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Test parsing of a request with an Attr elements with value
*/
@Test
public void testRequestWith1AttrWithValue()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_1_attr_with_value.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Entry entry = addRequest.getEntry();
assertEquals( 1, entry.size() );
// Getting the Attribute
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "objectclass", attribute.getUpId() );
// Getting the Value
Iterator<Value> valueIterator = attribute.iterator();
assertTrue( valueIterator.hasNext() );
Value value = valueIterator.next();
assertEquals( "top", value.getValue() );
}
示例6: testRequestWith1AttrWithBase64Value
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Test parsing of a request with an Attr elements with value
*/
@Test
public void testRequestWith1AttrWithBase64Value()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_1_attr_with_base64_value.xml" )
.openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Entry entry = addRequest.getEntry();
assertEquals( 1, entry.size() );
// Getting the Attribute
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "objectclass", attribute.getUpId() );
// Getting the Value
Iterator<Value> valueIterator = attribute.iterator();
assertTrue( valueIterator.hasNext() );
Value value = valueIterator.next();
assertFalse( value.isHumanReadable() );
assertEquals( "DSMLv2.0 rocks!!", value.getValue() );
}
示例7: testRequestWith2AttrWithValue
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Test parsing of a request with 2 Attr elements with value
*/
@Test
public void testRequestWith2AttrWithValue()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_2_attr_with_value.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Entry entry = addRequest.getEntry();
assertEquals( 1, entry.size() );
// Getting the Attribute
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "objectclass", attribute.getUpId() );
// Getting the Value
Iterator<Value> valueIterator = attribute.iterator();
assertTrue( valueIterator.hasNext() );
Value value = valueIterator.next();
assertEquals( "top", value.getValue() );
assertTrue( valueIterator.hasNext() );
value = valueIterator.next();
assertEquals( "person", value.getValue() );
assertFalse( valueIterator.hasNext() );
}
示例8: testRequestWith1AttrWith2Values
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Test parsing of a request with 1 Attr element with 2 Values
*/
@Test
public void testRequestWith1AttrWith2Values()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_1_attr_with_2_values.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Entry entry = addRequest.getEntry();
assertEquals( 1, entry.size() );
// Getting the Attribute
Iterator<Attribute> attributeIterator = entry.iterator();
Attribute attribute = attributeIterator.next();
assertEquals( "objectclass", attribute.getUpId() );
// Getting the Value
Iterator<Value> valueIterator = attribute.iterator();
assertTrue( valueIterator.hasNext() );
Value value = valueIterator.next();
assertEquals( "top", value.getValue() );
assertTrue( valueIterator.hasNext() );
value = valueIterator.next();
assertEquals( "person", value.getValue() );
assertFalse( valueIterator.hasNext() );
}
示例9: testResponseWith1Attr1Value
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的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() );
}
示例10: testResponseWith1Attr1Base64Value
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的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() );
}
示例11: testResponseWith1Attr1EmptyValue
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的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() );
}
示例12: testResponseWith1Attr2Value
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的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() );
}
示例13: getLdapEntry
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* 获取XJava对象池中的"条目翻译官"。
*
* 用于:将LDAP条目翻译为Java值对象的实例
*
* @author ZhengWei(HY)
* @createDate 2017-02-15
* @version v1.0
*
* @param i_Entry 条目。将解释条目中的ObjectClass,并组合成ID,再获取"条目翻译官"。
* @return
*/
public static LdapEntry getLdapEntry(Entry i_Entry)
{
if ( i_Entry == null )
{
return null;
}
Attribute v_Attribute = i_Entry.get(LDAP.$ObjectClass);
Iterator<Value<?>> v_Iter = v_Attribute.iterator();
StringBuilder v_Buffer = new StringBuilder();
while (v_Iter.hasNext())
{
Value<?> v_Value = v_Iter.next();
v_Buffer.append(",").append(v_Value.getString());
}
String v_ObjectClassesID = v_Buffer.toString();
if ( Help.isNull(v_ObjectClassesID) )
{
return null;
}
else
{
return getLdapEntry(v_ObjectClassesID.substring(1));
}
}
示例14: testResponseWith2Attr1Value
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Test parsing of a response with 2 Attr 1 Value
*/
@Test
public void testResponseWith2Attr1Value()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput(
SearchResultEntryTest.class.getResource( "response_with_2_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( 2, entry.size() );
Attribute objectClassAttribute = entry.get( "objectclass" );
assertEquals( 1, objectClassAttribute.size() );
Iterator<Value> valueIterator = objectClassAttribute.iterator();
assertTrue( valueIterator.hasNext() );
Value value = valueIterator.next();
assertEquals( "top", value.getValue() );
assertFalse( valueIterator.hasNext() );
Attribute dcAttribute = entry.get( "dc" );
assertEquals( 1, objectClassAttribute.size() );
valueIterator = dcAttribute.iterator();
assertTrue( valueIterator.hasNext() );
value = valueIterator.next();
assertEquals( "example", value.getValue() );
assertFalse( valueIterator.hasNext() );
}