Package org.apache.lucene.index

# Class StoredFieldVisitor

java.lang.Object
org.apache.lucene.index.StoredFieldVisitor

Direct Known Subclasses:
  `DocumentStoredFieldVisitor`, `StoredFieldsWriter.MergeVisitor`

public abstract class StoredFieldVisitor extends Object
Expert: provides a low-level means of accessing the stored field values in an index. See `StoredFields.document(int, StoredFieldVisitor)`.

NOTE: a `StoredFieldVisitor` implementation should not try to load or visit other stored documents in the same reader because the implementation of stored fields for most codecs is not reentrant and you will see strange exceptions as a result.

See `DocumentStoredFieldVisitor`, which is a `StoredFieldVisitor` that builds the `Document` containing all stored fields. This is used by `StoredFields.document(int)`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `StoredFieldVisitor.Status`
  Enumeration of possible return values for `needsField(org.apache.lucene.index.FieldInfo)`.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `StoredFieldVisitor()`
  Sole constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `binaryField(FieldInfo fieldInfo, byte[] value)`
  Process a binary field.
  `void`
  `binaryField(FieldInfo fieldInfo, StoredFieldDataInput value)`
  Expert: Process a binary field directly from the `StoredFieldDataInput`.
  `void`
  `doubleField(FieldInfo fieldInfo, double value)`
  Process a double numeric field.
  `void`
  `floatField(FieldInfo fieldInfo, float value)`
  Process a float numeric field.
  `void`
  `intField(FieldInfo fieldInfo, int value)`
  Process a int numeric field.
  `void`
  `longField(FieldInfo fieldInfo, long value)`
  Process a long numeric field.
  `abstract StoredFieldVisitor.Status`
  `needsField(FieldInfo fieldInfo)`
  Hook before processing a field.
  `void`
  `stringField(FieldInfo fieldInfo, String value)`
  Process a string field.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### StoredFieldVisitor

    protected StoredFieldVisitor()
    Sole constructor. (For invocation by subclass constructors, typically implicit.)

- ## Method Details

  - ### binaryField

    public void binaryField(FieldInfo fieldInfo, StoredFieldDataInput value) throws IOException
    Expert: Process a binary field directly from the `StoredFieldDataInput`. Implementors of this method must read `StoredFieldDataInput#length` bytes from the given `StoredFieldDataInput`. The default implementation reads all bytes in a newly created byte array and calls `binaryField(FieldInfo, byte[])`.
    Parameters:
      `value` - the stored field data input.
    Throws:
      `IOException`

  - ### binaryField

    public void binaryField(FieldInfo fieldInfo, byte[] value) throws IOException
    Process a binary field.
    Parameters:
      `value` - newly allocated byte array with the binary contents.
    Throws:
      `IOException`

  - ### stringField

    public void stringField(FieldInfo fieldInfo, String value) throws IOException
    Process a string field.
    Throws:
      `IOException`

  - ### intField

    public void intField(FieldInfo fieldInfo, int value) throws IOException
    Process a int numeric field.
    Throws:
      `IOException`

  - ### longField

    public void longField(FieldInfo fieldInfo, long value) throws IOException
    Process a long numeric field.
    Throws:
      `IOException`

  - ### floatField

    public void floatField(FieldInfo fieldInfo, float value) throws IOException
    Process a float numeric field.
    Throws:
      `IOException`

  - ### doubleField

    public void doubleField(FieldInfo fieldInfo, double value) throws IOException
    Process a double numeric field.
    Throws:
      `IOException`

  - ### needsField

    public abstract StoredFieldVisitor.Status needsField(FieldInfo fieldInfo) throws IOException
    Hook before processing a field. Before a field is processed, this method is invoked so that subclasses can return a `StoredFieldVisitor.Status` representing whether they need that particular field or not, or to stop processing entirely.
    Throws:
      `IOException`