directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DIRAPI-165) Add a FilterBuillder
Date Wed, 28 Jan 2015 16:22:35 GMT

    [ https://issues.apache.org/jira/browse/DIRAPI-165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14295347#comment-14295347
] 

Emmanuel Lecharny commented on DIRAPI-165:
------------------------------------------

The {{startswith()}}  method would looks like that :

{code}
    /**
     * Create a SubstringFilter based on the filter elements. Such a filter
     * has a form like <b>Attribute=initial*([any]*)*</b>. We don't expect any
     * <em>final</em> String.
     *
     * @param attribute The AttributeType for this filter
     * @param parts The parts that are the initial string and zero to N any strings
     * @return An instance of a SubstringFilter
     */
    public static SubstringFilter startswith( String attribute, String... parts )
    {
        if ( ( parts != null ) && ( parts.length > 0 ) )
        {
            if ( parts.length > 1 )
            {
                String[] any = new String[parts.length - 1];
                System.arraycopy( parts, 1, any, 0, any.length );

                return new SubstringFilter( attribute, parts[0], any, null );
            }
            else
            {
                return new SubstringFilter( attribute, parts[0], null, null );
            }
        }
        else
        {
            // This is a presence filter, kind of
            return new SubstringFilter( attribute, null, null, null );
        }
    }
{code}

> Add a FilterBuillder
> --------------------
>
>                 Key: DIRAPI-165
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-165
>             Project: Directory Client API
>          Issue Type: New Feature
>    Affects Versions: 1.0.0-M21
>            Reporter: lucas theisen
>            Priority: Minor
>             Fix For: 1.0.0-M29
>
>
> Looking for something Fluent, in the _spirit_ of Hibernate Criteria.  May not seem like
much, but can drastically reduce query syntax issues. Also, you would likely be using a StringBuilder
anyway, so its not much different. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message