Пример #1
0
        static int internal_index(System.Globalization.CompareInfo _this, string source, int sIndex, int count, char value, System.Globalization.CompareOptions options, bool first)
        {
            // if first == true find first incidence, else find last

            if (first)
            {
                for (int i = sIndex; i < (sIndex + count); i++)
                {
                    if (source[i] == value)
                    {
                        return(i);
                    }
                }
            }
            else
            {
                for (int i = (sIndex + count - 1); i >= sIndex; i--)
                {
                    if (source[i] == value)
                    {
                        return(i);
                    }
                }
            }
            return(-1);
        }
        /// <summary>
        /// The Virtual Payment Client need to use an Ordinal comparison to Sort on
        /// the field names to create the SHA256 Signature for validation of the message.
        /// This class provides a Compare method that is used to allow the sorted list
        /// to be ordered using an Ordinal comparison.
        /// </summary>
        /// <param name="a">The first string in the comparison.</param>
        /// <param name = "b" > The second string in the comparison.</param>
        /// <returns>An int containing the result of the comparison.</returns>
        public int Compare(string a, string b)
        {
            // Return if we are comparing the same object or one of the
            // objects is null, since we don't need to go any further.
            if (a == b)
            {
                return(0);
            }
            if (a == null)
            {
                return(-1);
            }
            if (b == null)
            {
                return(1);
            }

            // Ensure we have string to compare
            string sa = a as string;
            string sb = b as string;

            // Get the CompareInfo object to use for comparing
            System.Globalization.CompareInfo myComparer = System.Globalization.CompareInfo.GetCompareInfo("en-US");
            if (sa != null && sb != null)
            {
                // Compare using an Ordinal Comparison.
                return(myComparer.Compare(sa, sb, System.Globalization.CompareOptions.Ordinal));
            }
            throw new ArgumentException("a and b should be strings.");
        }
 /// <summary> Returns a comparator for sorting hits according to a field containing strings.</summary>
 /// <param name="reader"> Index to use.
 /// </param>
 /// <param name="fieldname"> Fieldable containg string values.
 /// </param>
 /// <returns>  Comparator for sorting hits.
 /// </returns>
 /// <throws>  IOException If an error occurs reading the index. </throws>
 internal static ScoreDocComparator ComparatorStringLocale(IndexReader reader, System.String fieldname, System.Globalization.CultureInfo locale)
 {
     System.Globalization.CompareInfo collator = locale.CompareInfo;
     System.String   field = String.Intern(fieldname);
     System.String[] index = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStrings(reader, field);
     return(new AnonymousClassScoreDocComparator5(index, collator));
 }
Пример #4
0
        /// <summary> Enumerates all terms greater/equal than <code>lowerTerm</code>
        /// but less/equal than <code>upperTerm</code>.
        ///
        /// If an endpoint is null, it is said to be "open". Either or both
        /// endpoints may be open.  Open endpoints may not be exclusive
        /// (you can't select all but the first or last term without
        /// explicitly specifying the term to exclude.)
        ///
        /// </summary>
        /// <param name="reader">
        /// </param>
        /// <param name="field">An interned field that holds both lower and upper terms.
        /// </param>
        /// <param name="lowerTermText">The term text at the lower end of the range
        /// </param>
        /// <param name="upperTermText">The term text at the upper end of the range
        /// </param>
        /// <param name="includeLower">If true, the <code>lowerTerm</code> is included in the range.
        /// </param>
        /// <param name="includeUpper">If true, the <code>upperTerm</code> is included in the range.
        /// </param>
        /// <param name="collator">The collator to use to collate index Terms, to determine their
        /// membership in the range bounded by <code>lowerTerm</code> and
        /// <code>upperTerm</code>.
        ///
        /// </param>
        /// <throws>  IOException </throws>
        public TermRangeTermEnum(IndexReader reader, System.String field, System.String lowerTermText, System.String upperTermText, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator)
        {
            this.collator      = collator;
            this.upperTermText = upperTermText;
            this.lowerTermText = lowerTermText;
            this.includeLower  = includeLower;
            this.includeUpper  = includeUpper;
            this.field         = StringHelper.Intern(field);

            // do a little bit of normalization...
            // open ended range queries should always be inclusive.
            if (this.lowerTermText == null)
            {
                this.lowerTermText = "";
                this.includeLower  = true;
            }

            if (this.upperTermText == null)
            {
                this.includeUpper = true;
            }

            System.String startTermText = collator == null?this.lowerTermText:"";
            SetEnum(reader.Terms(new Term(this.field, startTermText)));
        }
		/// <summary> Enumerates all terms greater/equal than <c>lowerTerm</c>
		/// but less/equal than <c>upperTerm</c>. 
		/// 
		/// If an endpoint is null, it is said to be "open". Either or both 
		/// endpoints may be open.  Open endpoints may not be exclusive 
		/// (you can't select all but the first or last term without 
		/// explicitly specifying the term to exclude.)
		/// 
		/// </summary>
		/// <param name="reader">
		/// </param>
		/// <param name="field">An interned field that holds both lower and upper terms.
		/// </param>
		/// <param name="lowerTermText">The term text at the lower end of the range
		/// </param>
		/// <param name="upperTermText">The term text at the upper end of the range
		/// </param>
		/// <param name="includeLower">If true, the <c>lowerTerm</c> is included in the range.
		/// </param>
		/// <param name="includeUpper">If true, the <c>upperTerm</c> is included in the range.
		/// </param>
		/// <param name="collator">The collator to use to collate index Terms, to determine their
		/// membership in the range bounded by <c>lowerTerm</c> and
		/// <c>upperTerm</c>.
		/// 
		/// </param>
		/// <throws>  IOException </throws>
		public TermRangeTermEnum(IndexReader reader, System.String field, System.String lowerTermText, System.String upperTermText, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator)
		{
			this.collator = collator;
			this.upperTermText = upperTermText;
			this.lowerTermText = lowerTermText;
			this.includeLower = includeLower;
			this.includeUpper = includeUpper;
			this.field = StringHelper.Intern(field);
			
			// do a little bit of normalization...
			// open ended range queries should always be inclusive.
			if (this.lowerTermText == null)
			{
				this.lowerTermText = "";
				this.includeLower = true;
			}
			
			if (this.upperTermText == null)
			{
				this.includeUpper = true;
			}
			
			System.String startTermText = collator == null?this.lowerTermText:"";
			SetEnum(reader.Terms(new Term(this.field, startTermText)));
		}
