| | |
| | | import java.util.List; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RawAttribute; |
| | | |
| | | import org.opends.server.types.*; |
| | | |
| | | |
| | | /** |
| | |
| | | extends RawAttribute |
| | | { |
| | | // The set of values for this attribute. |
| | | private ArrayList<ASN1OctetString> values; |
| | | private ArrayList<ByteString> values; |
| | | |
| | | // The attribute type for this attribute. |
| | | private String attributeType; |
| | |
| | | { |
| | | this.attributeType = attributeType; |
| | | |
| | | values = new ArrayList<ASN1OctetString>(0); |
| | | values = new ArrayList<ByteString>(0); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.attributeType = attributeType; |
| | | |
| | | values = new ArrayList<ASN1OctetString>(1); |
| | | values.add(new ASN1OctetString(value)); |
| | | values = new ArrayList<ByteString>(1); |
| | | values.add(ByteString.valueOf(value)); |
| | | } |
| | | |
| | | |
| | |
| | | * @param attributeType The attribute type for this attribute. |
| | | * @param value The value to use for this attribute. |
| | | */ |
| | | public LDAPAttribute(String attributeType, ASN1OctetString value) |
| | | public LDAPAttribute(String attributeType, ByteString value) |
| | | { |
| | | this.attributeType = attributeType; |
| | | |
| | | values = new ArrayList<ASN1OctetString>(1); |
| | | values = new ArrayList<ByteString>(1); |
| | | values.add(value); |
| | | } |
| | | |
| | |
| | | |
| | | if (values == null) |
| | | { |
| | | this.values = new ArrayList<ASN1OctetString>(0); |
| | | this.values = new ArrayList<ByteString>(0); |
| | | } |
| | | else |
| | | { |
| | | this.values = new ArrayList<ASN1OctetString>(values.size()); |
| | | this.values = new ArrayList<ByteString>(values.size()); |
| | | for (String value : values) |
| | | { |
| | | this.values.add(new ASN1OctetString(value)); |
| | | this.values.add(ByteString.valueOf(value)); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param attributeType The attribute type for this attribute. |
| | | * @param values The set of values for this attribute. |
| | | */ |
| | | public LDAPAttribute(String attributeType, ArrayList<ASN1OctetString> values) |
| | | public LDAPAttribute(String attributeType, ArrayList<ByteString> values) |
| | | { |
| | | this.attributeType = attributeType; |
| | | |
| | | if (values == null) |
| | | { |
| | | this.values = new ArrayList<ASN1OctetString>(0); |
| | | this.values = new ArrayList<ByteString>(0); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | if (attribute.isEmpty()) |
| | | { |
| | | values = new ArrayList<ASN1OctetString>(0); |
| | | values = new ArrayList<ByteString>(0); |
| | | return; |
| | | } |
| | | |
| | | values = new ArrayList<ASN1OctetString>(attribute.size()); |
| | | values = new ArrayList<ByteString>(attribute.size()); |
| | | for (AttributeValue v : attribute) |
| | | { |
| | | values.add(v.getValue().toASN1OctetString()); |
| | | values.add(v.getValue()); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The set of values for this attribute. |
| | | */ |
| | | public ArrayList<ASN1OctetString> getValues() |
| | | public ArrayList<ByteString> getValues() |
| | | { |
| | | return values; |
| | | } |
| | |
| | | } |
| | | |
| | | AttributeType attrType = builder.getAttributeType(); |
| | | for (ASN1OctetString value : values) |
| | | for (ByteString value : values) |
| | | { |
| | | if (!builder.add(new AttributeValue(attrType, value))) |
| | | if (!builder.add( |
| | | AttributeValues.create(attrType, value))) |
| | | { |
| | | Message message = |
| | | ERR_LDAP_ATTRIBUTE_DUPLICATE_VALUES.get(attributeType); |
| | |
| | | |
| | | if (! values.isEmpty()) |
| | | { |
| | | Iterator<ASN1OctetString> iterator = values.iterator(); |
| | | iterator.next().toString(buffer); |
| | | Iterator<ByteString> iterator = values.iterator(); |
| | | buffer.append(iterator.next()); |
| | | while (iterator.hasNext()) |
| | | { |
| | | buffer.append(", "); |
| | | iterator.next().toString(buffer); |
| | | buffer.append(iterator.next()); |
| | | } |
| | | } |
| | | |
| | |
| | | buffer.append(" Attribute Values:"); |
| | | buffer.append(EOL); |
| | | |
| | | for (ASN1OctetString value : values) |
| | | for (ByteString value : values) |
| | | { |
| | | value.toString(buffer, indent+4); |
| | | value.toHexPlusAscii(buffer, indent+4); |
| | | } |
| | | } |
| | | } |