/** * Returns the number of attributes in this set. * * @see <a href="../../../../api/com/novell/ldap/LDAPAttributeSet.html#size()"> com.novell.ldap.LDAPAttributeSet.size()</a> */ public int size() { return attrSet.size(); }
/** * Returns an array containing all the elements in this set. */ public Object[] toArray() { LDAPAttribute[] attrs = new LDAPAttribute[attrSet.size()]; return toArray(attrs); }
/** * Returns an array containing all the elements in this set. * * <p>The runtime type of the returned array is that of the specified * </p>array. */ public Object[] toArray( Object[] a) { // Throw ClassCastException if wrong type LDAPAttribute[] newAttrs = (LDAPAttribute[])a; com.novell.ldap.LDAPAttribute[] oldAttrs; oldAttrs = (com.novell.ldap.LDAPAttribute[])attrSet.toArray( new com.novell.ldap.LDAPAttribute[attrSet.size()]); int length = oldAttrs.length; if( newAttrs.length < length) { newAttrs = (LDAPAttribute[])java.lang.reflect.Array.newInstance( a.getClass().getComponentType(), length); } int i = 0; for( i = 0; i < length; i++) { newAttrs[i] = new LDAPAttribute(oldAttrs[i]); } if( newAttrs.length > length) { newAttrs[i] = null; } return newAttrs; }
/** * Build the attribuite list from an LDAPEntry. * * @param entry The LDAPEntry associated with this add request. */ private static final RfcAttributeList makeRfcAttrList( LDAPEntry entry) { // convert Java-API LDAPEntry to RFC2251 AttributeList LDAPAttributeSet attrSet = entry.getAttributeSet(); RfcAttributeList attrList = new RfcAttributeList(attrSet.size()); Iterator itr = attrSet.iterator(); while (itr.hasNext()) { LDAPAttribute attr = (LDAPAttribute)itr.next(); ASN1SetOf vals = new ASN1SetOf(attr.size()); Enumeration attrEnum = attr.getByteValues(); while(attrEnum.hasMoreElements()) { vals.add(new RfcAttributeValue((byte[])attrEnum.nextElement())); } attrList.add(new RfcAttributeTypeAndValues( new RfcAttributeDescription(attr.getName()), vals)); } return attrList; }