Пример #6
0
        static int CompareInfo_internal_compare(System.Globalization.CompareInfo ci, string str1, int offset1,
                                                int length1, string str2, int offset2, int length2, System.Globalization.CompareOptions options)
        {
            /* Based off the mono implementation */

            int length = length1;

            if (length2 > length)
            {
                length = length2;
            }

            if ((offset1 + length) > str1.Length)
            {
                throw new Exception("Trying to compare more characters than exist in str1");
            }
            if ((offset2 + length) > str2.Length)
            {
                throw new Exception("Trying to compare more characters than exist in str2");
            }

            for (int i = 0; i < length; i++)
            {
                int cc = compare_char(str1[offset1 + i], str2[offset2 + i], options);
                if (cc != 0)
                {
                    return(cc);
                }
            }

            return(0);
        }
Пример #7
0
            public int Compare(String a, String b)
            {
                if (a == b)
                {
                    return(0);
                }
                if (a == null)
                {
                    return(-1);
                }
                if (b == null)
                {
                    return(1);
                }

                string sa = a as string;
                string sb = b as string;

                System.Globalization.CompareInfo myComparer = System.Globalization.CompareInfo.GetCompareInfo("en-US");
                if (sa != null && sb != null)
                {
                    return(myComparer.Compare(sa, sb, System.Globalization.CompareOptions.Ordinal));
                }
                throw new ArgumentException("a and b should be strings.");
            }
Пример #8
0
        /// <summary> Compares the the attributes of the first LdapEntry to the second.
        /// Only the values of the attributes named at the construction of this
        /// object will be compared.  Multi-valued attributes compare on the first
        /// value only.
        ///
        /// </summary>
        /// <param name="object1">        Target entry for comparison.
        ///
        /// </param>
        /// <param name="object2">        Entry to be compared to.
        ///
        /// </param>
        /// <returns>     Negative value if the first entry is less than the second and
        /// positive if the first is greater than the second.  Zero is returned if all
        /// attributes to be compared are the same.
        /// </returns>
        public virtual int Compare(object object1, object object2)
        {
            LdapEntry     entry1 = (LdapEntry)object1;
            LdapEntry     entry2 = (LdapEntry)object2;
            LdapAttribute one, two;

            string[] first;  //multivalued attributes are ignored.
            string[] second; //we just use the first element
            int      compare, i = 0;

            if (collator == null)
            {
                //using default locale
                collator = System.Globalization.CultureInfo.CurrentCulture.CompareInfo;
            }

            do
            {
                //while first and second are equal
                one = entry1.getAttribute(sortByNames[i]);
                two = entry2.getAttribute(sortByNames[i]);
                if ((one != null) && (two != null))
                {
                    first   = one.StringValueArray;
                    second  = two.StringValueArray;
                    compare = collator.Compare(first[0], second[0]);
                }
                //We could also use the other multivalued attributes to break ties.
                //one of the entries was null
                else
                {
                    if (one != null)
                    {
                        compare = -1;
                    }
                    //one is greater than two
                    else if (two != null)
                    {
                        compare = 1;
                    }
                    //one is lesser than two
                    else
                    {
                        compare = 0; //tie - break it with the next attribute name
                    }
                }

                i++;
            }while ((compare == 0) && (i < sortByNames.Length));

            if (sortAscending[i - 1])
            {
                // return the normal ascending comparison.
                return(compare);
            }
            // negate the comparison for a descending comparison.
            return(-compare);
        }
