SearchResultEntryProtocolOp.java revision f4d85fde4c95d5f49f683641815e0463d6166720
/*
* 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
*
*
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
/**
* This class defines the structures and methods for an LDAP search result entry
* protocol op, which is used to return entries that match the associated search
* criteria.
*/
public class SearchResultEntryProtocolOp
extends ProtocolOp
{
// The set of attributes for this search entry.
// The DN for this search entry.
/**
* Creates a new LDAP search result entry protocol op with the specified DN
* and no attributes.
*
* @param dn The DN for this search result entry.
*/
{
}
/**
* Creates a new LDAP search result entry protocol op with the specified DN
* and set of attributes.
*
* @param dn The DN for this search result entry.
* @param attributes The set of attributes for this search result entry.
*/
{
if (attributes == null)
{
}
else
{
this.attributes = attributes;
}
}
/**
* Creates a new search result entry protocol op from the provided search
* result entry.
*
* @param searchEntry The search result entry object to use to create this
* search result entry protocol op.
*/
{
{
}
{
{
}
}
{
{
}
}
}
/**
* Retrieves the DN for this search result entry.
*
* @return The DN for this search result entry.
*/
{
return dn;
}
/**
* Specifies the DN for this search result entry.
*
* @param dn The DN for this search result entry.
*/
{
}
/**
* Retrieves the set of attributes for this search result entry. The returned
* list may be altered by the caller.
*
* @return The set of attributes for this search result entry.
*/
{
return attributes;
}
/**
* Retrieves the BER type for this protocol op.
*
* @return The BER type for this protocol op.
*/
public byte getType()
{
return OP_TYPE_SEARCH_RESULT_ENTRY;
}
/**
* Retrieves the name for this protocol op type.
*
* @return The name for this protocol op type.
*/
public String getProtocolOpName()
{
return "Search Result Entry";
}
/**
* Encodes this protocol op to an ASN.1 element suitable for including in an
* LDAP message.
*
* @return The ASN.1 element containing the encoded protocol op.
*/
public ASN1Element encode()
{
{
}
}
/**
* Decodes the provided ASN.1 element as an LDAP search result entry protocol
* op.
*
* @param element The ASN.1 element to be decoded.
*
* @return The decoded search result entry protocol op.
*
* @throws LDAPException If a problem occurs while decoding the provided
* ASN.1 element as an LDAP search result entry
* protocol op.
*/
throws LDAPException
{
try
{
}
catch (Exception e)
{
if (debugEnabled())
{
}
}
if (numElements != 2)
{
}
try
{
}
catch (Exception e)
{
if (debugEnabled())
{
}
}
try
{
for (ASN1Element e : attrElements)
{
}
}
catch (Exception e)
{
if (debugEnabled())
{
}
}
}
/**
* Appends a string representation of this LDAP protocol op to the provided
* buffer.
*
* @param buffer The buffer to which the string should be appended.
*/
{
if (! attributes.isEmpty())
{
{
}
}
}
/**
* Appends a multi-line string representation of this LDAP protocol op to the
* provided buffer.
*
* @param buffer The buffer to which the information should be appended.
* @param indent The number of spaces from the margin that the lines should
* be indented.
*/
{
for (int i=0 ; i < indent; i++)
{
}
{
}
}
/**
* Appends an LDIF representation of the entry to the provided buffer.
*
* @param buffer The buffer to which the entry should be appended.
* @param wrapColumn The column at which long lines should be wrapped.
*/
{
// Add the DN to the buffer.
int colsRemaining;
if (needsBase64Encoding(dnString))
{
}
else
{
}
{
}
else
{
int startPos = colsRemaining;
{
}
{
}
}
// Add the attributes to the buffer.
for (LDAPAttribute a : attributes)
{
for (ASN1OctetString v : a.getValues())
{
if (needsBase64Encoding(v.value()))
{
}
else
{
valueString = v.stringValue();
}
{
}
else
{
int startPos = colsRemaining;
{
}
if (startPos < valueLength)
{
}
}
}
}
// Make sure to add an extra blank line to ensure that there will be one
// between this entry and the next.
}
/**
* Converts this protocol op to a search result entry.
*
* @return The search result entry created from this protocol op.
*
* @throws LDAPException If a problem occurs while trying to create the
* search result entry.
*/
public SearchResultEntry toSearchResultEntry()
throws LDAPException
{
for (LDAPAttribute a : attributes)
{
if (attrType.isObjectClassType())
{
{
{
}
}
}
else if (attrType.isOperational())
{
{
}
else
{
}
}
else
{
{
}
else
{
// Check to see if any of the existing attributes in the list have the
// same set of options. If so, then add the values to that attribute.
boolean attributeSeen = false;
{
{
attributeSeen = true;
}
}
if (!attributeSeen)
{
// This is the first occurrence of the attribute and options.
}
}
}
}
return new SearchResultEntry(entry);
}
}