## org.apache.lucene.index
Class FieldInfos

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

All Implemented Interfaces:
  Iterable<FieldInfo>

    public final class FieldInfos

extends Object
implements Iterable<FieldInfo>

Collection of `FieldInfo`s (accessible by number or by name).

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

Field Summary
`static int` `FORMAT_OMIT_POSITIONS`
`static int` `FORMAT_PRE`
`static int` `FORMAT_START`

Constructor Summary
`FieldInfos()`
`FieldInfos(Directory d, String name)` Construct a FieldInfos object using the directory and the name of the file IndexInput

Method Summary
`void` `add(Document doc)` Adds field info for a Document.
`FieldInfo` `add(FieldInfo fi)`
`void` `add(FieldInfos other)`
`void` `add(String name, boolean isIndexed)` Calls 5 parameter add with false for all TermVector parameters.
`void` `add(String name, boolean isIndexed, boolean storeTermVector)` Calls 5 parameter add with false for term vector positions and offsets.
`void` `add(String name, boolean isIndexed, boolean storeTermVector, boolean omitNorms)` If the field is not yet known, adds it.
`FieldInfo` `add(String name, boolean isIndexed, boolean storeTermVector, boolean omitNorms, boolean storePayloads, FieldInfo.IndexOptions indexOptions)` If the field is not yet known, adds it.
`Object` `clone()` Returns a deep clone of this FieldInfos instance.
`FieldInfo` `fieldInfo(int fieldNumber)` Return the fieldinfo object referenced by the fieldNumber.
`FieldInfo` `fieldInfo(String fieldName)`
`String` `fieldName(int fieldNumber)` Return the fieldName identified by its number.
`int` `fieldNumber(String fieldName)` lookup the number of a field by name.
`boolean` `hasProx()` Returns true if any fields do not omitTermFreqAndPositions
`boolean` `hasVectors()`
`Iterator<FieldInfo>` `iterator()`
`int` `size()`
`void` `write(Directory d, String name)`
`void` `write(IndexOutput output)`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### FORMAT_PRE

    public static final int FORMAT_PRE

See Also:
  Constant Field Values

### FORMAT_START

    public static final int FORMAT_START

See Also:
  Constant Field Values

### FORMAT_OMIT_POSITIONS

    public static final int FORMAT_OMIT_POSITIONS

See Also:
  Constant Field Values

Constructor Detail

### FieldInfos

    public FieldInfos()

### FieldInfos

    public FieldInfos(Directory d,
                      String name)
               throws IOException

  Construct a FieldInfos object using the directory and the name of the file IndexInput

  Parameters:
    `d` - The directory to open the IndexInput from
    `name` - The name of the file to open the IndexInput from in the Directory
  Throws:
    `IOException`

Method Detail

### add

    public void add(FieldInfos other)

### clone

    public Object clone()

  Returns a deep clone of this FieldInfos instance.

  Overrides:
    `clone` in class `Object`

### add

    public void add(Document doc)

  Adds field info for a Document.

### hasProx

    public boolean hasProx()

  Returns true if any fields do not omitTermFreqAndPositions

### add

    public void add(String name,
                    boolean isIndexed)

  Calls 5 parameter add with false for all TermVector parameters.

  Parameters:
    `name` - The name of the Fieldable
    `isIndexed` - true if the field is indexed
  See Also:
    `add(String, boolean, boolean)`

### add

    public void add(String name,
                    boolean isIndexed,
                    boolean storeTermVector)

  Calls 5 parameter add with false for term vector positions and offsets.

  Parameters:
    `name` - The name of the field
    `isIndexed` - true if the field is indexed
    `storeTermVector` - true if the term vector should be stored

### add

    public void add(String name,
                    boolean isIndexed,
                    boolean storeTermVector,
                    boolean omitNorms)

  If the field is not yet known, adds it. If it is known, checks to make sure that the isIndexed flag is the same as was given previously for this field. If not - marks it as being indexed. Same goes for the TermVector parameters.

  Parameters:
    `name` - The name of the field
    `isIndexed` - true if the field is indexed
    `storeTermVector` - true if the term vector should be stored
    `omitNorms` - true if the norms for the indexed field should be omitted

### add

    public FieldInfo add(String name,
                         boolean isIndexed,
                         boolean storeTermVector,
                         boolean omitNorms,
                         boolean storePayloads,
                         FieldInfo.IndexOptions indexOptions)

  If the field is not yet known, adds it. If it is known, checks to make sure that the isIndexed flag is the same as was given previously for this field. If not - marks it as being indexed. Same goes for the TermVector parameters.

  Parameters:
    `name` - The name of the field
    `isIndexed` - true if the field is indexed
    `storeTermVector` - true if the term vector should be stored
    `omitNorms` - true if the norms for the indexed field should be omitted
    `storePayloads` - true if payloads should be stored for this field
    `indexOptions` - if term freqs should be omitted for this field

### add

    public FieldInfo add(FieldInfo fi)

### fieldNumber

    public int fieldNumber(String fieldName)

  lookup the number of a field by name.

  Parameters:
    `fieldName` - field's name
  Returns:
    number of field, or -1 if it does not exist.

### fieldInfo

    public FieldInfo fieldInfo(String fieldName)

### fieldName

    public String fieldName(int fieldNumber)

  Return the fieldName identified by its number.

  Parameters:
    `fieldNumber` -
  Returns:
    the fieldName or an empty string when the field with the given number doesn't exist.

### fieldInfo

    public FieldInfo fieldInfo(int fieldNumber)

  Return the fieldinfo object referenced by the fieldNumber.

  Parameters:
    `fieldNumber` -
  Returns:
    the FieldInfo object or null when the given fieldNumber doesn't exist.

### iterator

    public Iterator<FieldInfo> iterator()

  Specified by:
    `iterator` in interface `Iterable<FieldInfo>`

### size

    public int size()

  Returns:
    number of fields

### hasVectors

    public boolean hasVectors()

  Returns:
    true if at least one field has any vectors

### write

    public void write(Directory d,
                      String name)
               throws IOException

  Throws:
    `IOException`

### write

    public void write(IndexOutput output)
               throws IOException

  Throws:
    `IOException`