Пример #9
0
 /// <summary>Constructs a query selecting all terms greater/equal than
 /// <code>lowerTerm</code> but less/equal than <code>upperTerm</code>.
 /// <p/>
 /// If an endpoint is null, it is said
 /// to be "open". Either or both endpoints may be open.  Open endpoints may not
 /// be exclusive (you can't select all but the first or last term without
 /// explicitly specifying the term to exclude.)
 /// <p/>
 /// If <code>collator</code> is not null, it will be used to decide whether
 /// index terms are within the given range, rather than using the Unicode code
 /// point order in which index terms are stored.
 /// <p/>
 /// <strong>WARNING:</strong> Using this constructor and supplying a non-null
 /// value in the <code>collator</code> parameter will cause every single
 /// index Term in the Field referenced by lowerTerm and/or upperTerm to be
 /// examined.  Depending on the number of index Terms in this Field, the
 /// operation could be very slow.
 ///
 /// </summary>
 /// <param name="lowerTerm">The Term text at the lower end of the range
 /// </param>
 /// <param name="upperTerm">The Term text at the upper end of the range
 /// </param>
 /// <param name="includeLower">If true, the <code>lowerTerm</code> is
 /// included in the range.
 /// </param>
 /// <param name="includeUpper">If true, the <code>upperTerm</code> is
 /// included in the range.
 /// </param>
 /// <param name="collator">The collator to use to collate index Terms, to determine
 /// their membership in the range bounded by <code>lowerTerm</code> and
 /// <code>upperTerm</code>.
 /// </param>
 public TermRangeQuery(System.String field, System.String lowerTerm, System.String upperTerm, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator)
 {
     this.field        = field;
     this.lowerTerm    = lowerTerm;
     this.upperTerm    = upperTerm;
     this.includeLower = includeLower;
     this.includeUpper = includeUpper;
     this.collator     = collator;
 }
Пример #10
0
 // Fetch the HTML Title from remote page
 public void GetTitle()
 {
     // Check Prefix
     System.Globalization.CompareInfo cmpUrl = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
     if (cmpUrl.IsPrefix(this.tb_LinkUrl.Text, "http") == false)
     {
         this.tb_LinkUrl.Text = "http://" + this.tb_LinkUrl.Text;
     }
 }
Пример #11
0
        /// <summary>
        /// 指定した文字列内の指定した文字列を別の文字列に置換する。
        /// </summary>
        /// <param name="input">置換する文字列のある文字列。</param>
        /// <param name="oldValue">検索文字列。</param>
        /// <param name="newValue">置換文字列。</param>
        /// <param name="count">置換する回数。負の数が指定されたときは、すべて置換する。</param>
        /// <param name="compInfo">文字列の検索に使用するCompareInfo。</param>
        /// <param name="compOptions">文字列の検索に使用するCompareOptions。</param>
        /// <returns>置換された結果の文字列。</returns>
        private static string StringReplace(
            string input, string oldValue, string newValue, int count,
            System.Globalization.CompareInfo compInfo,
            System.Globalization.CompareOptions compOptions)
        {
            if (input == null || input.Length == 0 ||
                oldValue == null || oldValue.Length == 0 ||
                count == 0)
            {
                return(input);
            }

            if (compInfo == null)
            {
                compInfo    = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
                compOptions = System.Globalization.CompareOptions.Ordinal;
            }

            int inputLen    = input.Length;
            int oldValueLen = oldValue.Length;

            System.Text.StringBuilder buf = new System.Text.StringBuilder(inputLen);

            int currentPoint = 0;
            int foundPoint   = -1;
            int currentCount = 0;

            do
            {
                //文字列を検索する
                foundPoint = compInfo.IndexOf(input, oldValue, currentPoint, compOptions);
                if (foundPoint < 0)
                {
                    buf.Append(input.Substring(currentPoint));
                    break;
                }

                //見つかった文字列を新しい文字列に換える
                buf.Append(input.Substring(currentPoint, foundPoint - currentPoint));
                buf.Append(newValue);

                //次の検索開始位置を取得
                currentPoint = foundPoint + oldValueLen;

                //指定回数置換したか調べる
                currentCount++;
                if (currentCount == count)
                {
                    buf.Append(input.Substring(currentPoint));
                    break;
                }
            }while (currentPoint < inputLen);

            return(buf.ToString());
        }
Пример #12
0
 static private void getBoneOrder(ref int order, ref BoneCategory category, string source, string query, BoneCategory setCategory = BoneCategory.Other)
 {
     System.Globalization.CompareInfo ci = System.Globalization.CultureInfo.CurrentCulture.CompareInfo;
     //source内にqueryが含まれていた場合、序数とカテゴリを代入
     if (0 <= ci.IndexOf(source, query, System.Globalization.CompareOptions.IgnoreWidth))
     {
         order    = orderCount;
         category = setCategory;
     }
     orderCount++;
 }
