Apache Lucene open-source search software
LUCENE-608: deprecate Document.fields(), add getFields()
Daniel Naber8ebdf9fc86b0
diff --git a/CHANGES.txt b/CHANGES.txtindex 4e2bc41c560..f66794655c1 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -10,7 +10,8 @@ New features(Samphan Raruenrom va Chris Hostetter)2. LUCENE-545: New FieldSelector API and associated changes to IndexReader and implementations.- New Fieldable interface for use with the lazy field loading mechanism. (Grant Ingersoll and Chuck Williams via Grant Ingersoll)+ New Fieldable interface for use with the lazy field loading mechanism.+ (Grant Ingersoll and Chuck Williams via Grant Ingersoll)API Changes@@ -21,9 +22,13 @@ API Changesand is supposed to be replaced with the WordlistLoader class inpackage org.apache.lucene.analysis (Daniel Naber)-10. LUCENE-609: Revert return type of Document.getField(s) to Field+ 3. LUCENE-609: Revert return type of Document.getField(s) to Fieldfor backward compatibility, added new Document.getFieldable(s)for access to new lazy loaded fields. (Yonik Seeley)++ 4. LUCENE-608: Document.fields() has been deprecated and a new method+ Document.getFields() has been added that returns a List instead of+ an Enumeration (Daniel Naber)Bug fixesdiff --git a/src/java/org/apache/lucene/document/Document.java b/src/java/org/apache/lucene/document/Document.javaindex f47a75104af..d4e3710ab07 100644--- a/src/java/org/apache/lucene/document/Document.java+++ b/src/java/org/apache/lucene/document/Document.java@@ -168,11 +168,22 @@ public final class Document implements java.io.Serializable {return null;}- /** Returns an Enumeration of all the fields in a document. */+ /** Returns an Enumeration of all the fields in a document.+ * @deprecated use {@link #getFields()} instead+ */public final Enumeration fields() {return ((Vector)fields).elements();}+ /** Returns a List of all the fields in a document.+ * <p>Note that fields which are <i>not</i> {@link Fieldable#isStored() stored} are+ * <i>not</i> available in documents retrieved from the index, e.g. with {@link+ * Hits#doc(int)}, {@link Searcher#doc(int)} or {@link IndexReader#document(int)}.+ */+ public final List getFields() {+ return fields;+ }+/*** Returns an array of {@link Field}s with the given name.* This method can return <code>null</code>.@@ -202,7 +213,7 @@ public final class Document implements java.io.Serializable {* This method can return <code>null</code>.** @param name the name of the field- * @return a <code>Fieldable[]</code> array+ * @return a <code>Fieldable[]</code> array or <code>null</code>*/public Fieldable[] getFieldables(String name) {List result = new ArrayList();@@ -225,7 +236,7 @@ public final class Document implements java.io.Serializable {* This method can return <code>null</code>.** @param name the name of the field- * @return a <code>String[]</code> of field values+ * @return a <code>String[]</code> of field values or <code>null</code>*/public final String[] getValues(String name) {List result = new ArrayList();@@ -247,7 +258,7 @@ public final class Document implements java.io.Serializable {* binary fields with the specified name are available.** @param name the name of the field- * @return a <code>byte[][]</code> of binary field values.+ * @return a <code>byte[][]</code> of binary field values or <code>null</code>*/public final byte[][] getBinaryValues(String name) {List result = new ArrayList();@@ -270,7 +281,7 @@ public final class Document implements java.io.Serializable {* There may be non-binary fields with the same name.** @param name the name of the field.- * @return a <code>byte[]</code> containing the binary field value.+ * @return a <code>byte[]</code> containing the binary field value or <code>null</code>*/public final byte[] getBinaryValue(String name) {for (int i=0; i < fields.size(); i++) {