/** * Creates a new ldap attribute values. * * @param t type of values * * @throws IllegalArgumentException if t is not a String or byte[] */ public LdapAttributeValues(final Class<T> t) { if (!(t.isAssignableFrom(String.class) || t.isAssignableFrom(byte[].class))) { throw new IllegalArgumentException("Only String and byte[] values are supported"); } type = t; values = createSortBehaviorCollection(type); }
/** * Base64 encodes the supplied collection of values. * * @param v values to encode * * @return collection of string values */ protected Collection<String> convertValuesToString(final Collection<byte[]> v) { final Collection<String> c = createSortBehaviorCollection(String.class); c.addAll(v.stream().map(LdapUtils::base64Encode).collect(Collectors.toList())); return c; }
/** * Creates a new ldap attribute values. * * @param t type of values * * @throws IllegalArgumentException if t is not a String or byte[] */ LdapAttributeValues(final Class<T> t) { if (!(t.isAssignableFrom(String.class) || t.isAssignableFrom(byte[].class))) { throw new IllegalArgumentException("Only String and byte[] values are supported"); } type = t; values = createSortBehaviorCollection(type); }
/** * Creates a new ldap attribute values. * * @param t type of values * * @throws IllegalArgumentException if t is not a String or byte[] */ LdapAttributeValues(final Class<T> t) { if (!(t.isAssignableFrom(String.class) || t.isAssignableFrom(byte[].class))) { throw new IllegalArgumentException("Only String and byte[] values are supported"); } type = t; values = createSortBehaviorCollection(type); }
/** * Base64 encodes the supplied collection of values. * * @param v values to encode * * @return collection of string values */ protected Collection<String> convertValuesToString(final Collection<byte[]> v) { final Collection<String> c = createSortBehaviorCollection(String.class); c.addAll(v.stream().map(LdapUtils::base64Encode).collect(Collectors.toList())); return c; }
/** * UTF-8 encodes the supplied collection of values. * * @param v values to encode * * @return collection of byte array values */ protected Collection<byte[]> convertValuesToByteArray(final Collection<String> v) { final Collection<byte[]> c = createSortBehaviorCollection(byte[].class); c.addAll(v.stream().map(LdapUtils::utf8Encode).collect(Collectors.toList())); return c; } }
/** * UTF-8 encodes the supplied collection of values. * * @param v values to encode * * @return collection of byte array values */ protected Collection<byte[]> convertValuesToByteArray(final Collection<String> v) { final Collection<byte[]> c = createSortBehaviorCollection(byte[].class); c.addAll(v.stream().map(LdapUtils::utf8Encode).collect(Collectors.toList())); return c; } }
/** * Base64 encodes the supplied collection of values. * * @param v values to encode * * @return collection of string values */ protected Collection<String> convertValuesToString(final Collection<byte[]> v) { final Collection<String> c = createSortBehaviorCollection(String.class); for (byte[] value : v) { c.add(LdapUtils.base64Encode(value)); } return c; }
/** * UTF-8 encodes the supplied collection of values. * * @param v values to encode * * @return collection of byte array values */ protected Collection<byte[]> convertValuesToByteArray(final Collection<String> v) { final Collection<byte[]> c = createSortBehaviorCollection(byte[].class); for (String value : v) { c.add(LdapUtils.utf8Encode(value)); } return c; } }
/** * Returns the values of this attribute decoded by the supplied transcoder. * * @param <T> type of decoded attributes * @param transcoder to decode attribute values with * * @return collection of decoded attribute values */ public <T> Collection<T> getValues(final ValueTranscoder<T> transcoder) { final Collection<T> values = createSortBehaviorCollection(transcoder.getType()); if (isBinary()) { values.addAll(getBinaryValues().stream().map(transcoder::decodeBinaryValue).collect(Collectors.toList())); } else { values.addAll(getStringValues().stream().map(transcoder::decodeStringValue).collect(Collectors.toList())); } return values; }
/** * Returns the values of this attribute decoded by the supplied transcoder. * * @param <T> type of decoded attributes * @param transcoder to decode attribute values with * * @return collection of decoded attribute values */ public <T> Collection<T> getValues(final ValueTranscoder<T> transcoder) { final Collection<T> values = createSortBehaviorCollection(transcoder.getType()); if (isBinary()) { values.addAll(getBinaryValues().stream().map(transcoder::decodeBinaryValue).collect(Collectors.toList())); } else { values.addAll(getStringValues().stream().map(transcoder::decodeStringValue).collect(Collectors.toList())); } return values; }
/** * Returns the values of this attribute decoded by the supplied transcoder. * * @param <T> type of decoded attributes * @param transcoder to decode attribute values with * * @return collection of decoded attribute values */ public <T> Collection<T> getValues(final ValueTranscoder<T> transcoder) { final Collection<T> values = createSortBehaviorCollection(transcoder.getType()); if (isBinary()) { for (byte[] b : getBinaryValues()) { values.add(transcoder.decodeBinaryValue(b)); } } else { for (String s : getStringValues()) { values.add(transcoder.decodeStringValue(s)); } } return values; }