Пример #13
0
        /// <summary>
        /// ReSort elements in the parent of <c>node</c>
        /// </summary>
        /// <remarks>
        /// Get the parent of this node and resort this node in the
        /// collection of nodes. We only operate on this node and we
        /// assume all nodes are already sorted except for this node
        /// </remarks>
        /// <param name="node">The node to sort</param>
        private void ReSortNodes(TreeNode node)
        {
            // We need to sort the node and rename it
            TreeNode parent = node.Parent;

            if (parent != null)
            {
                int newindex = -1;
                int curindex = -1;

                System.Globalization.CompareInfo comp =
                    System.Globalization.CultureInfo.CurrentCulture.CompareInfo;

                for (int i = 0; i < parent.Nodes.Count; i++)
                {
                    TreeNode tnode = parent.Nodes[i];

                    // We assume that the collection is already sorted
                    if (newindex == -1 &&
                        comp.Compare(node.Text, tnode.Text) < 0)
                    {
                        newindex = i;
                    }
                    if (node == tnode)
                    {
                        curindex = i;
                    }
                }

                if (curindex != -1)
                {
                    // We found the node we're editing.
                    if (newindex == -1)
                    {
                        // This node is to be put at the end
                        newindex = parent.Nodes.Count - 1;
                    }

                    if (curindex < newindex)
                    {
                        --newindex;
                    }

                    SelectedNode = null;
                    BeginUpdate();
                    parent.Nodes.RemoveAt(curindex);
                    parent.Nodes.Insert(newindex, node);
                    EndUpdate();
                }
            }
        }
Пример #14
0
        /// <summary>Constructs a query selecting all terms greater than
        /// <code>lowerTerm</code> but less than <code>upperTerm</code>.
        /// There must be at least one term and either term may be null,
        /// in which case there is no bound on that side, but if there are
        /// two terms, both terms <b>must</b> be for the same field.
        /// <p/>
        /// If <code>collator</code> is not null, it will be used to decide whether
        /// index terms are within the given range, rather than using the Unicode code
        /// point order in which index terms are stored.
        /// <p/>
        /// <strong>WARNING:</strong> Using this constructor and supplying a non-null
        /// value in the <code>collator</code> parameter will cause every single
        /// index Term in the Field referenced by lowerTerm and/or upperTerm to be
        /// examined.  Depending on the number of index Terms in this Field, the
        /// operation could be very slow.
        ///
        /// </summary>
        /// <param name="lowerTerm">The Term at the lower end of the range
        /// </param>
        /// <param name="upperTerm">The Term at the upper end of the range
        /// </param>
        /// <param name="inclusive">If true, both <code>lowerTerm</code> and
        /// <code>upperTerm</code> will themselves be included in the range.
        /// </param>
        /// <param name="collator">The collator to use to collate index Terms, to determine
        /// their membership in the range bounded by <code>lowerTerm</code> and
        /// <code>upperTerm</code>.
        /// </param>
        public RangeQuery(Term lowerTerm, Term upperTerm, bool inclusive, System.Globalization.CompareInfo collator)
        {
            if (lowerTerm == null && upperTerm == null)
            {
                throw new System.ArgumentException("At least one term must be non-null");
            }
            if (lowerTerm != null && upperTerm != null && (System.Object)lowerTerm.Field() != (System.Object)upperTerm.Field())
            {
                throw new System.ArgumentException("Both terms must have the same field");
            }

            delegate_Renamed = new TermRangeQuery((lowerTerm == null)?upperTerm.Field():lowerTerm.Field(), (lowerTerm == null)?null:lowerTerm.Text(), (upperTerm == null)?null:upperTerm.Text(), inclusive, inclusive, collator);
            delegate_Renamed.SetRewriteMethod(TermRangeQuery.SCORING_BOOLEAN_QUERY_REWRITE);
        }
Пример #15
0
        internal CultureInfo(string cultureName, string textAndCompareCultureName)
        {
            if (cultureName == null)
            {
                throw new ArgumentNullException("cultureName", Environment.GetResourceString("ArgumentNull_String"));
            }
            this.m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(cultureName, false);
            this.cultureID            = this.m_cultureTableRecord.ActualCultureID;
            this.m_name = this.m_cultureTableRecord.ActualName;
            CultureInfo cultureInfo = GetCultureInfo(textAndCompareCultureName);

            this.compareInfo = cultureInfo.CompareInfo;
            this.textInfo    = cultureInfo.TextInfo;
        }
Пример #16
0
		public BplusTreeLong(System.IO.Stream fromfile, int NodeSize, int KeyLength, long StartSeek, int CultureId)
		{
			this.cultureContext = new System.Globalization.CultureInfo(CultureId);
			this.cmp = this.cultureContext.CompareInfo;
			this.fromfile = fromfile;
			this.NodeSize = NodeSize;
			this.seekStart = StartSeek;
			// add in key prefix overhead
			this.KeyLength = KeyLength + BufferFile.SHORTSTORAGE;
			this.rootSeek = NULLBUFFERNUMBER;
			this.root = null;
			this.freeHeadSeek = NULLBUFFERNUMBER;
			this.SanityCheck();
		}
