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


Java Attribute.size方法代码示例

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


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

示例1: getStrings

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Create a list of string from a multivalued attribute's values
 */
private List<String> getStrings( Attribute attr )
{
    if ( attr == null )
    {
        return EMPTY_LIST;
    }

    List<String> strings = new ArrayList<>( attr.size() );

    for ( Value value : attr )
    {
        strings.add( value.getValue() );
    }

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

示例2: isApacheDs

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Indicates if the given Root DSE corresponds to an ApacheDS server.
 *
 * @param rootDse the Root DSE
 * @return <code>true</code> if this is an ApacheDS server,
 *         <code>false</code> if not.
 * @throws LdapInvalidAttributeValueException
 */
private boolean isApacheDs( Entry rootDse ) throws LdapInvalidAttributeValueException
{
    if ( rootDse != null )
    {
        Attribute vendorNameAttribute = rootDse.get( SchemaConstants.VENDOR_NAME_AT );

        if ( ( vendorNameAttribute != null ) && vendorNameAttribute.size() == 1 )
        {
            return DEFAULT_APACHEDS_VENDOR_NAME.equalsIgnoreCase( vendorNameAttribute.getString() );
        }
    }

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

示例3: convertToLdif

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Converts an EntryAttribute as LDIF
 * 
 * @param attr the EntryAttribute to convert
 * @param length the expected line length
 * @return the corresponding LDIF code as a String
 * @throws LdapException If a naming exception is encountered.
 */
public static String convertToLdif( Attribute attr, int length ) throws LdapException
{
    StringBuilder sb = new StringBuilder();
    
    if ( attr.size() == 0 )
    {
        // Special case : we don't have any value
        return "";
    }

    for ( Value value : attr )
    {
        StringBuilder lineBuffer = new StringBuilder();

        lineBuffer.append( attr.getUpId() );

        // First, deal with null value (which is valid)
        if ( value.isNull() )
        {
            lineBuffer.append( ':' );
        }
        else if ( value.isHumanReadable() )
        {
            // It's a String but, we have to check if encoding isn't required
            String str = value.getValue();

            if ( !LdifUtils.isLDIFSafe( str ) )
            {
                lineBuffer.append( ":: " ).append( encodeBase64( str ) );
            }
            else
            {
                lineBuffer.append( ':' );

                if ( str != null )
                {
                    lineBuffer.append( ' ' ).append( str );
                }
            }
        }
        else
        {
            // It is binary, so we have to encode it using Base64 before adding it
            char[] encoded = Base64.encode( value.getBytes() );

            lineBuffer.append( ":: " + new String( encoded ) );
        }

        lineBuffer.append( '\n' );
        sb.append( stripLineToNChars( lineBuffer.toString(), length ) );
    }

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


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