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


Java Entry.get方法代码示例

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


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

示例1: testAddStringByteArrayArray

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

    entry.add( "userPassword", ( byte[] ) null );
    assertEquals( 1, entry.size() );
    Attribute attributePWD = entry.get( "userPassword" );
    assertEquals( 1, attributePWD.size() );
    assertNotNull( attributePWD.get() );
    assertNull( attributePWD.get().getBytes() );

    entry.add( "jpegPhoto", BYTES1, BYTES1, BYTES2 );
    assertEquals( 2, entry.size() );
    Attribute attributeJPG = entry.get( "jpegPhoto" );
    assertEquals( 2, attributeJPG.size() );
    assertNotNull( attributeJPG.get() );
    assertTrue( attributeJPG.contains( BYTES1 ) );
    assertTrue( attributeJPG.contains( BYTES2 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:SchemaAwareEntryTest.java

示例2: testAddStringStringArray

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

    entry.add( "cn", ( String ) null );
    assertEquals( 1, entry.size() );
    Attribute attributeCN = entry.get( "cn" );
    assertEquals( 1, attributeCN.size() );
    assertNotNull( attributeCN.get() );
    assertNull( attributeCN.get().getValue() );

    entry.add( "sn", "test", "test", "TEST" );
    assertEquals( 2, entry.size() );
    Attribute attributeSN = entry.get( "sn" );
    assertEquals( 2, attributeSN.size() );
    assertNotNull( attributeSN.get() );
    assertTrue( attributeSN.contains( "test" ) );
    assertTrue( attributeSN.contains( "TEST" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:SchemaAwareEntryTest.java

示例3: testGet

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

    assertNull( entry.get( "objectClass" ) );

    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.add( attrOC, attrCN, attrSN, attrPWD );

    assertNotNull( entry.get( "  CN  " ) );
    Attribute attribute = entry.get( "cN" );

    assertEquals( attribute, attrCN );

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

示例4: testLdifVersionStart

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
@Test
public void testLdifVersionStart() throws LdapLdifException, IOException
{
    String ldif = 
          "cn: app1\n" 
        + "objectClass: top\n" 
        + "objectClass: apApplication\n" 
        + "displayName:   app1   \n"
        + "dependencies:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertEquals( 1, reader.getVersion() );
    assertNotNull( entry );

    Attribute attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:22,代码来源:LdifAttributesReaderTest.java

示例5: testLdifParserEndSpaces

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Spaces at the end of values should not be included into values.
 * 
 * @throws NamingException
 */
@Test
public void testLdifParserEndSpaces() throws LdapLdifException, IOException
{
    String ldif = 
          "cn: app1\n" 
        + "objectClass: top\n" 
        + "objectClass: apApplication\n" 
        + "displayName:   app1   \n"
        + "dependencies:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();

    Entry entry = reader.parseEntry( ldif );
    assertNotNull( entry );

    Attribute attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:LdifAttributesReaderTest.java

示例6: testAddEntryAttributeArray

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Test method for add( EntryAttribute... )
 */
@Test
public void testAddEntryAttributeArray() throws LdapException
{
    Entry entry = createEntry();

    assertEquals( 4, entry.size() );
    assertTrue( entry.containsAttribute( "ObjectClass" ) );
    assertTrue( entry.containsAttribute( "CN" ) );
    assertTrue( entry.containsAttribute( "  sn  " ) );
    assertTrue( entry.containsAttribute( "userPassword" ) );

    Attribute attr = entry.get( "objectclass" );
    assertEquals( 2, attr.size() );

    Attribute attrCN2 = new DefaultAttribute( "cn", "test1", "test3" );
    entry.add( attrCN2 );
    assertEquals( 4, entry.size() );
    attr = entry.get( "cn" );
    assertEquals( 3, attr.size() );
    assertTrue( attr.contains( "test1", "test2", "test3" ) );

    // Check adding some byte[] values (they will not be transformed to Strings)
    attrCN2.clear();
    attrCN2.add( BYTES1, BYTES2 );
    entry.add( attrCN2 );
    assertEquals( 4, entry.size() );
    attr = entry.get( "cn" );
    assertEquals( 3, attr.size() );
    assertTrue( attr.contains( "test1", "test2", "test3" ) );
    assertFalse( attr.contains( "ab", "b" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:35,代码来源:SchemaAwareEntryTest.java

示例7: getLdapEntry

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的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));
    }
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.ldap,代码行数:41,代码来源:LDAP.java

示例8: getFqcn

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Process the FQCN attribute
 * @throws LdapInvalidAttributeValueException
 */
private String getFqcn( Entry entry, String objectType ) throws LdapInvalidAttributeValueException
{
    // The FQCN
    Attribute mFqcn = entry.get( MetaSchemaConstants.M_FQCN_AT );

    if ( mFqcn == null )
    {
        String msg = I18n.err( I18n.ERR_10028, objectType, MetaSchemaConstants.M_FQCN_AT );
        LOG.warn( msg );
        throw new IllegalArgumentException( msg );
    }

    return mFqcn.getString();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:SchemaEntityFactory.java

示例9: 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

示例10: testApplyRemoveModificationFromEntrySameAttributeValues

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

    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() );

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

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

    boolean isFirst = true;

    for ( Value value : modifiedAttr )
    {
        assertTrue( isFirst );

        isFirst = false;
        assertEquals( "apache", value.getValue() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:36,代码来源:AttributeUtilsTest.java

示例11: 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

示例12: testLdifParser

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
@Test
public void testLdifParser() throws LdapLdifException, LdapInvalidAttributeValueException, IOException
{
    String ldif = 
          "cn: app1\n" 
        + "objectClass: top\n" 
        + "objectClass: apApplication\n" 
        + "displayName: app1   \n"
        + "dependencies:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertNotNull( entry );

    Attribute attr = entry.get( "cn" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "apApplication" ) );

    attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "dependencies" );
    assertEquals( "", attr.get().getValue() );

    attr = entry.get( "envvars" );
    assertEquals( "", attr.get().getValue() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:34,代码来源:LdifAttributesReaderTest.java

示例13: doInit

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
/**
 * Partition initialization - loads schema entries from the files on classpath.
 *
 * @see org.apache.directory.server.core.partition.impl.avl.AvlPartition#doInit()
 */
@Override
protected void doInit() throws InvalidNameException, Exception {
    if (initialized)
        return;

    LOG.debug("Initializing schema partition " + getId());
    suffixDn.apply(schemaManager);
    super.doInit();

    // load schema
    final Map<String, Boolean> resMap = ResourceMap.getResources(Pattern.compile("schema[/\\Q\\\\E]ou=schema.*"));
    for (String resourcePath : new TreeSet<>(resMap.keySet())) {
        if (resourcePath.endsWith(".ldif")) {
            URL resource = DefaultSchemaLdifExtractor.getUniqueResource(resourcePath, "Schema LDIF file");
            LdifReader reader = new LdifReader(resource.openStream());
            LdifEntry ldifEntry = reader.next();
            reader.close();

            Entry entry = new DefaultEntry(schemaManager, ldifEntry.getEntry());
            // add mandatory attributes
            if (entry.get(SchemaConstants.ENTRY_CSN_AT) == null) {
                entry.add(SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString());
            }
            if (entry.get(SchemaConstants.ENTRY_UUID_AT) == null) {
                entry.add(SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString());
            }
            AddOperationContext addContext = new AddOperationContext(null, entry);
            super.add(addContext);
        }
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:37,代码来源:InMemorySchemaPartition.java

示例14: testLdifParserBase64

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
@Test
public void testLdifParserBase64() throws LdapLdifException, IOException
{
    String ldif = 
          "#comment\n" 
        + "cn:: RW1tYW51ZWwgTMOpY2hhcm55\n" 
        + "objectClass: top\n"
        + "objectClass: apApplication\n" 
        + "displayName: app1\n" 
        + "serviceType: http\n" 
        + "dependencies:\n"
        + "httpHeaders:\n" 
        + "startupOptions:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertNotNull( entry );

    Attribute attr = entry.get( "cn" );
    assertTrue( attr.contains( "Emmanuel L\u00e9charny".getBytes( StandardCharsets.UTF_8 ) ) );

    attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "apApplication" ) );

    attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "dependencies" );
    assertEquals( "", attr.get().getValue() );

    attr = entry.get( "envvars" );
    assertEquals( "", attr.get().getValue() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:38,代码来源:LdifAttributesReaderTest.java

示例15: testLdifParserBase64MultiLine

import org.apache.directory.api.ldap.model.entry.Entry; //导入方法依赖的package包/类
@Test
public void testLdifParserBase64MultiLine() throws LdapLdifException, IOException
{
    String ldif = 
          "#comment\n" 
        + "cn:: RW1tYW51ZWwg\n" 
        + " TMOpY2hhcm55ICA=\n" 
        + "objectClass: top\n"
        + "objectClass: apApplication\n" 
        + "displayName: app1\n" 
        + "serviceType: http\n" 
        + "dependencies:\n"
        + "httpHeaders:\n" 
        + "startupOptions:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertNotNull( entry );

    Attribute attr = entry.get( "cn" );
    assertTrue( attr.contains( "Emmanuel L\u00e9charny  ".getBytes( StandardCharsets.UTF_8 ) ) );

    attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "apApplication" ) );

    attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "dependencies" );
    assertEquals( "", attr.get().getValue() );

    attr = entry.get( "envvars" );
    assertEquals( "", attr.get().getValue() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:39,代码来源:LdifAttributesReaderTest.java


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