Beispiel #1
0
 /// <summary> <p>Removes all fields with the given name from the document.
 /// If there is no Field with the specified name, the document remains unchanged.</p>
 /// <p> Note that the removeField(s) methods like the add method only make sense
 /// prior to adding a document to an index. These methods cannot
 /// be used to change the content of an existing index! In order to achieve this,
 /// a document has to be deleted from an index and a new changed version of that
 /// document has to be added.</p>
 /// </summary>
 public void  RemoveFields(System.String name)
 {
     for (int i = fields.Count - 1; i >= 0; i--)
     {
         Field field = (Field)fields[i];
         if (field.Name().Equals(name))
         {
             fields.RemoveAt(i);
         }
     }
 }
Beispiel #2
0
 /// <summary>Returns a Field with the given name if any exist in this document, or
 /// null.  If multiple fields exists with this name, this method returns the
 /// first value added.
 /// </summary>
 public Field GetField(System.String name)
 {
     for (int i = 0; i < fields.Count; i++)
     {
         Field field = (Field)fields[i];
         if (field.Name().Equals(name))
         {
             return(field);
         }
     }
     return(null);
 }
Beispiel #3
0
 /// <summary> <p>Removes Field with the specified name from the document.
 /// If multiple fields exist with this name, this method removes the first Field that has been added.
 /// If there is no Field with the specified name, the document remains unchanged.</p>
 /// <p> Note that the removeField(s) methods like the add method only make sense
 /// prior to adding a document to an index. These methods cannot
 /// be used to change the content of an existing index! In order to achieve this,
 /// a document has to be deleted from an index and a new changed version of that
 /// document has to be added.</p>
 /// </summary>
 public void  RemoveField(System.String name)
 {
     System.Collections.IEnumerator it = fields.GetEnumerator();
     while (it.MoveNext())
     {
         Field field = (Field)it.Current;
         if (field.Name().Equals(name))
         {
             fields.Remove(field);
             return;
         }
     }
 }
Beispiel #4
0
        /// <summary> Returns an array of {@link Field}s with the given name.
        /// This method can return <code>null</code>.
        ///
        /// </summary>
        /// <param name="name">the name of the Field
        /// </param>
        /// <returns> a <code>Field[]</code> array
        /// </returns>
        public Field[] GetFields(System.String name)
        {
            System.Collections.ArrayList result = new System.Collections.ArrayList();
            for (int i = 0; i < fields.Count; i++)
            {
                Field field = (Field)fields[i];
                if (field.Name().Equals(name))
                {
                    result.Add(field);
                }
            }

            if (result.Count == 0)
            {
                return(null);
            }

            return((Field[])result.ToArray(typeof(Field)));
        }