Пример #17
0
 /// <summary>Returns an array of collators, possibly <code>null</code>.  The collators
 /// correspond to any SortFields which were given a specific locale.
 /// </summary>
 /// <param name="fields">Array of sort fields.
 /// </param>
 /// <returns> Array, possibly <code>null</code>.
 /// </returns>
 private System.Globalization.CompareInfo[] HasCollators(SortField[] fields)
 {
     if (fields == null)
     {
         return(null);
     }
     System.Globalization.CompareInfo[] ret = new System.Globalization.CompareInfo[fields.Length];
     for (int i = 0; i < fields.Length; ++i)
     {
         System.Globalization.CultureInfo locale = fields[i].GetLocale();
         if (locale != null)
         {
             ret[i] = locale.CompareInfo;
         }
     }
     return(ret);
 }
Пример #18
0
 /// <summary>Returns an array of collators, possibly <c>null</c>.  The collators
 /// correspond to any SortFields which were given a specific locale.
 /// </summary>
 /// <param name="fields">Array of sort fields.</param>
 /// <returns> Array, possibly <c>null</c>.</returns>
 private System.Globalization.CompareInfo[] HasCollators(ArraySegment <SortField> fields)
 {
     if (fields == null)
     {
         return(null);
     }
     System.Globalization.CompareInfo[] ret = new System.Globalization.CompareInfo[fields.Count];
     for (int i = 0; i < fields.Count; ++i)
     {
         System.Globalization.CultureInfo locale = fields.Array[i + fields.Offset].Locale;
         if (locale != null)
         {
             ret[i] = locale.CompareInfo;
         }
     }
     return(ret);
 }
        internal CultureInfo(string cultureName, string textAndCompareCultureName)
        {
            this.cultureID = 0x7f;
            if (cultureName == null)
            {
                throw new ArgumentNullException("cultureName", Environment.GetResourceString("ArgumentNull_String"));
            }
            this.m_cultureData = CultureData.GetCultureData(cultureName, false);
            if (this.m_cultureData == null)
            {
                throw new CultureNotFoundException("cultureName", cultureName, Environment.GetResourceString("Argument_CultureNotSupported"));
            }
            this.m_name = this.m_cultureData.CultureName;
            CultureInfo cultureInfo = GetCultureInfo(textAndCompareCultureName);

            this.compareInfo = cultureInfo.CompareInfo;
            this.textInfo    = cultureInfo.TextInfo;
        }
Пример #20
0
        public static bool IsValidUrl(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(false);
            }
            System.Globalization.CompareInfo cmpUrl = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
            if (cmpUrl.IsPrefix(url, "http://") == false && cmpUrl.IsPrefix(url, "https://") == false)
            {
                url = "http://" + url;
            }

            //Regex urlRegex = new Regex("(^|[^\\w'\"]|\\G)(?<uri>(?:https?|ftp)&#58;&#47;&#47;(?:[^./\\s'\"<)\\]]+\\.)+[^./\\s'\"<)\\]]+(?:&#47;.*?)?)(\\.[\\s<'\"]|[\\s,<'\"]|$)", RegexOptions.Compiled | RegexOptions.IgnoreCase); // Regex("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(/?([^#]*))?(#(.*))?");
            //^((https?|ftp)://|(www|ftp)\.)[a-z0-9-]+(\.[a-z0-9-]+)+([/?].*)?$
            Regex urlRegex = new Regex("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(/?([^#]*))?(#(.*))?");

            return(urlRegex.IsMatch(url));
        }
Пример #21
0
        static int internal_index(System.Globalization.CompareInfo _this, string source, int sIndex, int count, string value, System.Globalization.CompareOptions options, bool first)
        {
            // if first == true find first incidence, else find last

            if (first)
            {
                for (int i = sIndex; i < (sIndex + count); i++)
                {
                    bool found = true;
                    for (int j = 0; j < value.Length; j++)
                    {
                        if (source[j + i] != value[j])
                        {
                            found = false;
                            break;
                        }
                    }
                    if (found)
                    {
                        return(i);
                    }
                }
            }
            else
            {
                for (int i = (sIndex + count - 1); i >= sIndex; i--)
                {
                    bool found = true;
                    for (int j = 0; j < value.Length; j++)
                    {
                        if (source[j + i] != value[j])
                        {
                            found = false;
                            break;
                        }
                    }
                    if (found)
                    {
                        return(i);
                    }
                }
            }
            return(-1);
        }
