lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darren Hobbs <dar...@farfetched.org>
Subject Re: getAllFieldNames diffs
Date Tue, 12 Nov 2002 20:49:56 GMT
On Tue, Nov 12, 2002 at 03:17:19PM -0500, Peter Mularien wrote:
> Attached. Please comment or critique. I've used the java.util.Collection 
> classes here extensively, which may be an issue since other parts of the 
> API return Enumeration. Collections have been preferred since JDK 1.2 
> for a number of reasons I won't go into here. Please let me know if 
> these are OK to use in Lucene.
> 
> +     /**
> +      * Return a list of all unique field names which exist in the index pointed to
by
> +      * this IndexReader.
> +      * @return Collection of Strings indicating the names of the fields
> +      * @throws IOException if there is a problem with accessing the index
> +      */
> +     public abstract Collection getFieldNames() throws IOException;
>   
>     /**
> +     public Collection getFieldNames() throws IOException {
> +         // maintain a unique set of field names
> +         Set fieldSet = new HashSet();
> +         for (int i = 0; i < fieldInfos.size(); i++) {
> +             FieldInfo fi = fieldInfos.fieldInfo(i);
> +             fieldSet.add(fi.name);
> +         }
> +         return fieldSet;
> +     }
>   }

Given that the concrete implementation returns a Set and the javadoc states
that the field names will be unique, would it better to declare the method
to return a Set rather than a Collection?  That would seem to better capture
the intention.  Apologies if this seems nit-picky - it means I can't find
anything worse wrong with it!

Regards,

-Darren


--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message