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


Java Attribute.add方法代码示例

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


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

示例1: nameToLdif

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的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

示例2: testClear

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Test method clear()
 */
@Test
public void testClear() throws LdapException
{
    Attribute attr = new DefaultAttribute( "email", atEMail );

    assertEquals( 0, attr.size() );

    attr.add( ( String ) null, "a", "b" );
    assertEquals( 3, attr.size() );

    attr.clear();
    assertTrue( attr.isHumanReadable() );
    assertEquals( 0, attr.size() );
    assertEquals( atEMail, attr.getAttributeType() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:SchemaAwareAttributeTest.java

示例3: testNotEqualDiffModCount

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Test for inequality when only the number of mods are different.
 */
@Test
public void testNotEqualDiffModCount() throws LdapException
{
    ModifyRequestImpl req0 = getRequest();
    Attribute attr = new DefaultAttribute( "attr3" );
    attr.add( "val0" );
    attr.add( "val1" );
    attr.add( "val2" );
    Modification item = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );
    req0.addModification( item );

    ModifyRequestImpl req1 = getRequest();

    assertFalse( req0.equals( req1 ) );
    assertFalse( req1.equals( req0 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:20,代码来源:ModifyRequestImplTest.java

示例4: testContainsByteArray

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Test method contains( byte[]... )
 */
@Test
public void testContainsByteArray() throws LdapException
{
    Attribute attr1 = new DefaultAttribute( atPwd );

    assertEquals( 0, attr1.size() );
    assertFalse( attr1.contains( BYTES1 ) );
    assertFalse( attr1.contains( ( byte[] ) null ) );

    attr1.add( ( byte[] ) null );
    assertEquals( 1, attr1.size() );
    assertTrue( attr1.contains( ( byte[] ) null ) );

    attr1.remove( ( byte[] ) null );
    assertFalse( attr1.contains( ( byte[] ) null ) );
    assertEquals( 0, attr1.size() );

    attr1.add( BYTES1, BYTES2, BYTES3 );
    assertEquals( 3, attr1.size() );
    assertTrue( attr1.contains( BYTES1 ) );
    assertTrue( attr1.contains( BYTES2 ) );
    assertTrue( attr1.contains( BYTES3 ) );
    assertFalse( attr1.contains( BYTES4 ) );
    assertFalse( attr1.contains( ( byte[] ) null ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:SchemaAwareAttributeTest.java

示例5: anonymize

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type)
 */
@Override
public Attribute anonymize( Map<Value, Value> valueMap, Set<Value> valueSet, Attribute attribute )
{
    Attribute result = new DefaultAttribute( attribute.getAttributeType() );

    for ( Value value : attribute )
    {
        byte[] bytesValue = value.getBytes();
        byte[] newValue = computeNewValue( bytesValue );
        
        try
        {
            result.add( newValue );
            Value anonValue = new Value( attribute.getAttributeType(), newValue );
            valueMap.put( ( Value ) value, anonValue );
            valueSet.add( anonValue );
        }
        catch ( LdapInvalidAttributeValueException e )
        {
            throw new RuntimeException( "Error while anonymizing the value" + value );
        }
    }

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

示例6: testCreateServerModification

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
@Test
public void testCreateServerModification() throws LdapException
{
    Attribute attribute = new DefaultAttribute( "cn" );
    attribute.add( "test1", "test2" );

    Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
    Modification clone = mod.clone();

    attribute.remove( "test2" );

    Attribute clonedAttribute = clone.getAttribute();

    assertEquals( 1, mod.getAttribute().size() );
    assertTrue( mod.getAttribute().contains( "test1" ) );

    assertEquals( 2, clonedAttribute.size() );
    assertTrue( clone.getAttribute().contains( "test1" ) );
    assertTrue( clone.getAttribute().contains( "test2" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:ModificationTest.java

示例7: testClone

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Test method testClone()
 */
@Test
public void testClone() throws LdapException
{
    Attribute attr = new DefaultAttribute( atDC );

    Attribute clone = attr.clone();

    assertEquals( attr, clone );
    attr.setUpId( "DomainComponent" );
    assertEquals( "0.9.2342.19200300.100.1.25", clone.getId() );

    attr.add( "a", ( String ) null, "b" );
    clone = attr.clone();
    assertEquals( attr, clone );

    attr.remove( "a" );
    assertNotSame( attr, clone );

    clone = attr.clone();
    assertEquals( attr, clone );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:SchemaAwareAttributeTest.java

示例8: testIsValidSyntaxChecker

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Test method isValid( SyntaxChecker )
 */
@Test
public void testIsValidSyntaxChecker() throws LdapException
{
    Attribute attr = new DefaultAttribute( "test" );

    attr.add( "test", "another test" );

    assertTrue( attr.isValid( atCN ) );

    attr.add( "test an invalid '\uFFFD' char" );
    assertFalse( attr.isValid( atCN ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:16,代码来源:SchemaAwareAttributeTest.java

示例9: testSerializationModificationADD

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
@Test
public void testSerializationModificationADD() throws ClassNotFoundException, IOException, LdapException
{
    Attribute attribute = new DefaultAttribute( "cn" );
    attribute.add( "test1", "test2" );

    DefaultModification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );

    Modification modSer = deserializeValue( serializeValue( mod ) );

    assertEquals( mod, modSer );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:13,代码来源:ModificationTest.java

示例10: testIsValid

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Test method isValid()
 */
@Test
public void testIsValid() throws Exception
{
    Attribute attr = new DefaultAttribute( atCN );

    // No value, this should not be valid
    assertFalse( attr.isValid( atCN ) );

    attr.add( "test", "test2", "A123\\;" );
    assertTrue( attr.isValid( atCN ) );

    // If we try to add a wrong value, it will not be added. The
    // attribute remains valid.
    assertEquals( 0, attr.add( new byte[]
        { 0x01 } ) );
    assertTrue( attr.isValid( atCN ) );

    // test a SINGLE-VALUE attribute. CountryName is SINGLE-VALUE
    attr.clear();
    attr.apply( atC );
    attr.add( "FR" );
    assertTrue( attr.isValid( atC ) );
    assertEquals( 0, attr.add( "US" ) );
    assertFalse( attr.contains( "US" ) );
    assertTrue( attr.isValid( atC ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:30,代码来源:SchemaAwareAttributeTest.java

示例11: testSerializationModificationREPLACE

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
@Test
public void testSerializationModificationREPLACE() throws ClassNotFoundException, IOException,
    LdapInvalidAttributeValueException
{
    Attribute attribute = new DefaultAttribute( "cn", cnAT );
    attribute.add( "test1", "test2" );

    DefaultModification mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );

    Modification modSer = deserializeValue( serializeValue( mod ) );

    assertEquals( mod, modSer );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:14,代码来源:SchemaAwareModificationSerializationTest.java

示例12: initNames

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Initialize name instances
 */
@Before
public void initNames() throws Exception
{

    Attribute attrA = new DefaultAttribute( "aa" );
    attrA.add( "aa" );
    Attribute attrB = new DefaultAttribute( "bb" );
    attrB.add( "bb" );
    Attribute attrC = new DefaultAttribute( "cc" );
    attrC.add( "cc" );
    Attribute attrD = new DefaultAttribute( "dd" );
    attrD.add( "dd" );

    Set<Attribute> colA = new HashSet<Attribute>();
    colA.add( attrA );
    colA.add( attrB );
    colA.add( attrC );
    Set<Attribute> colB = new HashSet<Attribute>();
    colB.add( attrA );
    colB.add( attrB );
    colB.add( attrC );
    Set<Attribute> colC = new HashSet<Attribute>();
    colC.add( attrB );
    colC.add( attrC );
    colC.add( attrD );

    attributeValueA = new AttributeValueItem( colA );
    attributeValueACopy = new AttributeValueItem( colA );
    attributeValueB = new AttributeValueItem( colB );
    attributeValueC = new AttributeValueItem( colC );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:35,代码来源:ProtectedItem_AttributeValueTest.java

示例13: testGet

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Test method get()
 */
@Test
public void testGet() throws LdapException
{
    Attribute attr1 = new DefaultAttribute( "dc", atDC );

    attr1.add( ( String ) null );
    assertEquals( nullStringValue, attr1.get() );

    Attribute attr2 = new DefaultAttribute( "email", atEMail );

    attr2.add( "a", "b", "c" );
    assertEquals( "a", attr2.get().getValue() );

    attr2.remove( "a" );
    assertEquals( "b", attr2.get().getValue() );

    attr2.remove( "b" );
    assertEquals( "c", attr2.get().getValue() );

    attr2.remove( "c" );
    assertNull( attr2.get() );

    Attribute attr3 = new DefaultAttribute( "userPassword", atPwd );

    attr3.add( BYTES1, BYTES2, BYTES3 );
    assertTrue( Arrays.equals( BYTES1, attr3.get().getBytes() ) );

    attr3.remove( BYTES1 );
    assertTrue( Arrays.equals( BYTES2, attr3.get().getBytes() ) );

    attr3.remove( BYTES2 );
    assertTrue( Arrays.equals( BYTES3, attr3.get().getBytes() ) );

    attr3.remove( BYTES3 );
    assertNull( attr2.get() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:40,代码来源:SchemaAwareAttributeTest.java

示例14: convert

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Converts a Schema to an Entry
 * 
 * @param schema The Schema to convert
 * @param schemaManager The SchemaManager
 * @return An Entry containing the converted Schema
 * @throws LdapException If the conversion failed
 */
public Entry convert( Schema schema, SchemaManager schemaManager ) throws LdapException
{
    Entry entry = new DefaultEntry( schemaManager );

    entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SCHEMA_OC );
    entry.put( SchemaConstants.CN_AT, schema.getSchemaName() );
    entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
    entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );

    if ( schema.isDisabled() )
    {
        entry.put( MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
    }

    String[] dependencies = schema.getDependencies();

    if ( dependencies != null && dependencies.length > 0 )
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( MetaSchemaConstants.M_DEPENDENCIES_AT ) );

        for ( String dependency : dependencies )
        {
            attr.add( dependency );
        }

        entry.put( attr );
    }

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

示例15: testSerializationModificationADD

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
@Test
public void testSerializationModificationADD() throws ClassNotFoundException, IOException,
    LdapInvalidAttributeValueException
{
    Attribute attribute = new DefaultAttribute( "cn", cnAT );
    attribute.add( "test1", "test2" );

    DefaultModification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );

    Modification modSer = deserializeValue( serializeValue( mod ) );

    assertEquals( mod, modSer );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:14,代码来源:SchemaAwareModificationSerializationTest.java


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