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