mirror of https://github.com/apache/lucene.git
adding a constructor that takes a Reader; some small doc improvements, some whitespace fixes. I will soon deprecate the static methods.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150472 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
794ba80e15
commit
ac4238947f
|
@ -213,12 +213,20 @@ public final class Field implements java.io.Serializable {
|
||||||
is used. Exactly one of stringValue() and readerValue() must be set. */
|
is used. Exactly one of stringValue() and readerValue() must be set. */
|
||||||
public Reader readerValue() { return readerValue; }
|
public Reader readerValue() { return readerValue; }
|
||||||
|
|
||||||
|
/**
|
||||||
/** Create a field by specifying all parameters except for <code>termVector</code>,
|
* Create a field by specifying its name, value and how it will
|
||||||
* which is set to <code>TermVector.NO</code>.
|
* be saved in the index. Term vectors will not be stored in the index.
|
||||||
|
*
|
||||||
|
* @param name The name of the field
|
||||||
|
* @param value The string to process
|
||||||
|
* @param store Whether <code>value</code> should be stored in the index
|
||||||
|
* @param index Whether the field should be indexed, and if so, if it should
|
||||||
|
* be tokenized before indexing
|
||||||
|
* @throws NullPointerException if name or value is <code>null</code>
|
||||||
|
* @throws IllegalArgumentException if the field is neither stored nor indexed
|
||||||
*/
|
*/
|
||||||
public Field(String name, String string, Store store, Index index) {
|
public Field(String name, String value, Store store, Index index) {
|
||||||
this(name, string, store, index, TermVector.NO);
|
this(name, value, store, index, TermVector.NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,10 +235,11 @@ public final class Field implements java.io.Serializable {
|
||||||
*
|
*
|
||||||
* @param name The name of the field
|
* @param name The name of the field
|
||||||
* @param value The string to process
|
* @param value The string to process
|
||||||
* @param store whether <code>value</code> should be stored in the index
|
* @param store Whether <code>value</code> should be stored in the index
|
||||||
* @param index whether the field should be indexed, and if so, if it should
|
* @param index Whether the field should be indexed, and if so, if it should
|
||||||
* be tokenized before indexing
|
* be tokenized before indexing
|
||||||
* @param termVector whether Term Vector info should be stored
|
* @param termVector Whether term vector should be stored
|
||||||
|
* @throws NullPointerException if name or value is <code>null</code>
|
||||||
* @throws IllegalArgumentException in any of the following situations:
|
* @throws IllegalArgumentException in any of the following situations:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>the field is neither stored nor indexed</li>
|
* <li>the field is neither stored nor indexed</li>
|
||||||
|
@ -251,6 +260,7 @@ public final class Field implements java.io.Serializable {
|
||||||
|
|
||||||
this.name = name.intern(); // field names are interned
|
this.name = name.intern(); // field names are interned
|
||||||
this.stringValue = value;
|
this.stringValue = value;
|
||||||
|
|
||||||
if (store == Store.YES)
|
if (store == Store.YES)
|
||||||
this.isStored = true;
|
this.isStored = true;
|
||||||
else if (store == Store.NO)
|
else if (store == Store.NO)
|
||||||
|
@ -271,17 +281,46 @@ public final class Field implements java.io.Serializable {
|
||||||
throw new IllegalArgumentException("unknown index parameter " + index);
|
throw new IllegalArgumentException("unknown index parameter " + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (termVector == TermVector.NO) {
|
setStoreTermVector(termVector);
|
||||||
this.storeTermVector = false;
|
}
|
||||||
} else if (termVector == TermVector.YES) {
|
|
||||||
this.storeTermVector = true;
|
/**
|
||||||
} else {
|
* Create a tokenized and indexed field that is not stored. Term vectors will
|
||||||
throw new IllegalArgumentException("unknown termVector parameter " + termVector);
|
* not be stored.
|
||||||
|
*
|
||||||
|
* @param name The name of the field
|
||||||
|
* @param reader The reader with the content
|
||||||
|
* @throws NullPointerException if name or reader is <code>null</code>
|
||||||
|
*/
|
||||||
|
public Field(String name, Reader reader) {
|
||||||
|
this(name, reader, TermVector.NO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a tokenized and indexed field that is not stored, optionally with
|
||||||
|
* storing term vectors.
|
||||||
|
*
|
||||||
|
* @param name The name of the field
|
||||||
|
* @param reader The reader with the content
|
||||||
|
* @param termVector Whether term vector should be stored
|
||||||
|
* @throws NullPointerException if name or reader is <code>null</code>
|
||||||
|
*/
|
||||||
|
public Field(String name, Reader reader, TermVector termVector) {
|
||||||
|
if (name == null)
|
||||||
|
throw new NullPointerException("name cannot be null");
|
||||||
|
if (reader == null)
|
||||||
|
throw new NullPointerException("reader cannot be null");
|
||||||
|
this.name = name.intern(); // field names are interned
|
||||||
|
this.readerValue = reader;
|
||||||
|
this.isStored = false;
|
||||||
|
this.isIndexed = true;
|
||||||
|
this.isTokenized = true;
|
||||||
|
setStoreTermVector(termVector);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** Create a field by specifying all parameters except for <code>storeTermVector</code>,
|
/** Create a field by specifying all parameters except for <code>storeTermVector</code>,
|
||||||
* which is set to <code>false</code>.
|
* which is set to <code>false</code>.
|
||||||
|
*
|
||||||
* @deprecated use {@link #Field(String, String, Field.Store, Field.Index)} instead
|
* @deprecated use {@link #Field(String, String, Field.Store, Field.Index)} instead
|
||||||
*/
|
*/
|
||||||
public Field(String name, String string,
|
public Field(String name, String string,
|
||||||
|
@ -297,6 +336,7 @@ public final class Field implements java.io.Serializable {
|
||||||
* @param index true if the field should be indexed
|
* @param index true if the field should be indexed
|
||||||
* @param token true if the field should be tokenized
|
* @param token true if the field should be tokenized
|
||||||
* @param storeTermVector true if we should store the Term Vector info
|
* @param storeTermVector true if we should store the Term Vector info
|
||||||
|
*
|
||||||
* @deprecated use {@link #Field(String, String, Field.Store, Field.Index, Field.TermVector)} instead
|
* @deprecated use {@link #Field(String, String, Field.Store, Field.Index, Field.TermVector)} instead
|
||||||
*/
|
*/
|
||||||
public Field(String name, String string,
|
public Field(String name, String string,
|
||||||
|
@ -316,14 +356,14 @@ public final class Field implements java.io.Serializable {
|
||||||
this.storeTermVector = storeTermVector;
|
this.storeTermVector = storeTermVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field(String name, Reader reader) {
|
private void setStoreTermVector(TermVector termVector) {
|
||||||
if (name == null)
|
if (termVector == TermVector.NO) {
|
||||||
throw new NullPointerException("name cannot be null");
|
this.storeTermVector = false;
|
||||||
if (reader == null)
|
} else if (termVector == TermVector.YES) {
|
||||||
throw new NullPointerException("value cannot be null");
|
this.storeTermVector = true;
|
||||||
|
} else {
|
||||||
this.name = name.intern(); // field names are interned
|
throw new IllegalArgumentException("unknown termVector parameter " + termVector);
|
||||||
this.readerValue = reader;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** True iff the value of the field is to be stored in the index for return
|
/** True iff the value of the field is to be stored in the index for return
|
||||||
|
|
Loading…
Reference in New Issue