exampleSearch = ( ISearch ) search.clone();
exampleSearch.setName( null );
}
else if ( obj instanceof IEntry )
{
IEntry entry = ( IEntry ) obj;
exampleSearch.setConnection( entry.getConnection() );
exampleSearch.setSearchBase( entry.getDn() );
}
else if ( obj instanceof ISearchResult )
{
ISearchResult searchResult = ( ISearchResult ) obj;
exampleSearch.setConnection( searchResult.getEntry().getConnection() );
exampleSearch.setSearchBase( searchResult.getEntry().getDn() );
}
else if ( obj instanceof IBookmark )
{
IBookmark bookmark = ( IBookmark ) obj;
exampleSearch.setConnection( bookmark.getConnection() );
exampleSearch.setSearchBase( bookmark.getDn() );
}
else if ( obj instanceof AttributeHierarchy || obj instanceof IAttribute || obj instanceof IValue )
{
IEntry entry = null;
Set<String> filterSet = new LinkedHashSet<String>();
for ( int i = 0; i < objects.length; i++ )
{
Object object = objects[i];
if ( object instanceof AttributeHierarchy )
{
AttributeHierarchy ah = ( AttributeHierarchy ) object;
for ( Iterator it = ah.iterator(); it.hasNext(); )
{
IAttribute attribute = ( IAttribute ) it.next();
entry = attribute.getEntry();
IValue[] values = attribute.getValues();
for ( int v = 0; v < values.length; v++ )
{
filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
}
}
}
else if ( object instanceof IAttribute )
{
IAttribute attribute = ( IAttribute ) object;
entry = attribute.getEntry();
IValue[] values = attribute.getValues();
for ( int v = 0; v < values.length; v++ )
{
filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
}
}
else if ( object instanceof IValue )
{
IValue value = ( IValue ) object;
entry = value.getAttribute().getEntry();
filterSet.add( LdapFilterUtils.getFilter( value ) );
}
}
exampleSearch.setConnection( entry.getConnection() );
exampleSearch.setSearchBase( entry.getDn() );
StringBuffer filter = new StringBuffer();
if ( filterSet.size() > 1 )
{
filter.append( "(&" );
for ( Iterator<String> filterIterator = filterSet.iterator(); filterIterator.hasNext(); )