package org.apache.lucene.document;

import org.apache.lucene.index.IndexReader; // javadocs
import org.apache.lucene.index.StorableField;
import org.apache.lucene.search.IndexSearcher; // javadocs
import org.apache.lucene.util.BytesRef;

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/** A field whose value is stored so that {@link
 *  IndexSearcher#doc} and {@link IndexReader#document} will
 *  return the field and its value. */
public class StoredField extends Field {

  /**
   * Type for a stored-only field.
   */
  public final static FieldType TYPE;
  static {
    TYPE = new FieldType();
    TYPE.setStored(true);
    TYPE.freeze();
  }

  /**
   * Create a stored-only field with the given binary value.
   * <p>NOTE: the provided byte[] is not copied so be sure
   * not to change it until you're done with this field.
   * @param name field name
   * @param value byte array pointing to binary content (not copied)
   * @throws IllegalArgumentException if the field name is null.
   */
  protected StoredField(String name, FieldType type) {
    super(name, type);
  }
  
  /**
   * Expert: allows you to customize the {@link
   * FieldType}.
   * <p>NOTE: the provided byte[] is not copied so be sure
   * not to change it until you're done with this field.
   * @param name field name
   * @param value byte array pointing to binary content (not copied)
   * @param type custom {@link FieldType} for this field
   * @throws IllegalArgumentException if the field name is null.
   */
  public StoredField(String name, BytesRef bytes, FieldType type) {
    super(name, bytes, type);
  }
  
  public StoredField(String name, byte[] value) {
    super(name, value, TYPE);
  }
  
  /**
   * Create a stored-only field with the given binary value.
   * <p>NOTE: the provided byte[] is not copied so be sure
   * not to change it until you're done with this field.
   * @param name field name
   * @param value byte array pointing to binary content (not copied)
   * @param offset starting position of the byte array
   * @param length valid length of the byte array
   * @throws IllegalArgumentException if the field name is null.
   */
  public StoredField(String name, byte[] value, int offset, int length) {
    super(name, value, offset, length, TYPE);
  }

  /**
   * Create a stored-only field with the given binary value.
   * <p>NOTE: the provided BytesRef is not copied so be sure
   * not to change it until you're done with this field.
   * @param name field name
   * @param value BytesRef pointing to binary content (not copied)
   * @throws IllegalArgumentException if the field name is null.
   */
  public StoredField(String name, BytesRef value) {
    super(name, value, TYPE);
  }

  /**
   * Create a stored-only field with the given string value.
   * @param name field name
   * @param value string value
   * @throws IllegalArgumentException if the field name or value is null.
   */
  public StoredField(String name, String value) {
    super(name, value, TYPE);
  }
  
  public StoredField(String name, String value, FieldType type) {
    super(name, value, type);
  }

  // TODO: not great but maybe not a big problem?
  /**
   * Create a stored-only field with the given integer value.
   * @param name field name
   * @param value integer value
   * @throws IllegalArgumentException if the field name is null.
   */
  public StoredField(String name, int value) {
    super(name, TYPE);
    fieldsData = value;
  }

  /**
   * Create a stored-only field with the given float value.
   * @param name field name
   * @param value float value
   * @throws IllegalArgumentException if the field name is null.
   */
  public StoredField(String name, float value) {
    super(name, TYPE);
    fieldsData = value;
  }

  /**
   * Create a stored-only field with the given long value.
   * @param name field name
   * @param value long value
   * @throws IllegalArgumentException if the field name is null.
   */
  public StoredField(String name, long value) {
    super(name, TYPE);
    fieldsData = value;
  }

  /**
   * Create a stored-only field with the given double value.
   * @param name field name
   * @param value double value
   * @throws IllegalArgumentException if the field name is null.
   */
  public StoredField(String name, double value) {
    super(name, TYPE);
    fieldsData = value;
  }
}

@@ -1415,276 +1415,152 @@
   * 
-Create a stored-only field with the given binary value.%0A   * %3Cp%3ENOTE: the provided byte%5B%5D is not copied so be sure%0A   * not to change it until you're done with this field.%0A   * @param name field name%0A   * @param value byte array pointing to binary content (not copied)
+Expert: allows you to customize the %7B@link%0A   * FieldType%7D.%0A   * @param name field name%0A   * @param type custom %7B@link FieldType%7D for this field
 %0A   
@@ -1931,37 +1931,37 @@
 ame%0A   * @param 
-value
+bytes
  byte array poin
@@ -2221,32 +2221,383 @@
 , type);%0A  %7D%0A  %0A
+  /**%0A   * Create a stored-only field with the given binary value.%0A   * %3Cp%3ENOTE: the provided byte%5B%5D is not copied so be sure%0A   * not to change it until you're done with this field.%0A   * @param name field name%0A   * @param value byte array pointing to binary content (not copied)%0A   * @throws IllegalArgumentException if the field name is null.%0A   */%0A
   public StoredF
@@ -3979,16 +3979,283 @@
 %0A  %7D%0A  %0A
+  /**%0A   * Expert: allows you to customize the %7B@link%0A   * FieldType%7D.%0A   * @param name field name%0A   * @param value string value%0A   * @param type custom %7B@link FieldType%7D for this field%0A   * @throws IllegalArgumentException if the field name or value is null.%0A   */%0A
   public

Fix incorrect JavaDocs