001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2009 Sun Microsystems, Inc.
025 *      Portions Copyright 2014-2015 ForgeRock AS
026 */
027
028package org.opends.server.types;
029
030import java.util.Iterator;
031import java.util.List;
032import java.util.Set;
033
034import org.forgerock.opendj.ldap.ByteString;
035import org.forgerock.opendj.ldap.ConditionResult;
036
037/**
038 * This class defines a collective virtual attribute, which is a
039 * special kind of attribute whose values do not actually exist
040 * in persistent storage but rather are obtained dynamically
041 * from applicable collective attribute subentry.
042 */
043public class CollectiveVirtualAttribute extends AbstractAttribute
044{
045  /** The attribute this collective virtual attribute is based on. */
046  private Attribute attribute;
047
048  /**
049   * Creates a new collective virtual attribute.
050   * @param attribute The attribute this collective
051   *                  virtual attribute is based on.
052   */
053  public CollectiveVirtualAttribute(Attribute attribute) {
054    this.attribute = attribute;
055  }
056
057  /** {@inheritDoc} */
058  @Override
059  public ConditionResult approximatelyEqualTo(ByteString assertionValue) {
060    return attribute.approximatelyEqualTo(assertionValue);
061  }
062
063  /** {@inheritDoc} */
064  @Override
065  public boolean contains(ByteString value) {
066    return attribute.contains(value);
067  }
068
069  /** {@inheritDoc} */
070  @Override
071  public ConditionResult matchesEqualityAssertion(ByteString assertionValue)
072  {
073    return attribute.matchesEqualityAssertion(assertionValue);
074  }
075
076  /** {@inheritDoc} */
077  @Override
078  public AttributeType getAttributeType() {
079    return attribute.getAttributeType();
080  }
081
082  /** {@inheritDoc} */
083  @Override
084  public Set<String> getOptions() {
085    return attribute.getOptions();
086  }
087
088  /** {@inheritDoc} */
089  @Override
090  public ConditionResult greaterThanOrEqualTo(ByteString assertionValue) {
091    return attribute.greaterThanOrEqualTo(assertionValue);
092  }
093
094  /** {@inheritDoc} */
095  @Override
096  public boolean isVirtual() {
097    return true;
098  }
099
100  /** {@inheritDoc} */
101  @Override
102  public Iterator<ByteString> iterator() {
103    return attribute.iterator();
104  }
105
106  /** {@inheritDoc} */
107  @Override
108  public ConditionResult lessThanOrEqualTo(ByteString assertionValue) {
109    return attribute.lessThanOrEqualTo(assertionValue);
110  }
111
112  /** {@inheritDoc} */
113  @Override
114  public ConditionResult matchesSubstring(ByteString subInitial,
115          List<ByteString> subAny, ByteString subFinal) {
116    return attribute.matchesSubstring(subInitial, subAny, subFinal);
117  }
118
119  /** {@inheritDoc} */
120  @Override
121  public int size() {
122    return attribute.size();
123  }
124
125  /** {@inheritDoc} */
126  @Override
127  public int hashCode()
128  {
129    return attribute.hashCode();
130  }
131
132  /** {@inheritDoc} */
133  @Override
134  public void toString(StringBuilder buffer) {
135    attribute.toString(buffer);
136  }
137}