コード例 #1
0
ファイル: SortField.cs プロジェクト: wwb/lucenenet
        /// <summary>
        /// Creates a sort, possibly in reverse, by terms in the given field, parsed
        /// to numeric values using a custom <seealso cref="IFieldCache.Parser"/>. </summary>
        /// <param name="field">  Name of field to sort by.  Must not be null. </param>
        /// <param name="parser"> Instance of a <seealso cref="IFieldCache.Parser"/>,
        ///  which must subclass one of the existing numeric
        ///  parsers from <seealso cref="IFieldCache"/>. Sort type is inferred
        ///  by testing which numeric parser the parser subclasses. </param>
        /// <param name="reverse"> True if natural order should be reversed. </param>
        /// <exception cref="IllegalArgumentException"> if the parser fails to
        ///  subclass an existing numeric parser, or field is null </exception>
        public SortField(string field, FieldCache.IParser parser, bool reverse)
        {
            if (parser is FieldCache.IIntParser)
            {
                InitFieldType(field, Type_e.INT);
            }
            else if (parser is FieldCache.IFloatParser)
            {
                InitFieldType(field, Type_e.FLOAT);
            }
            else if (parser is FieldCache.IShortParser)
            {
                InitFieldType(field, Type_e.SHORT);
            }
            else if (parser is FieldCache.IByteParser)
            {
                InitFieldType(field, Type_e.BYTE);
            }
            else if (parser is FieldCache.ILongParser)
            {
                InitFieldType(field, Type_e.LONG);
            }
            else if (parser is FieldCache.IDoubleParser)
            {
                InitFieldType(field, Type_e.DOUBLE);
            }
            else
            {
                throw new System.ArgumentException("Parser instance does not subclass existing numeric parser from FieldCache (got " + parser + ")");
            }

            this.reverse = reverse;
            this.parser  = parser;
        }
コード例 #2
0
        /// <summary>
        /// Creates a sort, possibly in reverse, by terms in the given field, parsed
        /// to numeric values using a custom <see cref="FieldCache.IParser"/>. </summary>
        /// <param name="field">  Name of field to sort by.  Must not be <c>null</c>. </param>
        /// <param name="parser"> Instance of a <see cref="FieldCache.IParser"/>,
        ///  which must subclass one of the existing numeric
        ///  parsers from <see cref="IFieldCache"/>. Sort type is inferred
        ///  by testing which numeric parser the parser subclasses. </param>
        /// <param name="reverse"> <c>True</c> if natural order should be reversed. </param>
        /// <exception cref="ArgumentException"> if the parser fails to
        ///  subclass an existing numeric parser, or field is <c>null</c> </exception>
        public SortField(string field, FieldCache.IParser parser, bool reverse)
        {
            if (parser is FieldCache.IInt32Parser)
            {
                InitFieldType(field, SortFieldType.INT32);
            }
            else if (parser is FieldCache.ISingleParser)
            {
                InitFieldType(field, SortFieldType.SINGLE);
            }
#pragma warning disable 612, 618
            else if (parser is FieldCache.IInt16Parser)
            {
                InitFieldType(field, SortFieldType.INT16);
            }
            else if (parser is FieldCache.IByteParser)
            {
                InitFieldType(field, SortFieldType.BYTE);
#pragma warning restore 612, 618
            }
            else if (parser is FieldCache.IInt64Parser)
            {
                InitFieldType(field, SortFieldType.INT64);
            }
            else if (parser is FieldCache.IDoubleParser)
            {
                InitFieldType(field, SortFieldType.DOUBLE);
            }
            else
            {
                throw new System.ArgumentException("Parser instance does not subclass existing numeric parser from FieldCache (got " + parser + ")");
            }

            this.reverse = reverse;
            this.parser  = parser;
        }
コード例 #3
0
 internal AnonymousDoubleFieldCacheRangeFilter(string field, FieldCache.IParser parser, double?lowerVal, double?upperVal, bool includeLower, bool includeUpper)
     : base(field, parser, lowerVal, upperVal, includeLower, includeUpper)
 {
 }
コード例 #4
0
 internal AnonymousInt16FieldCacheRangeFilter(string field, FieldCache.IParser parser, short?lowerVal, short?upperVal, bool includeLower, bool includeUpper)
     : base(field, parser, lowerVal, upperVal, includeLower, includeUpper)
 {
 }
コード例 #5
0
 /// <summary>
 /// Creates a sort by terms in the given field, parsed
 /// to numeric values using a custom <see cref="FieldCache.IParser"/>. </summary>
 /// <param name="field">  Name of field to sort by.  Must not be <c>null</c>. </param>
 /// <param name="parser"> Instance of a <see cref="FieldCache.IParser"/>,
 ///  which must subclass one of the existing numeric
 ///  parsers from <see cref="IFieldCache"/>. Sort type is inferred
 ///  by testing which numeric parser the parser subclasses. </param>
 /// <exception cref="ArgumentException"> if the parser fails to
 ///  subclass an existing numeric parser, or field is <c>null</c> </exception>
 public SortField(string field, FieldCache.IParser parser)
     : this(field, parser, false)
 {
 }
コード例 #6
0
ファイル: SortField.cs プロジェクト: apache/lucenenet
        /// <summary>
        /// Creates a sort, possibly in reverse, by terms in the given field, parsed
        /// to numeric values using a custom <seealso cref="IFieldCache.Parser"/>. </summary>
        /// <param name="field">  Name of field to sort by.  Must not be null. </param>
        /// <param name="parser"> Instance of a <seealso cref="IFieldCache.Parser"/>,
        ///  which must subclass one of the existing numeric
        ///  parsers from <seealso cref="IFieldCache"/>. Sort type is inferred
        ///  by testing which numeric parser the parser subclasses. </param>
        /// <param name="reverse"> True if natural order should be reversed. </param>
        /// <exception cref="IllegalArgumentException"> if the parser fails to
        ///  subclass an existing numeric parser, or field is null </exception>
        public SortField(string field, FieldCache.IParser parser, bool reverse)
        {
            if (parser is FieldCache.IIntParser)
            {
                InitFieldType(field, Type_e.INT);
            }
            else if (parser is FieldCache.IFloatParser)
            {
                InitFieldType(field, Type_e.FLOAT);
            }
            else if (parser is FieldCache.IShortParser)
            {
                InitFieldType(field, Type_e.SHORT);
            }
            else if (parser is FieldCache.IByteParser)
            {
                InitFieldType(field, Type_e.BYTE);
            }
            else if (parser is FieldCache.ILongParser)
            {
                InitFieldType(field, Type_e.LONG);
            }
            else if (parser is FieldCache.IDoubleParser)
            {
                InitFieldType(field, Type_e.DOUBLE);
            }
            else
            {
                throw new System.ArgumentException("Parser instance does not subclass existing numeric parser from FieldCache (got " + parser + ")");
            }

            this.reverse = reverse;
            this.parser = parser;
        }
コード例 #7
0
 internal SingleFieldCacheRangeFilterAnonymousClass(string field, FieldCache.IParser parser, float?lowerVal, float?upperVal, bool includeLower, bool includeUpper)
     : base(field, parser, lowerVal, upperVal, includeLower, includeUpper)
 {
 }