コード例 #1
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.
 /// Do not use this method with lazy loaded fields.
 /// </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);
 }
コード例 #2
0
        /// <summary> Returns an array of {@link Field}s with the given name.
        /// Do not use with lazy loaded fields.
        /// This method returns an empty array when there are no
        /// matching fields.  It never returns null.
        ///
        /// </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(NO_FIELDS);
            }

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