001    package echopoint.model;
002    
003    import java.util.List;
004    
005    /**
006     * The AutoLookupModel provides for support for looking up
007     * {@code AutoLookupModel.Entry}'s based on partial-string matching.
008     *
009     * @author Christoff Spinner 2009-12-07
010     * @version $Id: AutoLookupModel.java 259 2009-12-07 16:43:59Z sptrakesh $
011     */
012    public interface AutoLookupModel
013    {
014      /**
015       * <code>AutoLookupModel.Entry</code> represents the entries that can be
016       * returned by the AutoLookupModel.
017       */
018      interface Entry
019      {
020        /** @return the value that is used */
021        String getValue();
022      }
023    
024      /**
025       * A simple implementation of <code>AutoLookupModel.Entry</code> is
026       * provided.
027       */
028      class DefaultEntry implements Entry
029      {
030    
031        private String value;
032    
033        /**
034         * Constructs a <code>AutoLookupModel.DefaultEntry</code> where all
035         * three values (value, sortValue, xhtml) are the same
036         *
037         * @param value The value to use.
038         */
039        public DefaultEntry( final String value )
040        {
041          setValue( value );
042        }
043    
044        /** @see Entry#getValue() */
045        public String getValue()
046        {
047          return value;
048        }
049    
050        /**
051         * Sets the value
052         *
053         * @param value - the new value The value to set.
054         */
055        public void setValue( final String value )
056        {
057          this.value = value;
058        }
059      }
060    
061      /**
062       * This is called to populate a cache of <code>AutoLookupModel.Entry</code>'s
063       * on the client based on the partial search value
064       *
065       * @param searchValue - the search value to use
066       * @return a NON-NULL array of <code>AutoLookupModel.Entry</code>'s. This
067       *         may be zero length but may not be null.
068       */
069      List<Entry> searchEntries( String searchValue );
070    }