Пример #22
0
        public static bool IsValidUrl(string url)
        {
            bool bResponse = false;

            System.Globalization.CompareInfo cmpUrl = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
            if (cmpUrl.IsPrefix(url, @"http://", System.Globalization.CompareOptions.IgnoreCase) == false)
            {
                url = @"http://" + url;
            }
            Regex RgxUrl = new Regex(@"^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~])*[^\.\,\)\(\s]$", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            if (RgxUrl.IsMatch(url))
            {
                bResponse = true;
            }
            else
            {
                bResponse = false;
            }
            return(bResponse);
        }
Пример #23
0
            /*
             * <summary>Customised Compare Class</summary>
             * <remarks>
             * <para>
             * The Virtual Payment Client need to use an Ordinal comparison to Sort on
             * the field names to create the SHA256 Signature for validation of the message.
             * This class provides a Compare method that is used to allow the sorted list
             * to be ordered using an Ordinal comparison.
             * </para>
             * </remarks>
             */

            public int Compare(String a, String b)
            {
                /*
                 * <summary>Compare method using Ordinal comparison</summary>
                 * <param name="a">The first string in the comparison.</param>
                 * <param name="b">The second string in the comparison.</param>
                 * <returns>An int containing the result of the comparison.</returns>
                 */

                // Return if we are comparing the same object or one of the
                // objects is null, since we don't need to go any further.
                if (a == b)
                {
                    return(0);
                }
                if (a == null)
                {
                    return(-1);
                }
                if (b == null)
                {
                    return(1);
                }

                // Ensure we have string to compare
                string sa = a as string;
                string sb = b as string;

                // Get the CompareInfo object to use for comparing
                System.Globalization.CompareInfo myComparer = System.Globalization.CompareInfo.GetCompareInfo("en-US");
                if (sa != null && sb != null)
                {
                    // Compare using an Ordinal Comparison.
                    return(myComparer.Compare(sa, sb, System.Globalization.CompareOptions.Ordinal));
                }
                throw new ArgumentException("a and b should be strings.");
            }
Пример #24
0
        static StackObject *Compare_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.String @string2 = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @string1 = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Globalization.CompareInfo instance_of_this_method = (System.Globalization.CompareInfo) typeof(System.Globalization.CompareInfo).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Compare(@string1, @string2);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method;
            return(__ret + 1);
        }
Пример #25
0
			internal StringComparatorLocale(int numHits, System.String field, System.Globalization.CultureInfo locale)
			{
				values = new System.String[numHits];
				this.field = field;
				collator = locale.CompareInfo;
			}
Пример #26
0
		/// <summary>Constructs a query selecting all terms greater/equal than
		/// <code>lowerTerm</code> but less/equal than <code>upperTerm</code>.
		/// <p/>
		/// If an endpoint is null, it is said 
		/// to be "open". Either or both endpoints may be open.  Open endpoints may not 
		/// be exclusive (you can't select all but the first or last term without 
		/// explicitly specifying the term to exclude.)
		/// <p/>
		/// If <code>collator</code> is not null, it will be used to decide whether
		/// index terms are within the given range, rather than using the Unicode code
		/// point order in which index terms are stored.
		/// <p/>
		/// <strong>WARNING:</strong> Using this constructor and supplying a non-null
		/// value in the <code>collator</code> parameter will cause every single 
		/// index Term in the Field referenced by lowerTerm and/or upperTerm to be
		/// examined.  Depending on the number of index Terms in this Field, the 
		/// operation could be very slow.
		/// 
		/// </summary>
		/// <param name="lowerTerm">The Term text at the lower end of the range
		/// </param>
		/// <param name="upperTerm">The Term text at the upper end of the range
		/// </param>
		/// <param name="includeLower">If true, the <code>lowerTerm</code> is
		/// included in the range.
		/// </param>
		/// <param name="includeUpper">If true, the <code>upperTerm</code> is
		/// included in the range.
		/// </param>
		/// <param name="collator">The collator to use to collate index Terms, to determine
		/// their membership in the range bounded by <code>lowerTerm</code> and
		/// <code>upperTerm</code>.
		/// </param>
		public TermRangeQuery(System.String field, System.String lowerTerm, System.String upperTerm, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator)
		{
			this.field = field;
			this.lowerTerm = lowerTerm;
			this.upperTerm = upperTerm;
			this.includeLower = includeLower;
			this.includeUpper = includeUpper;
			this.collator = collator;
		}
 internal CultureInfo(string cultureName, string textAndCompareCultureName)
 {
     this.cultureID = 0x7f;
     if (cultureName == null)
     {
         throw new ArgumentNullException("cultureName", Environment.GetResourceString("ArgumentNull_String"));
     }
     this.m_cultureData = CultureData.GetCultureData(cultureName, false);
     if (this.m_cultureData == null)
     {
         throw new CultureNotFoundException("cultureName", cultureName, Environment.GetResourceString("Argument_CultureNotSupported"));
     }
     this.m_name = this.m_cultureData.CultureName;
     CultureInfo cultureInfo = GetCultureInfo(textAndCompareCultureName);
     this.compareInfo = cultureInfo.CompareInfo;
     this.textInfo = cultureInfo.TextInfo;
 }
 private void  InitBlock(System.String[] index, System.Globalization.CompareInfo collator)
 {
     this.index    = index;
     this.collator = collator;
 }
Пример #29
0
 internal StringComparatorLocale(int numHits, System.String field, System.Globalization.CultureInfo locale)
 {
     values     = new System.String[numHits];
     this.field = field;
     collator   = locale.CompareInfo;
 }
Пример #30
0
 public AnonymousClassScoreDocComparator3(System.Globalization.CompareInfo collator, System.String[] index)
 {
     InitBlock(collator, index);
 }
Пример #31
0
 private void InitBlock()
 {
     //			location = Locale.getDefault();
     location=System.Globalization.CultureInfo.CurrentCulture;
     collator = System.Globalization.CultureInfo.CurrentCulture.CompareInfo;
 }
