| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean addAttribute(final Attribute attribute) { |
| | | return addAttribute(attribute, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Entry addAttribute(final String attributeDescription, final Object... values) { |
| | | addAttribute(new LinkedAttribute(attributeDescription, values), null); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean containsAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> missingValues) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean containsAttribute(final String attributeDescription, final Object... values) { |
| | | return containsAttribute(new LinkedAttribute(attributeDescription, values), null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean equals(final Object object) { |
| | | if (this == object) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Iterable<Attribute> getAllAttributes(final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | |
| | | attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Iterable<Attribute> getAllAttributes(final String attributeDescription) { |
| | | return getAllAttributes(AttributeDescription.valueOf(attributeDescription)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Attribute getAttribute(final AttributeDescription attributeDescription) { |
| | | for (final Attribute attribute : getAllAttributes()) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Attribute getAttribute(final String attributeDescription) { |
| | | return getAttribute(AttributeDescription.valueOf(attributeDescription)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int hashCode() { |
| | | int hashCode = this.getName().hashCode(); |
| | |
| | | return hashCode; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AttributeParser parseAttribute(final AttributeDescription attributeDescription) { |
| | | return AttributeParser.parseAttribute(getAttribute(attributeDescription)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AttributeParser parseAttribute(final String attributeDescription) { |
| | | return AttributeParser.parseAttribute(getAttribute(attributeDescription)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean removeAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> missingValues) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean removeAttribute(final AttributeDescription attributeDescription) { |
| | | return removeAttribute(Attributes.emptyAttribute(attributeDescription), null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Entry removeAttribute(final String attributeDescription, final Object... values) { |
| | | removeAttribute(new LinkedAttribute(attributeDescription, values), null); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean replaceAttribute(final Attribute attribute) { |
| | | if (attribute.isEmpty()) { |
| | | return removeAttribute(attribute.getAttributeDescription()); |
| | | } else { |
| | | // For consistency with addAttribute and removeAttribute, preserve |
| | | // the existing attribute if it already exists. |
| | | /* |
| | | * For consistency with addAttribute and removeAttribute, preserve |
| | | * the existing attribute if it already exists. |
| | | */ |
| | | final Attribute oldAttribute = getAttribute(attribute.getAttributeDescription()); |
| | | if (oldAttribute != null) { |
| | | oldAttribute.clear(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Entry replaceAttribute(final String attributeDescription, final Object... values) { |
| | | replaceAttribute(new LinkedAttribute(attributeDescription, values)); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Entry setName(final String dn) { |
| | | return setName(DN.valueOf(dn)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | | builder.append("Entry("); |
| | | builder.append('"'); |
| | | builder.append(this.getName()); |
| | | builder.append(", {"); |
| | | builder.append("\":{"); |
| | | boolean firstValue = true; |
| | | for (final Attribute attribute : this.getAllAttributes()) { |
| | | if (!firstValue) { |
| | | builder.append(", "); |
| | | builder.append(','); |
| | | } |
| | | |
| | | builder.append(attribute); |
| | | firstValue = false; |
| | | } |
| | | builder.append("})"); |
| | | builder.append('}'); |
| | | return builder.toString(); |
| | | } |
| | | |