本文整理汇总了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;
}
示例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;
}
示例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();
}