1/*
2 * [The "BSD licence"]
3 * Copyright (c) 2005-2008 Terence Parr
4 * All rights reserved.
5 *
6 * Conversion to C#:
7 * Copyright (c) 2008 Sam Harwell, Pixel Mine, Inc.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 *    derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33namespace Antlr.Runtime.JavaExtensions
34{
35    using ObsoleteAttribute = System.ObsoleteAttribute;
36    using Regex = System.Text.RegularExpressions.Regex;
37    using StringBuilder = System.Text.StringBuilder;
38
39    public static class StringExtensions
40    {
41#if DEBUG
42        [Obsolete]
43        public static char charAt( this string str, int index )
44        {
45            return str[index];
46        }
47
48        [Obsolete]
49        public static bool endsWith( this string str, string value )
50        {
51            return str.EndsWith( value );
52        }
53
54        [Obsolete]
55        public static int indexOf( this string str, char value )
56        {
57            return str.IndexOf( value );
58        }
59
60        [Obsolete]
61        public static int indexOf( this string str, char value, int startIndex )
62        {
63            return str.IndexOf( value, startIndex );
64        }
65
66        [Obsolete]
67        public static int indexOf( this string str, string value )
68        {
69            return str.IndexOf( value );
70        }
71
72        [Obsolete]
73        public static int indexOf( this string str, string value, int startIndex )
74        {
75            return str.IndexOf( value, startIndex );
76        }
77
78        [Obsolete]
79        public static int lastIndexOf( this string str, char value )
80        {
81            return str.LastIndexOf( value );
82        }
83
84        [Obsolete]
85        public static int lastIndexOf( this string str, string value )
86        {
87            return str.LastIndexOf( value );
88        }
89
90        [Obsolete]
91        public static int length( this string str )
92        {
93            return str.Length;
94        }
95
96        [Obsolete]
97        public static string replace(this string str, char oldValue, char newValue)
98        {
99            return str.Replace(oldValue, newValue);
100        }
101#endif
102
103        public static string replaceAll( this string str, string regex, string newValue )
104        {
105            return Regex.Replace( str, regex, newValue );
106        }
107
108        public static string replaceFirst( this string str, string regex, string replacement )
109        {
110            return Regex.Replace( str, regex, replacement );
111        }
112
113#if DEBUG
114        [Obsolete]
115        public static bool startsWith( this string str, string value )
116        {
117            return str.StartsWith( value );
118        }
119
120        [Obsolete]
121        public static string substring( this string str, int startOffset )
122        {
123            return str.Substring( startOffset );
124        }
125
126        [Obsolete]
127        public static string substring(this string str, int startOffset, int endOffset)
128        {
129            return str.Substring( startOffset, endOffset - startOffset );
130        }
131
132        [Obsolete]
133        public static char[] toCharArray( this string str )
134        {
135            return str.ToCharArray();
136        }
137
138        [Obsolete]
139        public static string toUpperCase( this string str )
140        {
141            return str.ToUpperInvariant();
142        }
143
144        [Obsolete]
145        public static string trim( this string str )
146        {
147            return str.Trim();
148        }
149#endif
150    }
151}
152