/** * * Creates a new instance of ClientModification. * * @param operation The modification operation * @param attribute The asociated attribute */ public ClientModification( int operation, EntryAttribute attribute ) { setOperation( operation ); this.attribute = attribute; }
/** * Creates an AddRequest implementation to create a new entry. * * @param id * the sequence identifier of the AddRequest message. */ public AddRequestImpl(final int id) { super( id, TYPE ); entry = new DefaultClientEntry(); }
/** * Add a new attributeTypeAndValue * * @param type The attribute's name */ public void addAttributeTypeAndValues( String type ) { currentAttribute = new DefaultClientAttribute( type ); Modification modification = new ClientModification( currentOperation, currentAttribute ); modifications.add( modification ); }
/** * Add an attribute to the attributes list. * * @param attribute The attribute to add to the list */ public void addAttribute( String attribute ) { attributes.add( new DefaultClientAttribute( attribute ) ); }
/** * <p> * Put an attribute (represented by its ID and some binary values) into an entry. * </p> * <p> * If the attribute already exists, the previous attribute will be * replaced and returned. * </p> * * @param upId The attribute ID * @param values The list of binary values to put. It can be empty. * @return The replaced attribute */ public EntryAttribute put( String upId, byte[]... values ) { // Get the normalized form of the ID String id = getId( upId ); // Create a new attribute EntryAttribute clientAttribute = new DefaultClientAttribute( upId, values ); // Replace the previous one, and return it back return attributes.put( id, clientAttribute ); }
/** * Convert the current ServerModification to a ClientModification instance * * @return a new ClientModification instance */ public Modification toClientModification() { ModificationOperation newOperation = operation; EntryAttribute newAttribute = attribute.toClientAttribute(); Modification newModification = new ClientModification( newOperation, newAttribute ); return newModification; }
/** * Create a new instance of a EntryAttribute, without value. */ public DefaultClientAttribute( String upId ) { setUpId( upId ); }
/** * Tells if an entry has a specific ObjectClass value * * @param objectClass The ObjectClass we want to check * @return <code>true</code> if the ObjectClass value is present * in the ObjectClass attribute */ public boolean hasObjectClass( String objectClass ) { return contains( "objectclass", objectClass ); }
/** * Clone an attribute. All the element are duplicated, so a modification on * the original object won't affect the cloned object, as a modification * on the cloned object has no impact on the original object * * @return a clone of the current attribute */ public EntryAttribute clone() { // clone the structure by cloner the inherited class EntryAttribute clone = (EntryAttribute)super.clone(); // We are done ! return clone; }
/** * Returns an iterator over all the attribute's values. * <p> * The effect on the returned enumeration of adding or removing values of * the attribute is not specified. * </p> * <p> * This method will throw any <code>LdapException</code> that occurs. * </p> * * @return an enumeration of all values of the attribute */ public Iterator<Value<?>> getAll() { return iterator(); }
/** * Creates a new instance of DefaultServerEntry, with a * DN and a list of IDs. * * @param dn The DN for this serverEntry. Can be null. * @param upIds The list of attributes to create. */ public DefaultClientEntry( DN dn, String... upIds ) { this.dn = dn; for ( String upId:upIds ) { // Add a new AttributeType without value set( upId ); } }
/** * Checks if an entry contains a specific attribute * * @param attributes The Attributes to look for * @return <code>true</code> if the attributes are found within the entry * @throws LdapException If the attribute does not exist */ public boolean contains( String upId ) throws LdapException { String id = getId( upId ); return attributes.containsKey( id ); }
private void addModification( ModificationOperation modOp, String attributeName, String... attributeValue ) { EntryAttribute attr = new DefaultClientAttribute( attributeName, attributeValue ); addModification( attr, modOp ); }
/** * <p> * Put an attribute (represented by its ID and some values) into an entry. * </p> * <p> * If the attribute already exists, the previous attribute will be * replaced and returned. * </p> * * @param upId The attribute ID * @param values The list of values to put. It can be empty. * @return The replaced attribute */ public EntryAttribute put( String upId, Value<?>... values ) { // Get the normalized form of the ID String id = getId( upId ); // Create a new attribute EntryAttribute clientAttribute = new DefaultClientAttribute( upId, values ); // Replace the previous one, and return it back return attributes.put( id, clientAttribute ); }
/** * Creates a new AddRequest object. */ public AddRequestCodec() { super(); entry = new DefaultClientEntry(); }
/** * Set the user provided ID. It will also set the ID, normalizing * the upId (removing spaces before and after, and lowercasing it)<br> * <br> * If the Attribute already has an AttributeType, then the upId must * be either the AttributeType name, or OID * * @param upId The attribute ID * @throws IllegalArgumentException If the ID is empty or null or * resolve to an empty value after being trimmed */ public void setUpId( String upId ) { setUpId( upId, null ); }
private void addModification( ModificationOperation modOp, String attributeName, byte[]... attributeValue ) { EntryAttribute attr = new DefaultClientAttribute( attributeName, attributeValue ); addModification( attr, modOp ); }
/** * Initialize the Entry. */ public void initEntry() { entry = new DefaultClientEntry(); }