Code example for SearchControls

Methods: setCountLimitsetSearchScope

0
     * @throws EncoderException on codec failures 
     */ 
    private SearchControls createSearchControls( DirContext ctx, int sizeLimit, int pagedSize )
        throws NamingException, EncoderException
    { 
        SearchControls controls = new SearchControls();
        controls.setCountLimit( sizeLimit );
        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
        PagedResultsDecorator pagedSearchControl = new PagedResultsDecorator( codec );
        pagedSearchControl.setSize( pagedSize );
 
        ( ( LdapContext ) ctx ).setRequestControls( JndiUtils.toJndiControls( codec, new Control[]
            { pagedSearchControl } ) ); 
 
        return controls;
    } 
 
 
    /** 
     * Create the searchControls with a paged size