isVirtualAttributesOnly(), isRealAttributesOnly());
// If there is a matched values control, then further pare down the entry
// based on the filters that it contains.
MatchedValuesControl matchedValuesControl = getMatchedValuesControl();
if ((matchedValuesControl != null) && (! typesOnly))
{
// First, look at the set of objectclasses.
// NOTE: the objectClass attribute is also present and must be
// dealt with later.
AttributeType attrType = DirectoryServer.getObjectClassAttributeType();
Iterator<String> ocIterator =
entryToReturn.getObjectClasses().values().iterator();
while (ocIterator.hasNext())
{
String ocName = ocIterator.next();
AttributeValue v =
AttributeValues.create(attrType,ocName);
if (! matchedValuesControl.valueMatches(attrType, v))
{
ocIterator.remove();
}
}
// Next, the set of user attributes (incl. objectClass attribute).
for (Map.Entry<AttributeType, List<Attribute>> e : entryToReturn
.getUserAttributes().entrySet())
{
AttributeType t = e.getKey();
List<Attribute> oldAttributes = e.getValue();
List<Attribute> newAttributes =
new ArrayList<Attribute>(oldAttributes.size());
for (Attribute a : oldAttributes)
{
// Assume that the attribute will be either empty or contain
// very few values.
AttributeBuilder builder = new AttributeBuilder(a, true);
for (AttributeValue v : a)
{
if (matchedValuesControl.valueMatches(t, v))
{
builder.add(v);
}
}
newAttributes.add(builder.toAttribute());
}
e.setValue(newAttributes);
}
// Then the set of operational attributes.
for (Map.Entry<AttributeType, List<Attribute>> e : entryToReturn
.getOperationalAttributes().entrySet())
{
AttributeType t = e.getKey();
List<Attribute> oldAttributes = e.getValue();
List<Attribute> newAttributes =
new ArrayList<Attribute>(oldAttributes.size());
for (Attribute a : oldAttributes)
{
// Assume that the attribute will be either empty or contain
// very few values.
AttributeBuilder builder = new AttributeBuilder(a, true);
for (AttributeValue v : a)
{
if (matchedValuesControl.valueMatches(t, v))
{
builder.add(v);
}
}
newAttributes.add(builder.toAttribute());