Exemplo n.º 1
0
 public static string Substring(string self, int startIndex, int length)
 {
     if (startIndex < 0)
     {
         throw new ArgumentOutOfRangeException("startIndex");
     }
     if (startIndex > self.Length)
     {
         throw new ArgumentOutOfRangeException("startIndex");
     }
     if (length < 0)
     {
         throw new ArgumentOutOfRangeException("length");
     }
     if (startIndex > self.Length - length)
     {
         throw new ArgumentOutOfRangeException("length");
     }
     if (length == 0)
     {
         return(string.Empty);
     }
     if ((startIndex == 0) && (length == self.Length))
     {
         return(self);
     }
     return(Intrinsics.ToJavaString(self).substring(startIndex, startIndex + length));
 }
Exemplo n.º 2
0
 public static int Compare(string strA, string strB, bool ignoreCase)
 {
     if (ignoreCase)
     {
         return(Intrinsics.ToJavaString(strA).compareToIgnoreCase(strB));
     }
     return(Intrinsics.ToJavaString(strA).compareTo(strB));
 }
Exemplo n.º 3
0
 public static int CompareTo(string self, object value)
 {
     if (value == null)
     {
         return(1);
     }
     if (!(value is string))
     {
         throw new ArgumentException(Local.GetText("value must be string"));
     }
     return(Intrinsics.ToJavaString(self).compareTo((string)value));
 }
Exemplo n.º 4
0
 public static string Concat(object arg0, object arg1)
 {
     if (arg0 == null)
     {
         arg0 = string.Empty;
     }
     if (arg1 == null)
     {
         arg1 = string.Empty;
     }
     return(Intrinsics.ToJavaString(arg0.ToString()).concat(arg0.ToString()));
 }
Exemplo n.º 5
0
        public static string Concat(string str0, string str1)
        {
            if (str0 == null)
            {
                str0 = string.Empty;
            }
            if (str1 == null)
            {
                str1 = string.Empty;
            }

            return(Intrinsics.ToJavaString(str0).concat(str1));
        }
Exemplo n.º 6
0
 public static char[] ToCharArray(string self, int startIndex, int length)
 {
     if ((startIndex < 0) || (startIndex > self.Length) || (startIndex > self.Length - length))
     {
         throw new ArgumentOutOfRangeException("startIndex");
     }
     if (length < 0)
     {
         throw new ArgumentOutOfRangeException("length");
     }
     char[] result = new char[length];
     Intrinsics.ToJavaString(self).getChars(startIndex, startIndex + length, result, 0);
     return(result);
 }
Exemplo n.º 7
0
        private static string TrimWorker(string self, char[] trimChars, bool fromStart, bool fromEnd)
        {
            int startIndex = 0;
            int endIndex   = self.Length;

            if (fromStart)
            {
                for (int i = 0; i < self.Length; i++)
                {
                    char ch = self[i];
                    for (int j = 0; j < trimChars.Length; j++)
                    {
                        if (ch == trimChars[j])
                        {
                            startIndex = i + 1;
                            break;
                        }
                    }

                    if (startIndex == i)
                    {
                        break;
                    }
                }
            }

            if (fromEnd)
            {
                for (int i = self.Length - 1; i >= 0; i--)
                {
                    char ch = self[i];
                    for (int j = 0; j < trimChars.Length; j++)
                    {
                        if (ch == trimChars[j])
                        {
                            endIndex = i;
                            break;
                        }
                    }

                    if (endIndex == i + 1)
                    {
                        break;
                    }
                }
            }

            return(Intrinsics.ToJavaString(self).substring(startIndex, endIndex));
        }
