public virtual int Compare(System.Object o1, System.Object o2)
			{
                if (o1 == o2) return 0;
                f1 = (Fieldable)o1;
                f2 = (Fieldable)o2;
                return String.CompareOrdinal(f1.Name() + f1.StringValue(), f2.Name() + f2.StringValue());
			}
예제 #2
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)
        {
            IEnumerator <Fieldable> it = fields.GetEnumerator();

            while (it.MoveNext())
            {
                Fieldable field = it.Current;
                if (field.Name().Equals(name))
                {
                    fields.Remove(field);
                    return;
                }
            }
        }
예제 #3
0
        /// <summary> Returns an array of byte arrays for of the fields that have the name specified
        /// as the method parameter. This method will return <code>null</code> if no
        /// binary fields with the specified name are available.
        ///
        /// </summary>
        /// <param name="name">the name of the field
        /// </param>
        /// <returns> a  <code>byte[][]</code> of binary field values or <code>null</code>
        /// </returns>
        public byte[][] GetBinaryValues(System.String name)
        {
            System.Collections.IList result = new System.Collections.ArrayList();
            for (int i = 0; i < fields.Count; i++)
            {
                Fieldable field = (Fieldable)fields[i];
                if (field.Name().Equals(name) && (field.IsBinary()))
                {
                    byte[] byteArray       = field.BinaryValue();
                    byte[] resultByteArray = new byte[byteArray.Length];
                    for (int index = 0; index < byteArray.Length; index++)
                    {
                        resultByteArray[index] = (byte)byteArray[index];
                    }

                    result.Add(resultByteArray);
                }
            }

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

            System.Collections.ICollection c = result;
            System.Object[] objects          = new byte[result.Count][];

            System.Type     type = objects.GetType().GetElementType();
            System.Object[] objs = (System.Object[])Array.CreateInstance(type, c.Count);

            System.Collections.IEnumerator e = c.GetEnumerator();
            int ii = 0;

            while (e.MoveNext())
            {
                objs[ii++] = e.Current;
            }

            // If objects is smaller than c then do not return the new array in the parameter
            if (objects.Length >= c.Count)
            {
                objs.CopyTo(objects, 0);
            }

            return((byte[][])objs);
        }
예제 #4
0
        /// <summary> Returns an array of values of the field specified as the method parameter.
        /// 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>String[]</code> of field values
        /// </returns>
        public System.String[] GetValues(System.String name)
        {
            System.Collections.ArrayList result = new System.Collections.ArrayList();
            for (int i = 0; i < fields.Count; i++)
            {
                Fieldable field = (Fieldable)fields[i];
                if (field.Name().Equals(name) && (!field.IsBinary()))
                {
                    result.Add(field.StringValue());
                }
            }

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

            return((System.String[])result.ToArray(typeof(System.String)));
        }
예제 #5
0
        /// <summary> Returns an array of {@link Fieldable}s with the given name.
        /// 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>Fieldable[]</code> array
        /// </returns>
        public Fieldable[] GetFieldables(System.String name)
        {
            System.Collections.ArrayList result = new System.Collections.ArrayList();
            for (int i = 0; i < fields.Count; i++)
            {
                Fieldable field = (Fieldable)fields[i];
                if (field.Name().Equals(name))
                {
                    result.Add(field);
                }
            }

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

            return((Fieldable[])result.ToArray(typeof(Fieldable)));
        }
예제 #6
0
        /// <summary> Returns an array of byte arrays for of the fields that have the name specified
        /// as the method parameter.  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>byte[][]</code> of binary field values
        /// </returns>
        public byte[][] GetBinaryValues(System.String name)
        {
            List <byte[]> result = new List <byte[]>();

            for (int i = 0; i < fields.Count; i++)
            {
                Fieldable field = fields[i];
                if (field.Name().Equals(name) && (field.IsBinary()))
                {
                    result.Add(field.BinaryValue());
                }
            }

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

            return(result.ToArray());
        }
예제 #7
0
        /// <summary> Returns an array of values of the field specified as the method parameter.
        /// 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>String[]</code> of field values
        /// </returns>
        public string[] GetValues(System.String name)
        {
            List <string> result = new List <string>();

            for (int i = 0; i < fields.Count; i++)
            {
                Fieldable field = fields[i];
                if (field.Name().Equals(name) && (!field.IsBinary()))
                {
                    result.Add(field.StringValue());
                }
            }

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

            return(result.ToArray());
        }
예제 #8
0
        /// <summary> Returns an array of {@link Fieldable}s with the given name.
        /// 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>Fieldable[]</code> array
        /// </returns>
        public Fieldable[] GetFieldables(System.String name)
        {
            List <Fieldable> result = new List <Fieldable>();

            for (int i = 0; i < fields.Count; i++)
            {
                Fieldable field = fields[i];
                if (field.Name().Equals(name))
                {
                    result.Add(field);
                }
            }

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

            return(result.ToArray());
        }
예제 #9
0
        /// <summary> Returns an array of values of the field specified as the method parameter.
        /// 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>String[]</code> of field values</returns>
        public System.String[] GetValues(System.String name)
        {
            System.Collections.ArrayList result = new System.Collections.ArrayList();
            for (int i = 0; i < fields.Count; i++)
            {
                Fieldable field = (Fieldable)fields[i];
                if (field.Name().Equals(name) && (!field.IsBinary()))
                {
                    result.Add(field.StringValue());
                }
            }
            /// This method returns an empty array when there are no
            /// matching fields.  It never returns null.

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

            return((System.String[])(result.ToArray(typeof(System.String))));
        }