From: Kevin W. <kev...@us...> - 2005-01-01 02:40:38
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26090 Modified Files: StringHelper.cs StringTokenizer.cs Log Message: fix xml documentation and allow ReSharper to reformat Index: StringTokenizer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/StringTokenizer.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StringTokenizer.cs 31 Dec 2004 23:57:07 -0000 1.3 --- StringTokenizer.cs 1 Jan 2005 02:40:28 -0000 1.4 *************** *** 2,17 **** using System.Collections; ! namespace NHibernate.Util { /// <summary> /// A StringTokenizer java like object /// </summary> ! public class StringTokenizer : IEnumerable { ! ! private static readonly string _defaultDelim=" \t\n\r\f"; ! string _origin; ! string _delim; ! bool _returnDelim; ! public StringTokenizer(string str) { _origin = str; _delim = _defaultDelim; --- 2,23 ---- using System.Collections; ! namespace NHibernate.Util ! { /// <summary> /// A StringTokenizer java like object /// </summary> ! public class StringTokenizer : IEnumerable ! { ! private static readonly string _defaultDelim = " \t\n\r\f"; ! private string _origin; ! private string _delim; ! private bool _returnDelim; ! /// <summary> ! /// ! /// </summary> ! /// <param name="str"></param> ! public StringTokenizer( string str ) ! { _origin = str; _delim = _defaultDelim; *************** *** 19,23 **** } ! public StringTokenizer(string str, string delim) { _origin = str; _delim = delim; --- 25,35 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="str"></param> ! /// <param name="delim"></param> ! public StringTokenizer( string str, string delim ) ! { _origin = str; _delim = delim; *************** *** 25,29 **** } ! public StringTokenizer(string str, string delim, bool returnDelims) { _origin = str; _delim = delim; --- 37,48 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="str"></param> ! /// <param name="delim"></param> ! /// <param name="returnDelims"></param> ! public StringTokenizer( string str, string delim, bool returnDelims ) ! { _origin = str; _delim = delim; *************** *** 31,75 **** } ! public IEnumerator GetEnumerator() { ! return new StringTokenizerEnumerator(this); } ! private class StringTokenizerEnumerator : IEnumerator { private StringTokenizer _stokenizer; private int _cursor = 0; private String _next = null; ! ! public StringTokenizerEnumerator(StringTokenizer stok) { _stokenizer = stok; } ! public bool MoveNext() { _next = GetNext(); return _next != null; } ! public void Reset() { _cursor = 0; } ! public object Current { ! get { ! return _next; ! } } ! private string GetNext() { char c; bool isDelim; ! if( _cursor >= _stokenizer._origin.Length ) return null; ! c = _stokenizer._origin[_cursor]; ! isDelim = (_stokenizer._delim.IndexOf(c) != -1); ! ! if ( isDelim ) { _cursor++; ! if ( _stokenizer._returnDelim ) { return c.ToString(); } --- 50,102 ---- } ! /// <summary></summary> ! public IEnumerator GetEnumerator() ! { ! return new StringTokenizerEnumerator( this ); } ! private class StringTokenizerEnumerator : IEnumerator ! { private StringTokenizer _stokenizer; private int _cursor = 0; private String _next = null; ! ! public StringTokenizerEnumerator( StringTokenizer stok ) ! { _stokenizer = stok; } ! public bool MoveNext() ! { _next = GetNext(); return _next != null; } ! public void Reset() ! { _cursor = 0; } ! public object Current ! { ! get { return _next; } } ! private string GetNext() ! { char c; bool isDelim; ! if( _cursor >= _stokenizer._origin.Length ) return null; ! c = _stokenizer._origin[ _cursor ]; ! isDelim = ( _stokenizer._delim.IndexOf( c ) != -1 ); ! ! if( isDelim ) ! { _cursor++; ! if( _stokenizer._returnDelim ) ! { return c.ToString(); } *************** *** 77,86 **** } ! int nextDelimPos = _stokenizer._origin.IndexOfAny(_stokenizer._delim.ToCharArray(), _cursor); ! if (nextDelimPos == -1) { nextDelimPos = _stokenizer._origin.Length; } ! string nextToken = _stokenizer._origin.Substring(_cursor, nextDelimPos - _cursor); _cursor = nextDelimPos; return nextToken; --- 104,114 ---- } ! int nextDelimPos = _stokenizer._origin.IndexOfAny( _stokenizer._delim.ToCharArray(), _cursor ); ! if( nextDelimPos == -1 ) ! { nextDelimPos = _stokenizer._origin.Length; } ! string nextToken = _stokenizer._origin.Substring( _cursor, nextDelimPos - _cursor ); _cursor = nextDelimPos; return nextToken; Index: StringHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/StringHelper.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** StringHelper.cs 22 Nov 2004 03:52:18 -0000 1.16 --- StringHelper.cs 1 Jan 2005 02:40:28 -0000 1.17 *************** *** 1,56 **** using System; - using System.Text; using System.Collections; ! namespace NHibernate.Util { ! ! public sealed class StringHelper { ! private StringHelper() { // not creatable } public const char Dot = '.'; public const char Underscore = '_'; public const string CommaSpace = ", "; public const string Comma = ","; public const string OpenParen = "("; public const string ClosedParen = ")"; public const string SqlParameter = "?"; ! public static string Repeat(string str, int times) { ! StringBuilder buf = new StringBuilder(str.Length * times); ! for (int i=0; i<times; i++) ! buf.Append(str); return buf.ToString(); } ! public static string Replace(string template, string placeholder, string replacement) { // sometimes a null value will get passed in here -> SqlWhereStrings are a good example ! if(template==null) return null; ! int loc = template.IndexOf(placeholder); ! if (loc<0) { return template; ! } else { ! return new StringBuilder( template.Substring(0, loc) ) ! .Append(replacement) .Append( Replace( ! template.Substring( loc + placeholder.Length ), ! placeholder, ! replacement ! ) ).ToString(); } } ! public static string ReplaceOnce(string template, string placeholder, string replacement) { ! int loc = template.IndexOf(placeholder); ! if (loc < 0) { return template; ! } else { ! return new StringBuilder( template.Substring(0, loc) ) ! .Append(replacement) .Append( template.Substring( loc + placeholder.Length ) ) .ToString(); --- 1,92 ---- using System; using System.Collections; + using System.Text; ! namespace NHibernate.Util { ! /// <summary></summary> ! public sealed class StringHelper { ! private StringHelper() { // not creatable } + /// <summary></summary> public const char Dot = '.'; + /// <summary></summary> public const char Underscore = '_'; + /// <summary></summary> public const string CommaSpace = ", "; + /// <summary></summary> public const string Comma = ","; + /// <summary></summary> public const string OpenParen = "("; + /// <summary></summary> public const string ClosedParen = ")"; + /// <summary></summary> public const string SqlParameter = "?"; ! /// <summary> ! /// ! /// </summary> ! /// <param name="str"></param> ! /// <param name="times"></param> ! /// <returns></returns> ! public static string Repeat( string str, int times ) ! { ! StringBuilder buf = new StringBuilder( str.Length*times ); ! for( int i = 0; i < times; i++ ) ! buf.Append( str ); return buf.ToString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="template"></param> ! /// <param name="placeholder"></param> ! /// <param name="replacement"></param> ! /// <returns></returns> ! public static string Replace( string template, string placeholder, string replacement ) ! { // sometimes a null value will get passed in here -> SqlWhereStrings are a good example ! if( template == null ) return null; ! int loc = template.IndexOf( placeholder ); ! if( loc < 0 ) ! { return template; ! } ! else ! { ! return new StringBuilder( template.Substring( 0, loc ) ) ! .Append( replacement ) .Append( Replace( ! template.Substring( loc + placeholder.Length ), ! placeholder, ! replacement ! ) ).ToString(); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="template"></param> ! /// <param name="placeholder"></param> ! /// <param name="replacement"></param> ! /// <returns></returns> ! public static string ReplaceOnce( string template, string placeholder, string replacement ) ! { ! int loc = template.IndexOf( placeholder ); ! if( loc < 0 ) ! { return template; ! } ! else ! { ! return new StringBuilder( template.Substring( 0, loc ) ) ! .Append( replacement ) .Append( template.Substring( loc + placeholder.Length ) ) .ToString(); *************** *** 66,72 **** /// <param name="list">the string that will be broken into tokens</param> /// <returns></returns> ! public static string[] Split(string separators, string list) { ! return list.Split(separators.ToCharArray()); } --- 102,108 ---- /// <param name="list">the string that will be broken into tokens</param> /// <returns></returns> ! public static string[ ] Split( string separators, string list ) { ! return list.Split( separators.ToCharArray() ); } *************** *** 82,102 **** /// not including the seperators in the tokens. /// </remarks> ! public static string[] Split(string separators, string list, bool include) { ! StringTokenizer tokens = new StringTokenizer(list, separators, include); ArrayList results = new ArrayList(); ! foreach(string token in tokens) { results.Add( token ); } ! return (string[]) results.ToArray(typeof(string)); } ! public static string Unqualify(string qualifiedName) { ! return Unqualify(qualifiedName, "."); } ! public static string Unqualify(string qualifiedName, string seperator) { ! return qualifiedName.Substring( qualifiedName.LastIndexOf(seperator) + 1 ); } --- 118,151 ---- /// not including the seperators in the tokens. /// </remarks> ! public static string[ ] Split( string separators, string list, bool include ) { ! StringTokenizer tokens = new StringTokenizer( list, separators, include ); ArrayList results = new ArrayList(); ! foreach( string token in tokens ) { results.Add( token ); } ! return ( string[ ] ) results.ToArray( typeof( string ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="qualifiedName"></param> ! /// <returns></returns> ! public static string Unqualify( string qualifiedName ) ! { ! return Unqualify( qualifiedName, "." ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="qualifiedName"></param> ! /// <param name="seperator"></param> ! /// <returns></returns> ! public static string Unqualify( string qualifiedName, string seperator ) ! { ! return qualifiedName.Substring( qualifiedName.LastIndexOf( seperator ) + 1 ); } *************** *** 107,113 **** /// <param name="typeName"></param> /// <returns></returns> ! public static string GetFullClassname(string typeName) { ! return typeName.Trim().Split(' ', ',')[0]; } --- 156,162 ---- /// <param name="typeName"></param> /// <returns></returns> ! public static string GetFullClassname( string typeName ) { ! return typeName.Trim().Split( ' ', ',' )[ 0 ]; } *************** *** 118,204 **** /// <param name="typeName"></param> /// <returns></returns> ! public static string GetClassname(string typeName) { ! string[] splitClassname = GetFullClassname(typeName).Split('.'); ! ! return splitClassname[splitClassname.Length-1]; } ! public static string Qualifier(string qualifiedName) { ! int loc = qualifiedName.LastIndexOf("."); ! if ( loc< 0 ) { return String.Empty; ! } else { ! return qualifiedName.Substring(0, loc); } } ! public static string[] Suffix(string[] columns, string suffix) { ! if (suffix == null) return columns; ! string[] qualified = new string[columns.Length]; ! for ( int i=0; i<columns.Length; i++) { ! qualified[i] = Suffix(columns[i], suffix); } return qualified; } ! public static string Suffix(string name, string suffix) { ! return (suffix == null) ? name : name + suffix; } ! public static string[] Prefix(string [] columns, string prefix) { ! if (prefix == null) return columns; ! string[] qualified = new string[columns.Length]; ! for (int i=0; i<columns.Length; i++) { ! qualified[i] = prefix + columns[i]; } return qualified; } ! public static string Root(string qualifiedName) { ! int loc = qualifiedName.IndexOf("."); ! return (loc<0) ? qualifiedName ! : qualifiedName.Substring(0, loc); } ! public static bool BooleanValue(string tfString) { string trimmed = tfString.Trim().ToLower(); ! return trimmed.Equals("true") || trimmed.Equals("t"); } ! public static string ToString(object[] array) { int len = array.Length; ! // if there is no value in the array then return no string... ! if(len==0) return String.Empty; ! StringBuilder buf = new StringBuilder(len * 12); ! for (int i=0; i<len - 1; i++) { ! buf.Append( array[i] ).Append(StringHelper.CommaSpace); } ! return buf.Append( array[len-1]).ToString(); } ! public static string[] Multiply(string str, IEnumerator placeholders, IEnumerator replacements) { ! string[] result = new string[] { str }; ! while( placeholders.MoveNext() ) { replacements.MoveNext(); ! result = Multiply( result, placeholders.Current as string, replacements.Current as string[]); } return result; } ! public static string[] Multiply(string[] strings, string placeholder, string[] replacements) { ! string[] results = new string[replacements.Length * strings.Length ]; ! int n=0; ! for ( int i=0; i<replacements.Length; i++ ) { ! for (int j=0; j<strings.Length; j++) { ! results[n++] = ReplaceOnce(strings[j], placeholder, replacements[i]); } } --- 167,322 ---- /// <param name="typeName"></param> /// <returns></returns> ! public static string GetClassname( string typeName ) { ! string[ ] splitClassname = GetFullClassname( typeName ).Split( '.' ); + return splitClassname[ splitClassname.Length - 1 ]; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="qualifiedName"></param> ! /// <returns></returns> ! public static string Qualifier( string qualifiedName ) ! { ! int loc = qualifiedName.LastIndexOf( "." ); ! if( loc < 0 ) ! { return String.Empty; ! } ! else ! { ! return qualifiedName.Substring( 0, loc ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="columns"></param> ! /// <param name="suffix"></param> ! /// <returns></returns> ! public static string[ ] Suffix( string[ ] columns, string suffix ) ! { ! if( suffix == null ) return columns; ! string[ ] qualified = new string[columns.Length]; ! for( int i = 0; i < columns.Length; i++ ) ! { ! qualified[ i ] = Suffix( columns[ i ], suffix ); } return qualified; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="suffix"></param> ! /// <returns></returns> ! public static string Suffix( string name, string suffix ) ! { ! return ( suffix == null ) ? name : name + suffix; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="columns"></param> ! /// <param name="prefix"></param> ! /// <returns></returns> ! public static string[ ] Prefix( string[ ] columns, string prefix ) ! { ! if( prefix == null ) return columns; ! string[ ] qualified = new string[columns.Length]; ! for( int i = 0; i < columns.Length; i++ ) ! { ! qualified[ i ] = prefix + columns[ i ]; } return qualified; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="qualifiedName"></param> ! /// <returns></returns> ! public static string Root( string qualifiedName ) ! { ! int loc = qualifiedName.IndexOf( "." ); ! return ( loc < 0 ) ? qualifiedName ! : qualifiedName.Substring( 0, loc ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tfString"></param> ! /// <returns></returns> ! public static bool BooleanValue( string tfString ) ! { string trimmed = tfString.Trim().ToLower(); ! return trimmed.Equals( "true" ) || trimmed.Equals( "t" ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="array"></param> ! /// <returns></returns> ! public static string ToString( object[ ] array ) ! { int len = array.Length; ! // if there is no value in the array then return no string... ! if( len == 0 ) return String.Empty; ! StringBuilder buf = new StringBuilder( len*12 ); ! for( int i = 0; i < len - 1; i++ ) ! { ! buf.Append( array[ i ] ).Append( StringHelper.CommaSpace ); } ! return buf.Append( array[ len - 1 ] ).ToString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="str"></param> ! /// <param name="placeholders"></param> ! /// <param name="replacements"></param> ! /// <returns></returns> ! public static string[ ] Multiply( string str, IEnumerator placeholders, IEnumerator replacements ) ! { ! string[ ] result = new string[ ] {str}; ! while( placeholders.MoveNext() ) ! { replacements.MoveNext(); ! result = Multiply( result, placeholders.Current as string, replacements.Current as string[ ] ); } return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="strings"></param> ! /// <param name="placeholder"></param> ! /// <param name="replacements"></param> ! /// <returns></returns> ! public static string[ ] Multiply( string[ ] strings, string placeholder, string[ ] replacements ) ! { ! string[ ] results = new string[replacements.Length*strings.Length]; ! int n = 0; ! for( int i = 0; i < replacements.Length; i++ ) ! { ! for( int j = 0; j < strings.Length; j++ ) ! { ! results[ n++ ] = ReplaceOnce( strings[ j ], placeholder, replacements[ i ] ); } } *************** *** 206,208 **** } } ! } --- 324,326 ---- } } ! } \ No newline at end of file |