Пример #32
0
        /// <summary> Compares the the attributes of the first LdapEntry to the second.
        /// Only the values of the attributes named at the construction of this
        /// object will be compared.  Multi-valued attributes compare on the first
        /// value only.  
        /// 
        /// </summary>
        /// <param name="object1">        Target entry for comparison.
        /// 
        /// </param>
        /// <param name="object2">        Entry to be compared to.
        /// 
        /// </param>
        /// <returns>     Negative value if the first entry is less than the second and
        /// positive if the first is greater than the second.  Zero is returned if all
        /// attributes to be compared are the same.
        /// </returns>
        public virtual int Compare(System.Object object1, System.Object object2)
        {
            LdapEntry entry1 = (LdapEntry) object1;
            LdapEntry entry2 = (LdapEntry) object2;
            LdapAttribute one, two;
            System.String[] first; //multivalued attributes are ignored.
            System.String[] second; //we just use the first element
            int compare, i = 0;
            if (collator == null)
            {
                //using default locale
                collator = System.Globalization.CultureInfo.CurrentCulture.CompareInfo;
            }

            do
            {
                //while first and second are equal
                one = entry1.getAttribute(sortByNames[i]);
                two = entry2.getAttribute(sortByNames[i]);
                if ((one != null) && (two != null))
                {
                    first = one.StringValueArray;
                    second = two.StringValueArray;
                    compare = collator.Compare(first[0], second[0]);
                }
                //We could also use the other multivalued attributes to break ties.
                //one of the entries was null
                else
                {
                    if (one != null)
                        compare = - 1;
                    //one is greater than two
                    else if (two != null)
                        compare = 1;
                    //one is lesser than two
                    else
                        compare = 0; //tie - break it with the next attribute name
                }

                i++;
            }
            while ((compare == 0) && (i < sortByNames.Length));

            if (sortAscending[i - 1])
            {
                // return the normal ascending comparison.
                return compare;
            }
            else
            {
                // negate the comparison for a descending comparison.
                return - compare;
            }
        }
Пример #33
0
 public RangeQuery(Term lowerTerm, Term upperTerm, bool inclusive, CompareInfo collator)
     : this(lowerTerm, upperTerm, inclusive)
 {
     this.collator = collator;
 }
Пример #34
0
 /// <summary> <strong>WARNING:</strong> Using this constructor and supplying a non-null
 /// value in the <code>collator</code> parameter will cause every single
 /// index Term in the Field referenced by lowerTerm and/or upperTerm to be
 /// examined.  Depending on the number of index Terms in this Field, the
 /// operation could be very slow.
 ///
 /// </summary>
 /// <param name="lowerTerm">The lower bound on this range
 /// </param>
 /// <param name="upperTerm">The upper bound on this range
 /// </param>
 /// <param name="includeLower">Does this range include the lower bound?
 /// </param>
 /// <param name="includeUpper">Does this range include the upper bound?
 /// </param>
 /// <param name="collator">The collator to use when determining range inclusion; set
 /// to null to use Unicode code point ordering instead of collation.
 /// </param>
 /// <throws>  IllegalArgumentException if both terms are null or if </throws>
 /// <summary>  lowerTerm is null and includeLower is true (similar for upperTerm
 /// and includeUpper)
 /// </summary>
 public RangeFilter(System.String fieldName, System.String lowerTerm, System.String upperTerm, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator) : base(new TermRangeQuery(fieldName, lowerTerm, upperTerm, includeLower, includeUpper, collator))
 {
 }
Пример #35
0
 /// <summary>
 /// WARNING: Using this constructor and supplying a non-null
 /// value in the collator paramter will cause every single
 /// index Term in the Field referenced by lowerTerm and/or upperTerm
 /// to be examined.  Depending on the number of index Terms in this 
 /// Field, the operation could be very slow.
 /// </summary>
 /// <param name="fieldName"></param>
 /// <param name="lowerTerm">lower bound</param>
 /// <param name="upperTerm">upper bound</param>
 /// <param name="includeLower">is lower bound inclusive</param>
 /// <param name="includeUpper">is upper bound inclusive</param>
 /// <param name="collator">the collator that determines range inclusion; when set to null Unicode code point ordering is used</param>
 public RangeFilter(string fieldName, string lowerTerm, string upperTerm, bool includeLower, bool includeUpper, CompareInfo collator)
     : this(fieldName, lowerTerm, upperTerm, includeLower, includeUpper)
 {
     this.collator = collator;
 }
Пример #36
0
		/// <summary> Sets the collator used to determine index term inclusion in ranges
		/// for RangeQuerys.
		/// <p/>
		/// <strong>WARNING:</strong> Setting the rangeCollator to a non-null
		/// collator using this method will cause every single index Term in the
		/// Field referenced by lowerTerm and/or upperTerm to be examined.
		/// Depending on the number of index Terms in this Field, the operation could
		/// be very slow.
		/// 
		/// </summary>
		/// <param name="rc"> the collator to use when constructing RangeQuerys
		/// </param>
		public virtual void  SetRangeCollator(System.Globalization.CompareInfo rc)
		{
			rangeCollator = rc;
		}