Exemplo n.º 8
0
        private static string TrimWorker(string self, bool fromStart, bool fromEnd)
        {
            int startIndex = 0;
            int endIndex   = self.Length;

            if (fromStart)
            {
                for (int i = 0; i < self.Length; i++)
                {
                    if (char.IsWhiteSpace(self[i]))
                    {
                        startIndex = i + 1;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (fromEnd)
            {
                for (int i = self.Length - 1; i >= 0; i--)
                {
                    if (char.IsWhiteSpace(self[i]))
                    {
                        endIndex = i;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(Intrinsics.ToJavaString(self).substring(startIndex, endIndex));
        }
Exemplo n.º 9
0
 public static void CopyTo(string self, int sourceIndex, char[] destination, int destinationIndex, int count)
 {
     if (destination == null)
     {
         throw new ArgumentNullException("destination");
     }
     if (count < 0)
     {
         throw new ArgumentOutOfRangeException("count");
     }
     if (sourceIndex < 0)
     {
         throw new ArgumentOutOfRangeException("sourceIndex");
     }
     if (count > self.Length - sourceIndex)
     {
         throw new ArgumentOutOfRangeException("count");
     }
     if (destinationIndex > destination.Length - destinationIndex)
     {
         throw new ArgumentOutOfRangeException("destinationIndex");
     }
     Intrinsics.ToJavaString(self).getChars(sourceIndex, sourceIndex + count, destination, destinationIndex);
 }
Exemplo n.º 10
0
        public static string[] Split(string self, char[] separator, int count, StringSplitOptions options)
        {
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if ((options != StringSplitOptions.None) && (options != StringSplitOptions.RemoveEmptyEntries))
            {
                throw new ArgumentException(Local.GetText("Illegal enum value: {0}.", options));
            }
            if (((self.Length == 0) && (options == StringSplitOptions.RemoveEmptyEntries)) || (count == 0))
            {
                return(Utils.EmptyArray <string> .value);
            }
            if (count == 1)
            {
                return new string[] { self }
            }
            ;

            List <string> result = new List <string>();

            int pos  = 0;
            int last = 0;
            int len  = self.Length;

            while (pos < len)
            {
                char ch = self[pos];

                if ((separator != null) && (separator.Length > 0))
                {
                    for (int i = 0; i < separator.Length; i++)
                    {
                        if (ch == separator[i])
                        {
                            result.Add(Intrinsics.ToJavaString(self).substring(last, pos));
                            last = pos + 1;
                            break;
                        }
                    }
                }
                else
                {
                    if (char.IsWhiteSpace(ch))
                    {
                        result.Add(Intrinsics.ToJavaString(self).substring(last, pos));
                        last = pos + 1;
                    }
                }

                pos++;
            }

            //if (last != pos)
            result.Add(Intrinsics.ToJavaString(self).substring(last, pos));

            if (options == StringSplitOptions.RemoveEmptyEntries)
            {
                for (int i = 0; i < result.Count; i++)
                {
                    if (result[i].Length == 0)
                    {
                        result.RemoveAt(i--);
                    }
                }
            }

            if (result.Count > count)
            {
                result.RemoveRange(count, result.Count - count);
            }

            return(result.ToArray());
        }
Exemplo n.º 11
0
 public static int Compare(string strA, string strB)
 {
     return(Intrinsics.ToJavaString(strA).compareTo(strB));
 }
Exemplo n.º 12
0
 public static string Normalize(string self, NormalizationForm normalizationForm)
 {
     return(java.text.Normalizer.normalize(Intrinsics.ToJavaString(self), ToJavaNormalizeForm(normalizationForm)));
 }
Exemplo n.º 13
0
 public static string Normalize(string self)
 {
     return(java.text.Normalizer.normalize(Intrinsics.ToJavaString(self), java.text.Normalizer.Form.NFC));
 }
Exemplo n.º 14
0
 public static bool IsNormalized(string self)
 {
     return(java.text.Normalizer.isNormalized(Intrinsics.ToJavaString(self), java.text.Normalizer.Form.NFC));
 }
Exemplo n.º 15
0
 public static string Replace(string self, string oldValue, string newValue)
 {
     return(Intrinsics.ToJavaString(self).replace(Intrinsics.ToJavaString(oldValue), Intrinsics.ToJavaString(newValue)));
 }
Exemplo n.º 16
0
 public static string Intern(string str)
 {
     return(Intrinsics.ToJavaString(str).intern());
 }
Exemplo n.º 17
0
 public static bool Contains(string self, string value)
 {
     return(Intrinsics.ToJavaString(self).contains(Intrinsics.ToJavaString(value)));
 }
Exemplo n.º 18
0
 public static int IndexOf(string self, char value, int startIndex)
 {
     return(Intrinsics.ToJavaString(self).indexOf(value, startIndex));
 }
Exemplo n.º 19
0
 public static int LastIndexOf(string self, char value)
 {
     return(Intrinsics.ToJavaString(self).lastIndexOf(value));
 }