/** * Adds the supplied values for this attribute by encoding them with the supplied transcoder. * * @param <T> type attribute to encode * @param transcoder to encode value with * @param value to encode and add * @throws NullPointerException if value is null */ public <T> void addValue(final ValueTranscoder<T> transcoder, final T... value) { for (T t : value) { if (isBinary()) { attributeValues.add(transcoder.encodeBinaryValue(t)); } else { attributeValues.add(transcoder.encodeStringValue(t)); } } }
/** Removes all the values in this ldap attribute. */ public void clear() { attributeValues.clear(); }
/** * Returns the number of values in this ldap attribute. * * @return number of values in this ldap attribute */ public int size() { return attributeValues.size(); }
/** * Removes the supplied value from the attribute values if it exists. * * @param value to remove */ public void removeBinaryValue(final byte[]... value) { for (byte[] b : value) { attributeValues.remove(b); } }
/** * Removes the supplied value from the attribute values if it exists. * * @param value to remove */ public void removeStringValue(final String... value) { for (String s : value) { attributeValues.remove(s); } }
/** * Adds the supplied byte array as a value for this attribute. * * @param value to add * @throws NullPointerException if value is null */ public void addBinaryValue(final byte[]... value) { for (byte[] b : value) { attributeValues.add(b); } }
/** * Adds the supplied string as a value for this attribute. * * @param value to add * @throws NullPointerException if value is null */ public void addStringValue(final String... value) { for (String s : value) { attributeValues.add(s); } }
/** * Returns whether this ldap attribute contains a value of type byte[]. * * @return whether this ldap attribute contains a value of type byte[] */ public boolean isBinary() { return attributeValues.isType(byte[].class); }
/** * Returns the values of this attribute as byte arrays. String data is UTF-8 encoded. The return * collection cannot be modified. * * @return collection of byte array attribute values */ public Collection<byte[]> getBinaryValues() { return attributeValues.getBinaryValues(); }
/** * Returns the values of this attribute as strings. Binary data is base64 encoded. The return * collection cannot be modified. * * @return collection of string attribute values */ public Collection<String> getStringValues() { return attributeValues.getStringValues(); }