001    package com.sptci.prevayler.annotations;
002    
003    import java.lang.annotation.Documented;
004    import java.lang.annotation.ElementType;
005    import java.lang.annotation.Inherited;
006    import java.lang.annotation.Retention;
007    import java.lang.annotation.RetentionPolicy;
008    import java.lang.annotation.Target;
009    
010    /**
011     * Annotation for class fields that are to be indexed for full-text search.
012     * When specified at the class level, it is possible to specify a number of
013     * fields that are to be indexed as a combination making for easier search
014     * queries.
015     *
016     * <p>&copy; Copyright 2008 <a href='http://sptci.com/' target='_top'>Sans
017     * Pareil Technologies, Inc.</a></p>
018     * @author Rakesh 2008-11-12
019     * @since Release 0.3.0
020     * @version $Id: Searchable.java 22 2008-11-24 19:04:25Z sptrakesh $
021     */
022    @Documented
023    @Inherited
024    @Retention( RetentionPolicy.RUNTIME )
025    @Target( { ElementType.TYPE, ElementType.FIELD } )
026    public @interface Searchable
027    {
028      /** The default value for {@link #members} indicating a null value. */
029      static String NULL = "";
030    
031      /**
032       * The name of the field within the lucene document that is represented
033       * by this index.  Specify only for composite indices (specified at class
034       * level.  When annotated at the field level, the name of the field is
035       * taken as the indexed field name. If not specified a name that is the
036       * concatenation of the field names in {@link #members} will be used.
037       * Using the default value will make it harder to compile queries, so it
038       * is recommended that you specify this value as well.
039       *
040       * @return The name of the indexed field.
041       */
042      String name() default NULL;
043    
044      /**
045       * The name of the fields in the prevalent object to index.  This need only
046       * be specified when specified at the class level.  Multiple fields may be
047       * specified to indicate a composite search index (tokenised and stored
048       * as a common index for easy search). Defaults to {@link #NULL}.
049       *
050       * @return The name of the fields.
051       */
052      String[] members() default NULL;
053    }