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


Java Entry.put方法代码示例

本文整理汇总了Java中org.apache.directory.api.ldap.model.entry.Entry.put方法的典型用法代码示例。如果您正苦于以下问题:Java Entry.put方法的具体用法?Java Entry.put怎么用?Java Entry.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.directory.api.ldap.model.entry.Entry的用法示例。


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

示例1: createEntry

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Helper method which creates an entry with 4 attributes.
 */
private Entry createEntry()
{
    try
    {
        Entry entry = new DefaultEntry( exampleDn );

        Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
        Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
        Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

        entry.put( attrOC, attrCN, attrSN, attrPWD );

        return entry;
    }
    catch ( LdapException ne )
    {
        // Do nothing
        return null;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:SchemaAwareEntryTest.java

示例2: getEntry

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
private Entry getEntry( LdapComparatorDescription comparatorDescription )
{
    Entry entry = new DefaultEntry();

    entry.put( SchemaConstants.OBJECT_CLASS_AT,
        SchemaConstants.TOP_OC,
        MetaSchemaConstants.META_TOP_OC,
        MetaSchemaConstants.META_COMPARATOR_OC );

    entry.put( MetaSchemaConstants.M_OID_AT, comparatorDescription.getOid() );
    entry.put( MetaSchemaConstants.M_FQCN_AT, comparatorDescription.getFqcn() );

    if ( comparatorDescription.getBytecode() != null )
    {
        entry.put( MetaSchemaConstants.M_BYTECODE_AT,
            Base64.decode( comparatorDescription.getBytecode().toCharArray() ) );
    }

    if ( comparatorDescription.getDescription() != null )
    {
        entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, comparatorDescription.getDescription() );
    }

    return entry;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:DefaultSchemaLoader.java

示例3: testRemoveAttributesStringArray

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Test method for removeAttributes( String... )
 */
@Test
public void testRemoveAttributesStringArray() throws LdapException
{
    Entry entry = new DefaultEntry( exampleDn );

    Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
    Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
    Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
    Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

    entry.put( attrOC, attrCN, attrSN, attrPWD );

    entry.removeAttributes( "CN", "SN" );

    assertFalse( entry.containsAttribute( "cn", "sn" ) );
    assertTrue( entry.containsAttribute( "objectclass", "userpassword" ) );

    entry.removeAttributes( "badId" );

    entry.removeAttributes( ( String ) null );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:SchemaAwareEntryTest.java

示例4: testApplyRemoveModificationFromEntrySameAttributeSameValue

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Test the deletion of an attribute into an entry which contains the attribute.
 * 
 * The entry should not contain the attribute after the operation
 */
@Test
public void testApplyRemoveModificationFromEntrySameAttributeSameValue() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test" );

    Attribute attr = new DefaultAttribute( "cn", "test" );

    Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );

    assertNull( entry.get( "cn" ) );
    assertEquals( 0, entry.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:AttributeUtilsTest.java

示例5: nameToLdif

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * @return the Names as Ldif lines
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
private String nameToLdif() throws LdapException
{
    if ( names.isEmpty() )
    {
        return "";
    }
    else
    {
        Entry entry = new DefaultEntry();
        Attribute attribute = new DefaultAttribute( "m-name" );

        for ( String name : names )
        {
            attribute.add( name );
        }

        entry.put( attribute );

        return LdifUtils.convertAttributesToLdif( entry );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:SchemaElementImpl.java

示例6: getEntry

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Creates and populates a LockableAttributes object
 * 
 * @return
 */
private Entry getEntry()
{
    Entry entry = new DefaultEntry();

    try
    {
        entry.put( getAttribute( "attr0" ) );
        entry.put( getAttribute( "attr1" ) );
        entry.put( getAttribute( "attr2" ) );
    }
    catch ( LdapException ne )
    {
        // Do nothing
    }

    return entry;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:AddRequestImplTest.java

示例7: testApplyModifyModificationRemoveAttribute

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Test the removing by modification of an existing attribute in an .
 * 
 * @throws LdapException
 */
@Test
public void testApplyModifyModificationRemoveAttribute() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test" );
    entry.put( "ou", "apache", "acme corp" );

    Attribute newOu = new DefaultAttribute( "ou" );

    Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newOu );

    AttributeUtils.applyModification( entry, modification );

    assertEquals( 1, entry.size() );

    assertNotNull( entry.get( "cn" ) );
    assertNull( entry.get( "ou" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:AttributeUtilsTest.java

示例8: descToLdif

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * @return The description as a ldif line
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
private String descToLdif() throws LdapException
{
    if ( Strings.isEmpty( description ) )
    {
        return "";
    }
    else
    {
        Entry entry = new DefaultEntry();
        Attribute attribute = new DefaultAttribute( "m-description", description );

        entry.put( attribute );

        return LdifUtils.convertAttributesToLdif( entry );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:SchemaElementImpl.java

示例9: testApplyRemoveModificationFromEntryAttributeNotSameValue

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Test the deletion of an attribute into an entry which contains the attribute
 * but without the value to be deleted
 */
@Test
public void testApplyRemoveModificationFromEntryAttributeNotSameValue() throws LdapException
{
    Entry entry = new DefaultEntry();

    Attribute cn = new DefaultAttribute( "cn", "apache" );
    entry.put( cn );

    Attribute attr = new DefaultAttribute( "cn", "test" );

    Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );

    assertNotNull( entry.get( "cn" ) );
    assertEquals( 1, entry.size() );
    assertEquals( cn, entry.get( "cn" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:AttributeUtilsTest.java

示例10: convert

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Convert a SyntaxChecker instance into an Entry
 *
 * @param syntaxChecker The SyntaxChecker to convert
 * @param schema The schema containing this SyntaxChecker
 * @param schemaManager The SchemaManager
 * @return An Entry containing the converted SyntaxChecker
 */
public Entry convert( SyntaxChecker syntaxChecker, Schema schema, SchemaManager schemaManager )
{
    Entry entry = new DefaultEntry( schemaManager );

    entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SYNTAX_CHECKER_OC );
    entry.put( MetaSchemaConstants.M_OID_AT, syntaxChecker.getOid() );
    entry.put( MetaSchemaConstants.M_FQCN_AT, syntaxChecker.getClass().getName() );
    entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
    entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );

    return entry;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:AttributesFactory.java

示例11: getEntry

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Creates and populates an Entry object
 * 
 * @return The populated Entry object
 */
private Entry getEntry() throws LdapException
{
    Entry attrs = new DefaultEntry();
    attrs.put( getEntry( "attr0" ) );
    attrs.put( getEntry( "attr1" ) );
    attrs.put( getEntry( "attr2" ) );
    return attrs;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:14,代码来源:SearchResultEntryImplTest.java

示例12: testApplyAddModificationToEntryWithSameValue

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Test a addModification applied to an entry with the same attribute
 * and the same value 
 */
@Test
public void testApplyAddModificationToEntryWithSameValue() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test", "apache" );
    assertEquals( 1, entry.size() );

    Attribute attr = new DefaultAttribute( "cn", "test" );
    Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );
    AttributeUtils.applyModification( entry, modification );
    assertNotNull( entry.get( "cn" ) );
    assertEquals( 1, entry.size() );

    Attribute cnAttr = entry.get( "cn" );

    assertTrue( cnAttr.size() != 0 );

    Set<String> expectedValues = new HashSet<String>();
    expectedValues.add( "apache" );
    expectedValues.add( "test" );

    for ( Value value : cnAttr )
    {
        String valueStr = value.getValue();

        assertTrue( expectedValues.contains( valueStr ) );

        expectedValues.remove( valueStr );
    }

    assertEquals( 0, expectedValues.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:37,代码来源:AttributeUtilsTest.java

示例13: testApplyModifyAttributeModification

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Test the replacement by modification of an attribute in an empty entry.
 * 
 * As we are replacing a non existing attribute, it should not change the entry.
 *
 * @throws LdapException
 */
@Test
public void testApplyModifyAttributeModification() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test" );
    entry.put( "ou", "apache", "acme corp" );

    Attribute newOu = new DefaultAttribute( "ou", "Big Company", "directory" );

    Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newOu );

    AttributeUtils.applyModification( entry, modification );

    assertEquals( 2, entry.size() );

    assertNotNull( entry.get( "cn" ) );
    assertNotNull( entry.get( "ou" ) );

    Attribute modifiedAttr = entry.get( "ou" );

    assertTrue( modifiedAttr.size() != 0 );

    Set<String> expectedValues = new HashSet<String>();
    expectedValues.add( "Big Company" );
    expectedValues.add( "directory" );

    for ( Value value : modifiedAttr )
    {
        String valueStr = value.getValue();

        assertTrue( expectedValues.contains( valueStr ) );

        expectedValues.remove( valueStr );
    }

    assertEquals( 0, expectedValues.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:45,代码来源:AttributeUtilsTest.java

示例14: testApplyAddModificationToEntryWithValues

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Test a addModification applied to an entry with the same attribute
 * but with another value 
 */
@Test
public void testApplyAddModificationToEntryWithValues() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "apache" );
    assertEquals( 1, entry.size() );

    Attribute attr = new DefaultAttribute( "cn", "test" );
    Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );
    AttributeUtils.applyModification( entry, modification );
    assertNotNull( entry.get( "cn" ) );
    assertEquals( 1, entry.size() );

    Attribute attribute = entry.get( "cn" );

    assertTrue( attribute.size() != 0 );

    Set<String> expectedValues = new HashSet<String>();
    expectedValues.add( "apache" );
    expectedValues.add( "test" );

    for ( Value value : attribute )
    {
        String valueStr = value.getValue();

        assertTrue( expectedValues.contains( valueStr ) );

        expectedValues.remove( valueStr );
    }

    assertEquals( 0, expectedValues.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:37,代码来源:AttributeUtilsTest.java

示例15: testEqualsObject

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Test method for equals()
 */
@Test
public void testEqualsObject() throws LdapException
{
    Entry entry1 = new DefaultEntry();
    Entry entry2 = new DefaultEntry();

    assertEquals( entry1, entry2 );

    entry1.setDn( exampleDn );
    assertNotSame( entry1, entry2 );

    entry2.setDn( exampleDn );
    assertEquals( entry1, entry2 );

    Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
    Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
    Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
    Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

    entry1.put( attrOC, attrCN, attrSN, attrPWD );
    entry2.put( attrOC, attrCN, attrSN );
    assertNotSame( entry1, entry2 );

    entry2.put( attrPWD );
    assertEquals( entry1, entry2 );

    Attribute attrL1 = new DefaultAttribute( "l", "Paris", "New-York" );
    Attribute attrL2 = new DefaultAttribute( "l", "Paris", "Tokyo" );

    entry1.put( attrL1 );
    entry2.put( attrL1 );
    assertEquals( entry1, entry2 );

    entry1.add( "l", "London" );
    assertNotSame( entry1, entry2 );

    entry2.add( attrL2 );
    assertNotSame( entry1, entry2 );

    entry1.clear();
    entry2.clear();
    assertEquals( entry1, entry2 );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:47,代码来源:SchemaAwareEntryTest.java


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