/** * Adds the specified attribute to this attribute set. * * @see <a href="../../../../api/com/novell/ldap/LDAPAttributeSet.html#add(java.lang.Object)"> com.novell.ldap.LDAPAttributeSet.add(Object)</a> */ public boolean add(Object attr) { com.novell.ldap.LDAPAttribute a; a = ((org.ietf.ldap.LDAPAttribute)attr).getWrappedObject(); return attrSet.add( a); }
/** * Adds all <code>LDAPAttribute</code> objects in the specified collection to * this collection. * * @param c Collection of <code>LDAPAttribute</code> objects. * * @throws ClassCastException occurs when an element in the * collection is not of type <code>LDAPAttribute</code>. * * @return true if this set changed as a result of the call. */ public boolean addAll(java.util.Collection c){ boolean setChanged = false; Iterator i = c.iterator(); while (i.hasNext()){ // we must enforce that everything in c is an LDAPAttribute // add will return true if the attribute was added if (this.add( i.next() )){ setChanged = true; } } return setChanged; }
/** * Returns a deep copy of this attribute set. * * @return A deep copy of this attribute set. */ public Object clone() { try { Object newObj = super.clone(); ((LDAPAttributeSet)newObj).clear(); Iterator i = this.iterator(); while (i.hasNext()){ ((LDAPAttributeSet)newObj).add( ((LDAPAttribute)i.next()).clone()); } return newObj; } catch( CloneNotSupportedException ce) { throw new RuntimeException("Internal error, cannot create clone"); } }
this.add( ((LDAPAttribute)i.next()).clone());
tempAttributeSet.add(attr.clone());
attrSet.add(new LDAPAttribute(attrName));
attrSet.add(attr);
/** * Constructs an LDAPEntry that represents the add request * * @return an LDAPEntry that represents the add request. */ public LDAPEntry getEntry() { RfcAddRequest addreq = (RfcAddRequest)getASN1Object().getRequest(); LDAPAttributeSet attrs = new LDAPAttributeSet(); // Build the list of attributes ASN1Object[] seqArray = addreq.getAttributes().toArray(); for(int i = 0; i < seqArray.length; i++) { RfcAttributeTypeAndValues seq = (RfcAttributeTypeAndValues)seqArray[i]; LDAPAttribute attr = new LDAPAttribute(((ASN1OctetString)seq.get(0)).stringValue()); // Add the values to the attribute ASN1SetOf set = (ASN1SetOf)seq.get(1); Object[] setArray = set.toArray(); for(int j = 0; j < setArray.length; j++) { attr.addValue(((ASN1OctetString)setArray[j]).byteValue()); } attrs.add(attr); } return new LDAPEntry( getASN1Object().getRequestDN(), attrs); }
/** * Returns the entry of a server's search response. * * @return The LDAPEntry associated with this LDAPSearchResult */ public LDAPEntry getEntry() { if( entry == null) { LDAPAttributeSet attrs = new LDAPAttributeSet(); ASN1Sequence attrList = ((RfcSearchResultEntry)message.getResponse()).getAttributes(); ASN1Object[] seqArray = attrList.toArray(); for(int i = 0; i < seqArray.length; i++) { ASN1Sequence seq = (ASN1Sequence)seqArray[i]; LDAPAttribute attr = new LDAPAttribute(((ASN1OctetString)seq.get(0)).stringValue()); ASN1Set set = (ASN1Set)seq.get(1); Object[] setArray = set.toArray(); for(int j = 0; j < setArray.length; j++) { attr.addValue(((ASN1OctetString)setArray[j]).byteValue()); } attrs.add(attr); } entry = new LDAPEntry( ((RfcSearchResultEntry)message.getResponse()).getObjectName().stringValue(), attrs); } return entry; }