/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011 ForgeRock AS
*/
/**
* This is a commodity class used to wrap the SearchResult class of JNDI.
* Basically it retrieves all the attributes and values on the SearchResult and
* calculates its DN. Using it we avoid having to handle the NamingException
* exceptions that most of the methods in SearchResult throw.
*
*/
{
private int hashCode;
/**
* Constructor of an empty search result. This constructor is used by the
* LDAP entry editor which 'build' their own CustomSearchResult. The entry
* editors use some methods that require CustomSearchResult.
* @param dn the dn of the entry.
*/
{
}
/**
* Constructor of a search result using a SearchResult as basis.
* @param sr the SearchResult.
* @param baseDN the base DN of the search that returned the SearchResult.
* @throws NamingException if there is an error retrieving the attribute
* values.
*/
throws NamingException
{
{
{
}
else {
}
}
else {
}
{
{
}
{
}
}
{
try
{
{
{
}
}
}
}
finally
{
}
}
}
/**
* Returns the DN of the entry.
* @return the DN of the entry.
*/
return dn;
}
/**
* Returns the values for a given attribute. It returns an empty Set if
* the attribute is not defined.
* @param name the name of the attribute.
* @return the values for a given attribute. It returns an empty Set if
* the attribute is not defined.
*/
{
}
return values;
}
/**
* Returns all the attribute names of the entry.
* @return the attribute names of the entry.
*/
return attrNames;
}
/**
* {@inheritDoc}
*/
int compareTo;
if (this.equals(o))
{
compareTo = 0;
}
else
{
}
return compareTo;
}
/**
* {@inheritDoc}
*/
{
return sr;
}
/**
* {@inheritDoc}
*/
{
boolean equals = false;
if (o != null)
{
equals = o == this;
if (!equals && (o instanceof CustomSearchResult))
{
if (equals)
{
if (equals)
{
{
if (!equals)
{
break;
}
}
}
}
}
}
return equals;
}
/**
* {@inheritDoc}
*/
return toString;
}
/**
* {@inheritDoc}
*/
public int hashCode() {
return hashCode;
}
/**
* Sets the values for a given attribute name.
* @param attrName the name of the attribute.
* @param values the values for the attribute.
*/
{
}
{
}
private int calculateHashCode()
{
}
/**
* Gets the Entry object equivalent to this CustomSearchResult.
* The method assumes that the schema in DirectoryServer has been initialized.
* @return the Entry object equivalent to this CustomSearchResult.
* @throws OpenDsException if there is an error parsing the DN or retrieving
* the attributes definition and objectclasses in the schema of the server.
*/
{
{
// See if this is an objectclass or an attribute. Then get the
// corresponding definition and add the value to the appropriate hash.
{
{
if (objectClass == null)
{
}
}
}
else
{
{
}
{
if (value instanceof byte[])
{
}
else
{
}
}
if (attrType.isOperational())
{
}
else
{
}
}
}
}
}