Пример #37
0
 public int Compare(string left, string right, bool caseSensitive)
 {
     if (!caseSensitive) {
         left = left.ToLower();
         right = right.ToLower();
     }
     //System.Globalization.CompareInfo cmp = this.cultureContext.CompareInfo;
     if (this.cultureContext==null || this.DontUseCulture)
     {
         // no culture context: use miscellaneous total ordering on unicode strings
         int i = 0;
         while (i<left.Length && i<right.Length)
         {
             int leftOrd = Convert.ToInt32(left[i]);
             int rightOrd = Convert.ToInt32(right[i]);
             if (leftOrd<rightOrd)
             {
                 return -1;
             }
             if (leftOrd>rightOrd)
             {
                 return 1;
             }
             i++;
         }
         if (left.Length<right.Length)
         {
             return -1;
         }
         if (left.Length>right.Length)
         {
             return 1;
         }
         return 0;
     }
     if (this.cmp==null)
     {
         this.cmp = this.cultureContext.CompareInfo;
     }
     return this.cmp.Compare(left, right);
 }
Пример #38
0
        static string InternalReplace(string str, string old_value, string new_value, System.Globalization.CompareInfo ci)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < str.Length; i++)
            {
                bool found = true;
                for (int j = 0; j < old_value.Length; j++)
                {
                    if (((i + j) >= str.Length) || (str[i + j] != old_value[j]))
                    {
                        found = false;
                        break;
                    }
                }

                if (found)
                {
                    sb.Append(new_value);
                    i += old_value.Length;
                    i--;        // the for loop adds a 1 for us
                }
                else
                {
                    sb.Append(str[i]);
                }
            }

            return(sb.ToString());
        }
 public ConstantScoreRangeQuery(string fieldName, string lowerVal, string upperVal, bool includeLower, bool includeUpper, CompareInfo collator)
     : this(fieldName, lowerVal, upperVal, includeLower, includeUpper)
 {
     this.collator = collator;
 }
Пример #40
0
 /// <summary>
 /// WARNING: Using this constructor and supplying a non-null
 /// value in the collator paramter will cause every single
 /// index Term in the Field referenced by lowerTerm and/or upperTerm
 /// to be examined.  Depending on the number of index Terms in this
 /// Field, the operation could be very slow.
 /// </summary>
 /// <param name="fieldName"></param>
 /// <param name="lowerTerm">lower bound</param>
 /// <param name="upperTerm">upper bound</param>
 /// <param name="includeLower">is lower bound inclusive</param>
 /// <param name="includeUpper">is upper bound inclusive</param>
 /// <param name="collator">the collator that determines range inclusion; when set to null Unicode code point ordering is used</param>
 public RangeFilter(string fieldName, string lowerTerm, string upperTerm, bool includeLower, bool includeUpper, CompareInfo collator)
     : this(fieldName, lowerTerm, upperTerm, includeLower, includeUpper)
 {
     this.collator = collator;
 }
Пример #41
0
 private void InitBlock(System.String[] index, System.Globalization.CompareInfo collator)
 {
     this.index = index;
     this.collator = collator;
 }
 public AnonymousClassScoreDocComparator5(System.String[] index, System.Globalization.CompareInfo collator)
 {
     InitBlock(index, collator);
 }
		/// <summary>Returns an array of collators, possibly <code>null</code>.  The collators
		/// correspond to any SortFields which were given a specific locale.
		/// </summary>
		/// <param name="fields">Array of sort fields.
		/// </param>
		/// <returns> Array, possibly <code>null</code>.
		/// </returns>
		private System.Globalization.CompareInfo[] HasCollators(SortField[] fields)
		{
			if (fields == null)
				return null;
			System.Globalization.CompareInfo[] ret = new System.Globalization.CompareInfo[fields.Length];
			for (int i = 0; i < fields.Length; ++i)
			{
				System.Globalization.CultureInfo locale = fields[i].GetLocale();
				if (locale != null)
					ret[i] = locale.CompareInfo;
			}
			return ret;
		}
Пример #44
0
 internal CultureInfo(string cultureName, string textAndCompareCultureName)
 {
     if (cultureName == null)
     {
         throw new ArgumentNullException("cultureName", Environment.GetResourceString("ArgumentNull_String"));
     }
     this.m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(cultureName, false);
     this.cultureID = this.m_cultureTableRecord.ActualCultureID;
     this.m_name = this.m_cultureTableRecord.ActualName;
     CultureInfo cultureInfo = GetCultureInfo(textAndCompareCultureName);
     this.compareInfo = cultureInfo.CompareInfo;
     this.textInfo = cultureInfo.TextInfo;
 }
Пример #45
0
        /// <summary>macro for readability </summary>
        public static Query Csrq(System.String f, System.String l, System.String h, bool il, bool ih, System.Globalization.CompareInfo c)
        {
            TermRangeQuery query = new TermRangeQuery(f, l, h, il, ih, c);

            query.SetRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
            return(query);
        }