diff options
author | Boris Kirzner <borisk@mono-cvs.ximian.com> | 2005-05-29 18:36:27 +0400 |
---|---|---|
committer | Boris Kirzner <borisk@mono-cvs.ximian.com> | 2005-05-29 18:36:27 +0400 |
commit | 32a7d770ef1bfcb29f197f0817b52d69351eb92c (patch) | |
tree | 90954ab7b88c704c5a109224d63aaff9f69e88f3 /mcs | |
parent | df9e42ed38d2b2a8461e4d3bf2d73330bf01e148 (diff) |
Changes toward common code base with TARGET_JVM
svn path=/trunk/mcs/; revision=45163
Diffstat (limited to 'mcs')
15 files changed, 419 insertions, 281 deletions
diff --git a/mcs/class/System.Data/Assembly/AssemblyInfo.cs b/mcs/class/System.Data/Assembly/AssemblyInfo.cs index 68dcfca3b43..d9c34bbeea1 100644 --- a/mcs/class/System.Data/Assembly/AssemblyInfo.cs +++ b/mcs/class/System.Data/Assembly/AssemblyInfo.cs @@ -60,7 +60,9 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("(c) 2003 Various Authors")] [assembly: AssemblyTrademark("")] +#if !TARGET_JVM [assembly: CLSCompliant(true)] +#endif [assembly: AssemblyDefaultAlias("System.Data.dll")] [assembly: AssemblyInformationalVersion("0.0.0.1")] [assembly: NeutralResourcesLanguage("en-US")] @@ -69,4 +71,6 @@ using System.Runtime.InteropServices; [assembly: AllowPartiallyTrustedCallers] [assembly: AssemblyDelaySign(true)] +#if !TARGET_JVM [assembly: AssemblyKeyFile("../ecma.pub")] +#endif diff --git a/mcs/class/System.Data/Assembly/ChangeLog b/mcs/class/System.Data/Assembly/ChangeLog index af1e0492668..608c761d11c 100644 --- a/mcs/class/System.Data/Assembly/ChangeLog +++ b/mcs/class/System.Data/Assembly/ChangeLog @@ -1,3 +1,7 @@ +2005-05-29 Boris Kirzner <borisk@mainsoft.com> + + * AssemblyInfo.cs: added #if !TARGET_JVM for attribues not currently supported in TARGET_JVM. + 2004-04-06 Andreas Nahr <ClassDevelopment@A-SoftTech.com> * AssemblyInfo.cs: also remove the fixme diff --git a/mcs/class/System.Data/ChangeLog b/mcs/class/System.Data/ChangeLog index 59c446bdd71..bfa04727768 100644 --- a/mcs/class/System.Data/ChangeLog +++ b/mcs/class/System.Data/ChangeLog @@ -1,3 +1,6 @@ +2005-05-29 BorisKirzner <borisk@mainsoft.com> + * System.Data.dll.sources: Added ExceptionHelper.cs + 2005-05-29 Eyal Alaluf <eyala@mainsoft.com> * System.Data_tests.dll.sources: Unified Mainsoft ConstraintCollection tests into one test in Test/System.Data diff --git a/mcs/class/System.Data/System.Data.Common/ChangeLog b/mcs/class/System.Data/System.Data.Common/ChangeLog index 3f5697477f9..f07a51d1c79 100755 --- a/mcs/class/System.Data/System.Data.Common/ChangeLog +++ b/mcs/class/System.Data/System.Data.Common/ChangeLog @@ -1,3 +1,9 @@ +2005-05-29 Boris Kirzner <borisk@mainsoft.com> + * DbCommand.cs - added #ifdef NET_2_0 on DbCommandOptionalFeatures (not used in TARGET_JVM).
+ * ExceptionHelper.cs - removed java references. Exceptions created on formatted text messages. Code styling fixes.
+ * DbParameterCollection.cs - implemented indexer properties. + * DbDataAdapter.cs - delagate exceptions creating to ExceptionHelper. + 2005-05-25 Konstantin Triger <kostat@mainsoft.com> * DataContainer.cs: Correcting the order - first the record is queried whether the value it contains is null, and only if not the value is fetched diff --git a/mcs/class/System.Data/System.Data.Common/DbCommand.cs b/mcs/class/System.Data/System.Data.Common/DbCommand.cs index 8c96e0677f6..f47936d9410 100644 --- a/mcs/class/System.Data/System.Data.Common/DbCommand.cs +++ b/mcs/class/System.Data/System.Data.Common/DbCommand.cs @@ -72,10 +72,12 @@ namespace System.Data.Common { set { Transaction = (DbTransaction) value; } } +#if NET_2_0 [MonoTODO] public virtual DbCommandOptionalFeatures OptionalFeatures { get { throw new NotImplementedException (); } } +#endif public DbParameterCollection Parameters { get { return DbParameterCollection; } diff --git a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs index 72587b7da35..d621d5c11a7 100644 --- a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs +++ b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs @@ -889,7 +889,7 @@ namespace System.Data.Common { break; case UpdateStatus.ErrorsOccurred : if (argsUpdating.Errors == null) { - argsUpdating.Errors = new DataException("RowUpdatedEvent: Errors occurred; no additional is information available."); + argsUpdating.Errors = ExceptionHelper.RowUpdatedError(); } row.RowError += argsUpdating.Errors.Message; if (!ContinueUpdateOnError) { @@ -902,14 +902,14 @@ namespace System.Data.Common { updateCount++; continue; default : - throw new ArgumentException(String.Format("Invalid UpdateStatus: {0}",argsUpdating.Status)); + throw ExceptionHelper.InvalidUpdateStatus(argsUpdating.Status); } command = argsUpdating.Command; IDataReader reader = null; try { if (command == null) { - throw new InvalidOperationException("ADP_UpdateRequiresCommand" + command); + throw ExceptionHelper.UpdateRequiresCommand(commandName); } CommandBehavior commandBehavior = CommandBehavior.Default; @@ -999,7 +999,7 @@ namespace System.Data.Common { break; case UpdateStatus.ErrorsOccurred: if (updatedArgs.Errors == null) { - updatedArgs.Errors = new DataException("RowUpdatedEvent: Errors occurred; no additional is information available."); + updatedArgs.Errors = ExceptionHelper.RowUpdatedError(); } row.RowError += updatedArgs.Errors.Message; if (!ContinueUpdateOnError) { diff --git a/mcs/class/System.Data/System.Data.Common/DbParameterCollection.cs b/mcs/class/System.Data/System.Data.Common/DbParameterCollection.cs index 11fd1f84765..8f940f19db5 100644 --- a/mcs/class/System.Data/System.Data.Common/DbParameterCollection.cs +++ b/mcs/class/System.Data/System.Data.Common/DbParameterCollection.cs @@ -56,25 +56,29 @@ namespace System.Data.Common { set { this [parameterName] = (DbParameter) value; } } - object IList.this [int objA] { - get { return this [objA]; } - set { this [objA] = (DbParameter) value; } + object IList.this [int index] { + get { return this [index]; } + set { this [index] = (DbParameter) value; } } public abstract bool IsFixedSize { get; } public abstract bool IsReadOnly { get; } public abstract bool IsSynchronized { get; } - [MonoTODO] - public DbParameter this [string ulAdd] { - get { throw new NotImplementedException (); } - set { throw new NotImplementedException (); } + public DbParameter this [string parameterName] { + get { + int index = IndexOf (parameterName); + return this [index]; + } + set { + int index = IndexOf (parameterName); + this [index] = value; + } } - [MonoTODO] - public DbParameter this [[Optional] int ulAdd] { - get { throw new NotImplementedException (); } - set { throw new NotImplementedException (); } + public DbParameter this [[Optional] int index] { + get { return GetParameter (index); } + set { SetParameter (index,value); } } public abstract object SyncRoot { get; } @@ -84,8 +88,12 @@ namespace System.Data.Common { #region Methods public abstract int Add (object value); + +#if NET_2_0 public abstract void AddRange (Array values); protected abstract int CheckName (string parameterName); +#endif + public abstract void Clear (); public abstract bool Contains (object value); public abstract bool Contains (string value); diff --git a/mcs/class/System.Data/System.Data.Common/ExceptionHelper.cs b/mcs/class/System.Data/System.Data.Common/ExceptionHelper.cs index 0eb66ea27cd..a21d1b5d812 100644 --- a/mcs/class/System.Data/System.Data.Common/ExceptionHelper.cs +++ b/mcs/class/System.Data/System.Data.Common/ExceptionHelper.cs @@ -7,218 +7,201 @@ using System;
-using java.util;
-
namespace System.Data.Common
{
internal sealed class ExceptionHelper
- {
- sealed class ResourceManager
+ {
+ internal static ArgumentException InvalidSizeValue (int value)
{
- private static readonly ResourceBundle _resourceBundle = ResourceBundle.getBundle("SystemData");
-
- internal ResourceManager()
- {
- }
-
- internal string GetString(string key)
- {
- return _resourceBundle.getString(key);
- }
+ string [] args = new string [] {value.ToString ()};
+ return new ArgumentException (GetExceptionMessage ("Invalid parameter Size value '{0}'. The value must be greater than or equal to 0.",args));
}
- static ResourceManager _resourceManager = new ResourceManager();
-
- internal static ArgumentException InvalidSizeValue(int value)
- {
- string[] args = new string[] {value.ToString()};
- return new ArgumentException(GetExceptionMessage("ADP_InvalidSizeValue",args));
+ internal static ArgumentOutOfRangeException InvalidDataRowVersion (DataRowVersion value)
+ {
+ object [] args = new object [] { "DataRowVersion", value.ToString () } ;
+ return new ArgumentOutOfRangeException (GetExceptionMessage ("{0}: Invalid DataRow Version enumeration value: {1}",args));
}
- internal static ArgumentOutOfRangeException InvalidDataRowVersion(DataRowVersion value)
- {
- return InvalidEnumerationValue(typeof(DataRowVersion), (int) value);
- }
-
- internal static ArgumentOutOfRangeException InvalidEnumerationValue(Type type, int value)
- {
- object[] args = new object[] { type.Name, value.ToString() } ;
- return new ArgumentOutOfRangeException(GetExceptionMessage("ADP_InvalidEnumerationValue",args));
- }
-
- internal static ArgumentException InvalidOffsetValue(int value)
+ internal static ArgumentOutOfRangeException InvalidParameterDirection (ParameterDirection value)
{
- string[] args = new string[] {value.ToString()};
- return new ArgumentException(GetExceptionMessage("ADP_InvalidOffsetValue",args));
+ object [] args = new object [] { "ParameterDirection", value.ToString () } ;
+ return new ArgumentOutOfRangeException (GetExceptionMessage ("Invalid direction '{0}' for '{1}' parameter.",args));
}
- internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value)
- {
- return InvalidEnumerationValue(typeof(ParameterDirection), (int) value);
- }
-
- internal static InvalidOperationException NoStoredProcedureExists(string procedureName) {
- object[] args = new object[1] { procedureName } ;
- return new InvalidOperationException(GetExceptionMessage("ADP_NoStoredProcedureExists", args));
+ internal static InvalidOperationException NoStoredProcedureExists (string procedureName) {
+ object [] args = new object [1] { procedureName } ;
+ return new InvalidOperationException (GetExceptionMessage ("The stored procedure '{0}' doesn't exist.", args));
}
- internal static ArgumentNullException ArgumentNull(string parameter)
+ internal static ArgumentNullException ArgumentNull (string parameter)
{
- return new ArgumentNullException(parameter);
+ return new ArgumentNullException (parameter);
}
- internal static InvalidOperationException TransactionRequired()
+ internal static InvalidOperationException TransactionRequired ()
{
- return new InvalidOperationException(GetExceptionMessage("ADP_TransactionRequired_Execute"));
+ return new InvalidOperationException (GetExceptionMessage ("Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized."));
}
- internal static ArgumentOutOfRangeException InvalidOleDbType(int value)
+ internal static ArgumentOutOfRangeException InvalidOleDbType (int value)
{
- string[] args = new string[] {value.ToString()};
- return new ArgumentOutOfRangeException(GetExceptionMessage("OleDb_InvalidOleDbType",args));
+ string [] args = new string [] { value.ToString() };
+ return new ArgumentOutOfRangeException (GetExceptionMessage ("Invalid OleDbType enumeration value: {0}",args));
}
internal static ArgumentException InvalidDbType(int value)
{
- string[] args = new string[] {value.ToString()};
- return new ArgumentException(GetExceptionMessage("ADP_UnknownDataType",args));
+ string [] args = new string [] { value.ToString () };
+ return new ArgumentException (GetExceptionMessage ("No mapping exists from DbType {0} to a known {1}.",args));
}
internal static InvalidOperationException DeriveParametersNotSupported(Type type,CommandType commandType)
{
- string[] args = new string[] {type.ToString(),commandType.ToString()};
- return new InvalidOperationException(GetExceptionMessage("ADP_DeriveParametersNotSupported",args));
+ string [] args = new string [] { type.ToString(),commandType.ToString() };
+ return new InvalidOperationException (GetExceptionMessage ("{0} DeriveParameters only supports CommandType.StoredProcedure, not CommandType.{1}.",args));
}
- internal static InvalidOperationException ReaderClosed(string mehodName)
+ internal static InvalidOperationException ReaderClosed (string mehodName)
{
- string[] args = new string[] {mehodName};
- return new InvalidOperationException(GetExceptionMessage("ADP_DataReaderClosed",args));
+ string [] args = new string [] { mehodName };
+ return new InvalidOperationException (GetExceptionMessage ("Invalid attempt to {0} when reader is closed.",args));
}
- internal static ArgumentOutOfRangeException InvalidSqlDbType(int value)
+ internal static ArgumentOutOfRangeException InvalidSqlDbType (int value)
{
- string[] args = new string[] {value.ToString()};
- return new ArgumentOutOfRangeException(GetExceptionMessage("SQL_InvalidSqlDbType",args));
+ string [] args = new string [] { value.ToString () };
+ return new ArgumentOutOfRangeException (GetExceptionMessage ("{0}: Invalid SqlDbType enumeration value: {1}.",args));
}
- internal static ArgumentException UnknownDataType(string type1, string type2)
+ internal static ArgumentException UnknownDataType (string type1, string type2)
{
- string[] args = new string[] {type1, type2};
- return new ArgumentException(GetExceptionMessage("ADP_UnknownDataType",args));
+ string [] args = new string [] { type1, type2 };
+ return new ArgumentException (GetExceptionMessage ("No mapping exists from DbType {0} to a known {1}.",args));
}
- internal static InvalidOperationException TransactionNotInitialized()
+ internal static InvalidOperationException TransactionNotInitialized ()
{
- return new InvalidOperationException(GetExceptionMessage("ADP_TransactionRequired_Execute"));
+ return new InvalidOperationException (GetExceptionMessage ("Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized."));
}
- internal static InvalidOperationException ParametersNotInitialized(int parameterPosition,string parameterName,string parameterType)
+ internal static InvalidOperationException ParametersNotInitialized (int parameterPosition,string parameterName,string parameterType)
{
- object[] args = new object[] {parameterPosition,parameterName,parameterType};
- return new InvalidOperationException(GetExceptionMessage("OleDb_UninitializedParameters",args));
+ object [] args = new object [] { parameterPosition, parameterName, parameterType };
+ return new InvalidOperationException (GetExceptionMessage ("Parameter {0}: '{1}', the property DbType is uninitialized: OleDbType.{2}.",args));
}
internal static InvalidOperationException WrongParameterSize(string provider)
{
- string[] args = new string[] {provider};
- return new InvalidOperationException(GetExceptionMessage("ADP_PrepareParameterSize",args));
+ string [] args = new string [] { provider };
+ return new InvalidOperationException (GetExceptionMessage ("{0}.Prepare method requires all variable length parameters to have an explicitly set non-zero Size.",args));
+ }
+
+ internal static InvalidOperationException ConnectionNotOpened (string operationName, string connectionState)
+ {
+ object [] args = new object [] { operationName, connectionState };
+ return new InvalidOperationException (GetExceptionMessage ("{0} requires an open and available Connection. The connection's current state is {1}.",args));
}
- internal static InvalidOperationException ConnectionNotOpened(string operationName, string connectionState)
+ internal static InvalidOperationException ConnectionNotInitialized (string methodName)
{
- object[] args = new object[] {operationName,connectionState};
- return new InvalidOperationException(GetExceptionMessage("ADP_OpenConnectionRequired_PropertySet",args));
+ object [] args = new object [] { methodName };
+ return new InvalidOperationException (GetExceptionMessage ("{0}: Connection property has not been initialized.",args));
}
- internal static InvalidOperationException ConnectionNotInitialized(string methodName)
+ internal static InvalidOperationException OpenConnectionRequired (string methodName, object connectionState)
{
- object[] args = new object[] {methodName};
- return new InvalidOperationException(GetExceptionMessage("ADP_ConnectionRequired_ExecuteReader",args));
+ object [] args = new object [] { methodName, connectionState };
+ return new InvalidOperationException (GetExceptionMessage ("{0} requires an open and available Connection. The connection's current state is {1}.",args));
}
- internal static InvalidOperationException OpenConnectionRequired(string methodName, object connectionState)
+ internal static InvalidOperationException OpenedReaderExists ()
{
- object[] args = new object[] {methodName, connectionState};
- return new InvalidOperationException(GetExceptionMessage("ADP_OpenConnectionRequired_Fill",args));
+ return new InvalidOperationException (GetExceptionMessage ("There is already an open DataReader associated with this Connection which must be closed first."));
}
- internal static InvalidOperationException OpenedReaderExists()
+ internal static InvalidOperationException ConnectionAlreadyOpen (object connectionState)
{
- return new InvalidOperationException(GetExceptionMessage("ADP_OpenReaderExists"));
+ object [] args = new object [] { connectionState };
+ return new InvalidOperationException (GetExceptionMessage ("The connection is already Open (state={0}).",args));
}
- internal static InvalidOperationException ConnectionAlreadyOpen(object connectionState)
+ internal static InvalidOperationException ConnectionStringNotInitialized ()
{
- object[] args = new object[] {connectionState};
- return new InvalidOperationException(GetExceptionMessage("ADP_ConnectionAlreadyOpen",args));
+ return new InvalidOperationException (GetExceptionMessage ("The ConnectionString property has not been initialized."));
}
- internal static InvalidOperationException ConnectionStringNotInitialized()
+ internal static InvalidOperationException ConnectionIsBusy (object commandType,object connectionState)
{
- return new InvalidOperationException(GetExceptionMessage("ADP_NoConnectionString"));
+ object [] args = new object [] { commandType.ToString (), connectionState.ToString () };
+ return new InvalidOperationException (GetExceptionMessage ("The {0} is currently busy {1}.",args));
}
- internal static InvalidOperationException ConnectionIsBusy(object commandType,object connectionState)
+ internal static InvalidOperationException NotAllowedWhileConnectionOpen (string propertyName, object connectionState)
{
- object[] args = new object[] {commandType.ToString(), connectionState.ToString()};
- return new InvalidOperationException(GetExceptionMessage("ADP_CommandIsActive",args));
+ object [] args = new object [] { propertyName, connectionState };
+ return new InvalidOperationException (GetExceptionMessage ("Not allowed to change the '{0}' property while the connection (state={1}).",args));
}
- internal static InvalidOperationException NotAllowedWhileConnectionOpen(string propertyName, object connectionState)
+ internal static ArgumentException OleDbNoProviderSpecified ()
{
- object[] args = new object[] {propertyName,connectionState};
- return new InvalidOperationException(GetExceptionMessage("ADP_OpenConnectionPropertySet",args));
+ return new ArgumentException (GetExceptionMessage ("An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'."));
}
- internal static ArgumentException OleDbNoProviderSpecified()
+ internal static ArgumentException InvalidValueForKey (string key)
{
- return new ArgumentException(GetExceptionMessage("OleDb_NoProviderSpecified"));
+ string [] args = new string [] { key };
+ return new ArgumentException (String.Format ("Invalid value for key {0}",args));
}
- internal static ArgumentException InvalidValueForKey(string key)
+ internal static InvalidOperationException ParameterSizeNotInitialized( int parameterIndex, string parameterName,string parameterType,int parameterSize)
{
- string[] args = new string[] { key };
- return new ArgumentException(String.Format("Invalid value for key {0}",args));
+ object [] args = new object [] { parameterIndex.ToString (), parameterName, parameterType, parameterSize.ToString () };
+ return new InvalidOperationException (GetExceptionMessage ("Parameter {0}: '{1}' of type: {2}, the property Size has an invalid size: {3}",args));
}
- internal static InvalidOperationException ParameterSizeNotInitialized(int parameterIndex, string parameterName,string parameterType,int parameterSize)
+ internal static ArgumentException InvalidUpdateStatus (UpdateStatus status)
{
- object[] args = new object[] { parameterIndex.ToString(),parameterName,parameterType,parameterSize.ToString()};
- return new InvalidOperationException(GetExceptionMessage("ADP_UninitializedParameterSize",args));
+ object [] args = new object [] { status };
+ return new ArgumentException (GetExceptionMessage ("Invalid UpdateStatus: {0}",args));
}
- internal static ArgumentException InvalidUpdateStatus(UpdateStatus status)
+ internal static InvalidOperationException UpdateRequiresCommand (string command)
{
- object[] args = new object[] { status };
- return new ArgumentException(GetExceptionMessage("ADP_InvalidUpdateStatus",args));
+ object [] args = new object [] { command };
+ return new InvalidOperationException (GetExceptionMessage ("Auto SQL generation during {0} requires a valid SelectCommand.",args));
}
- internal static InvalidOperationException UpdateRequiresCommand(string command)
+ internal static DataException RowUpdatedError ()
{
- return new InvalidOperationException(GetExceptionMessage("ADP_UpdateRequiresCommand" + command));
+ return new DataException (GetExceptionMessage ("RowUpdatedEvent: Errors occurred; no additional is information available."));
}
- internal static DataException RowUpdatedError()
+ internal static ArgumentNullException CollectionNoNullsAllowed (object collection, object objectsType)
{
- return new DataException(GetExceptionMessage("ADP_RowUpdatedErrors"));
+ object [] args = new object [] {collection.GetType ().ToString (), objectsType.ToString ()};
+ return new ArgumentNullException (GetExceptionMessage ("The {0} only accepts non-null {1} type objects."));
}
- internal static string GetExceptionMessage(string key,object[] args)
+ internal static ArgumentException CollectionAlreadyContains(object objectType,string propertyName, object propertyValue, object collection)
{
- string exceptionMessage = _resourceManager.GetString(key);
+ object [] args = new object [] {objectType.ToString (), propertyName, propertyValue, collection.GetType ().ToString ()};
+ return new ArgumentException (GetExceptionMessage ("The {0} with {1} '{2}' is already contained by this {3}.",args));
+ }
+ internal static string GetExceptionMessage (string exceptionMessage,object [] args)
+ {
if ((args == null) || (args.Length == 0)) {
return exceptionMessage;
}
else {
- return String.Format(exceptionMessage,args);
+ return String.Format (exceptionMessage,args);
}
}
- internal static string GetExceptionMessage(string key)
+ internal static string GetExceptionMessage (string exceptionMessage)
{
- return GetExceptionMessage(key,null);
+ return GetExceptionMessage (exceptionMessage,null);
}
}
}
diff --git a/mcs/class/System.Data/System.Data.ProviderBase/ChangeLog b/mcs/class/System.Data/System.Data.ProviderBase/ChangeLog index f021ed170d6..9a0e9bccbab 100755 --- a/mcs/class/System.Data/System.Data.ProviderBase/ChangeLog +++ b/mcs/class/System.Data/System.Data.ProviderBase/ChangeLog @@ -1,3 +1,24 @@ +2005-05-29 Boris Kirzner <borisk@mainsoft.com> + * DbCommandBase.cs + - Private members names changed. + - Implemented ExsecuteScalar, ExecuteNonQuery, PropertyChanging and ResetCommandTimeout. + - Implemented copy ctor. + * DbDataReaderBase.cs + - Implemented Depth property. + - Added #ifdef NET_2_0 on ISValidRow (not used in TARGET_JVM). + - Implemented Dispose and GetEnumerator methods. + * DbParameterBase.cs + - Private members names changed. + - Implemented copy ctor. + - Reimplemented Direction, ParameterName, Size and SourceColumn properties. + - Added #ifdef NET_2_0 on methods not used in TARGET_JVM + - Implemented CopyTo and ShouldSerializeSize methods + - Added internal Parent property (used by DbParameterCollectionBase) + * DbParameterCollectionBase.cs + - Private members names changed. + - Re/Implemented public methods and added private ones. + * DbStringManager.cs - removed. + 2005-03-11 Sureshkumar T <tsureshkumar@novell.com> * DbConnectionBase.cs : Implemented OnStateChange. diff --git a/mcs/class/System.Data/System.Data.ProviderBase/DbCommandBase.cs b/mcs/class/System.Data/System.Data.ProviderBase/DbCommandBase.cs index 3bbfdb168b1..bf38ecf82e9 100644 --- a/mcs/class/System.Data/System.Data.ProviderBase/DbCommandBase.cs +++ b/mcs/class/System.Data/System.Data.ProviderBase/DbCommandBase.cs @@ -3,6 +3,7 @@ // // Author: // Tim Coleman (tim@timcoleman.com) +// Boris Kirzner (borisk@mainsoft.com) // // Copyright (C) Tim Coleman, 2003 // @@ -30,7 +31,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_2_0 +#if NET_2_0 || TARGET_JVM using System.Data.Common; @@ -39,11 +40,11 @@ namespace System.Data.ProviderBase { { #region Fields - string commandText; - int commandTimeout; - CommandType commandType; - bool designTimeVisible; - UpdateRowSource updatedRowSource; + string _commandText; + int _commandTimeout; + CommandType _commandType; + bool _designTimeVisible; + UpdateRowSource _updatedRowSource; #endregion // Fields @@ -51,15 +52,20 @@ namespace System.Data.ProviderBase { protected DbCommandBase () { - CommandText = String.Empty; - CommandTimeout = 30; - CommandType = CommandType.Text; - DesignTimeVisible = true; - UpdatedRowSource = UpdateRowSource.Both; + _commandText = String.Empty; + _commandTimeout = 30; + _commandType = CommandType.Text; + _designTimeVisible = true; + _updatedRowSource = UpdateRowSource.Both; } protected DbCommandBase (DbCommandBase from) { + _commandText = from._commandText; + _commandTimeout = from._commandTimeout; + _commandType = from._commandType; + _updatedRowSource = from._updatedRowSource; + _designTimeVisible = from._designTimeVisible; } #endregion // Constructors @@ -67,28 +73,27 @@ namespace System.Data.ProviderBase { #region Properties public override string CommandText { - get { return commandText; } - set { commandText = value; } + get { return _commandText; } + set { _commandText = value; } } - public override int CommandTimeout { - get { return commandTimeout; } - set { commandTimeout = value; } + get { return _commandTimeout; } + set { _commandTimeout = value; } } public override CommandType CommandType { - get { return commandType; } - set { commandType = value; } + get { return _commandType; } + set { _commandType = value; } } public override bool DesignTimeVisible { - get { return designTimeVisible; } - set { designTimeVisible = value; } - } + get { return _designTimeVisible; } + set { _designTimeVisible = value; } + } public override UpdateRowSource UpdatedRowSource { - get { return updatedRowSource; } - set { updatedRowSource = value; } + get { return _updatedRowSource; } + set { _updatedRowSource = value; } } #endregion // Properties @@ -101,25 +106,34 @@ namespace System.Data.ProviderBase { throw new NotImplementedException (); } - [MonoTODO] + public override int ExecuteNonQuery () { - DbDataReader reader = ExecuteReader (); - reader.Close (); + IDataReader reader = null; + try { + reader = ExecuteReader (); + } + finally { + if (reader != null) + reader.Close (); + } return reader.RecordsAffected; } public override object ExecuteScalar () { - object val = null; - DbDataReader reader=ExecuteReader(); + IDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SequentialAccess); + try { - if (reader.Read ()) - val=reader[0]; + do { + if (reader.FieldCount > 0 && reader.Read ()) + return reader.GetValue (0); + } + while (reader.NextResult ()); + return null; } finally { reader.Close(); } - return val; } [MonoTODO] @@ -128,16 +142,13 @@ namespace System.Data.ProviderBase { throw new NotImplementedException (); } - [MonoTODO] public virtual void PropertyChanging () { - throw new NotImplementedException (); } - [MonoTODO] public virtual void ResetCommandTimeout () { - throw new NotImplementedException (); + _commandTimeout = 30; } [MonoTODO] diff --git a/mcs/class/System.Data/System.Data.ProviderBase/DbDataReaderBase.cs b/mcs/class/System.Data/System.Data.ProviderBase/DbDataReaderBase.cs index e5e5f05fe22..94294802e96 100644 --- a/mcs/class/System.Data/System.Data.ProviderBase/DbDataReaderBase.cs +++ b/mcs/class/System.Data/System.Data.ProviderBase/DbDataReaderBase.cs @@ -3,6 +3,7 @@ // // Author: // Tim Coleman (tim@timcoleman.com) +// Boris Kirzner (borisk@mainsoft.com) // // Copyright (C) Tim Coleman, 2003 // @@ -30,7 +31,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_2_0 +#if NET_2_0 || TARGET_JVM using System.Collections; using System.Data.Common; @@ -60,9 +61,9 @@ namespace System.Data.ProviderBase { get { return behavior; } } - [MonoTODO] public override int Depth { - get { throw new NotImplementedException (); } + // default value to be overriden by user + get { return 0; } } [MonoTODO] @@ -80,7 +81,9 @@ namespace System.Data.ProviderBase { get { throw new NotImplementedException (); } } +#if NET_2_0 protected abstract bool IsValidRow { get; } +#endif [MonoTODO] public override object this [[Optional] int index] { @@ -131,10 +134,9 @@ namespace System.Data.ProviderBase { throw new NotImplementedException (); } - [MonoTODO] public override void Dispose () { - throw new NotImplementedException (); + Close (); } [MonoTODO] @@ -197,10 +199,10 @@ namespace System.Data.ProviderBase { throw new NotImplementedException (); } - [MonoTODO] public override IEnumerator GetEnumerator () { - throw new NotImplementedException (); + bool closeReader = (CommandBehavior & CommandBehavior.CloseConnection) != 0; + return new DbEnumerator (this , closeReader); } [MonoTODO] diff --git a/mcs/class/System.Data/System.Data.ProviderBase/DbParameterBase.cs b/mcs/class/System.Data/System.Data.ProviderBase/DbParameterBase.cs index 650e8b36954..33a5e39d161 100644 --- a/mcs/class/System.Data/System.Data.ProviderBase/DbParameterBase.cs +++ b/mcs/class/System.Data/System.Data.ProviderBase/DbParameterBase.cs @@ -4,6 +4,7 @@ // Author: // Sureshkumar T (tsureshkumar@novell.com) // Tim Coleman (tim@timcoleman.com) +// Boris Kirzner <borisk@mainsoft.com> // // Copyright (C) Tim Coleman, 2003 // @@ -30,25 +31,27 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_2_0 +#if NET_2_0 || TARGET_JVM using System.Data.Common; namespace System.Data.ProviderBase { public abstract class DbParameterBase : DbParameter { - #region Fields - string _name; + string _parameterName; ParameterDirection _direction = ParameterDirection.Input; - bool _isNullable = false; int _size; +#if NET_2_0 byte _precision; byte _scale; - object _paramValue; - int _offset; DataRowVersion _sourceVersion; +#endif + object _value; + bool _isNullable; + int _offset; string _sourceColumn; + DbParameterCollection _parent = null; #endregion // Fields @@ -59,11 +62,17 @@ namespace System.Data.ProviderBase { { } - [MonoTODO] protected DbParameterBase (DbParameterBase source) { - } + if (source == null) + throw ExceptionHelper.ArgumentNull ("source"); + source.CopyTo (this); + ICloneable cloneable = source._value as ICloneable; + if (cloneable != null) + _value = cloneable.Clone (); + } + #endregion // Constructors #region Properties @@ -73,9 +82,24 @@ namespace System.Data.ProviderBase { get { throw new NotImplementedException (); } } - public override ParameterDirection Direction { + public override ParameterDirection Direction { get { return _direction; } - set { _direction = value; } + set { + if (_direction != value) { + switch (value) { + case ParameterDirection.Input: + case ParameterDirection.Output: + case ParameterDirection.InputOutput: + case ParameterDirection.ReturnValue: + { + PropertyChanging (); + _direction = value; + return; + } + } + throw ExceptionHelper.InvalidParameterDirection (value); + } + } } public override bool IsNullable { @@ -90,10 +114,21 @@ namespace System.Data.ProviderBase { } public override string ParameterName { - get { return _name; } - set { _name = value; } + get { + if (_parameterName == null) + return String.Empty; + + return _parameterName; + } + set { + if (_parameterName != value) { + PropertyChanging (); + _parameterName = value; + } + } } +#if NET_2_0 public override byte Precision { get { return _precision; } set { _precision = value; } @@ -105,28 +140,51 @@ namespace System.Data.ProviderBase { set { _scale = value; } } +#endif public override int Size { get { return _size; } - set { _size = value; } + + set { + if (_size != value) { + if (value < -1) + throw ExceptionHelper.InvalidSizeValue (value); + + PropertyChanging (); + _size = value; + } + } } public override string SourceColumn { - get { return _sourceColumn; } - set { _sourceColumn = value; } + get { + if (_sourceColumn == null) + return String.Empty; + + return _sourceColumn; + } + + set { _sourceColumn = value; } } - +#if NET_2_0 public override DataRowVersion SourceVersion { get { return _sourceVersion; } set { _sourceVersion = value; } } +#endif public override object Value { - get { return _paramValue; } - set { _paramValue = value; } + get { return _value; } + set { _value = value; } + } + + internal DbParameterCollection Parent + { + get { return _parent; } + set { _parent = value; } } #endregion // Properties @@ -136,15 +194,29 @@ namespace System.Data.ProviderBase { [MonoTODO] public override void CopyTo (DbParameter destination) { - throw new NotImplementedException (); - } + if (destination == null) + throw ExceptionHelper.ArgumentNull ("destination"); + + DbParameterBase t = (DbParameterBase)destination; + t._parameterName = _parameterName; + t._size = _size; + t._offset = _offset; + t._isNullable = _isNullable; + t._sourceColumn = _sourceColumn; + t._direction = _direction; + + if (_value is ICloneable) + t._value = ((ICloneable) _value).Clone (); + else + t._value = this._value; + } - [MonoTODO] public virtual void PropertyChanging () { - throw new NotImplementedException (); } +#if NET_2_0 + [MonoTODO] protected void ResetCoercedValue () { @@ -174,13 +246,14 @@ namespace System.Data.ProviderBase { { throw new NotImplementedException (); } - - [MonoTODO] +#endif + protected bool ShouldSerializeSize () { - throw new NotImplementedException (); + return (_size != 0); } +#if NET_2_0 [MonoTODO] public override string ToString () { @@ -204,6 +277,7 @@ namespace System.Data.ProviderBase { { throw new NotImplementedException (); } +#endif #endregion // Methods } diff --git a/mcs/class/System.Data/System.Data.ProviderBase/DbParameterCollectionBase.cs b/mcs/class/System.Data/System.Data.ProviderBase/DbParameterCollectionBase.cs index 6af0bb2ad37..e6eb102d25d 100644 --- a/mcs/class/System.Data/System.Data.ProviderBase/DbParameterCollectionBase.cs +++ b/mcs/class/System.Data/System.Data.ProviderBase/DbParameterCollectionBase.cs @@ -3,6 +3,7 @@ // // Author: // Tim Coleman (tim@timcoleman.com) +// Boris Kirzner (borisk@mainsoft.com) // // Copyright (C) Tim Coleman, 2003 // @@ -30,7 +31,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_2_0 +#if NET_2_0 || TARGET_JVM using System.Collections; using System.Data.Common; @@ -40,16 +41,15 @@ namespace System.Data.ProviderBase { { #region Fields - ArrayList list; + ArrayList _list; #endregion // Fields #region Constructors - [MonoTODO] protected DbParameterBaseCollection () { - list = new ArrayList (); + _list = new ArrayList (); } #endregion // Constructors @@ -57,30 +57,32 @@ namespace System.Data.ProviderBase { #region Properties public override int Count { - get { return list.Count; } + get { return _list.Count; } } public override bool IsFixedSize { - get { return list.IsFixedSize; } + get { return _list.IsFixedSize; } } public override bool IsReadOnly { - get { return list.IsReadOnly; } + get { return _list.IsReadOnly; } } public override bool IsSynchronized { - get { return list.IsSynchronized; } + get { return _list.IsSynchronized; } } protected abstract Type ItemType { get; } +#if NET_2_0 [MonoTODO] protected virtual string ParameterNamePrefix { get { throw new NotImplementedException (); } } +#endif public override object SyncRoot { - get { return list.SyncRoot; } + get { return _list.SyncRoot; } } #endregion // Properties @@ -89,10 +91,12 @@ namespace System.Data.ProviderBase { public override int Add (object value) { - ValidateType (value); - return list.Add (value); + Validate (-1, value); + ((DbParameterBase)value).Parent = this; + return _list.Add (value); } +#if NET_2_0 public override void AddRange (Array values) { foreach (object value in values) @@ -104,106 +108,177 @@ namespace System.Data.ProviderBase { { throw new NotImplementedException (); } +#endif public override void Clear () { - list.Clear (); + if (_list != null && Count != 0) { + for (int i = 0; i < _list.Count; i++) { + ((DbParameterBase)_list [i]).Parent = null; + } + _list.Clear (); + } } public override bool Contains (object value) { - return list.Contains (value); + if (IndexOf (value) != -1) + return true; + else + return false; } - [MonoTODO] public override bool Contains (string value) { - throw new NotImplementedException (); + if (IndexOf (value) != -1) + return true; + else + return false; } public override void CopyTo (Array array, int index) { - list.CopyTo (array, index); + _list.CopyTo (array, index); } public override IEnumerator GetEnumerator () { - return list.GetEnumerator (); + return _list.GetEnumerator (); } protected override DbParameter GetParameter (int index) { - return (DbParameter) list [index]; + return (DbParameter) _list [index]; } public override int IndexOf (object value) { - return list.IndexOf (value); + ValidateType (value); + return _list.IndexOf (value); } - [MonoTODO] public override int IndexOf (string parameterName) { - throw new NotImplementedException (); + if (_list == null) + return -1; + + for (int i = 0; i < _list.Count; i++) { + string name = ((DbParameterBase)_list [i]).ParameterName; + if (name == parameterName) { + return i; + } + } + return -1; } +#if NET_2_0 [MonoTODO] protected internal static int IndexOf (IEnumerable items, string parameterName) { throw new NotImplementedException (); } +#endif public override void Insert (int index, object value) { - list.Insert (index, value); + Validate(-1, (DbParameterBase)value); + ((DbParameterBase)value).Parent = this; + _list.Insert (index, value); } +#if NET_2_0 [MonoTODO] protected virtual void OnChange () { throw new NotImplementedException (); } +#endif public override void Remove (object value) { - list.Remove (value); + ValidateType (value); + int index = IndexOf (value); + RemoveIndex (index); } public override void RemoveAt (int index) { - list.RemoveAt (index); + RemoveIndex (index); } - [MonoTODO] public override void RemoveAt (string parameterName) { - throw new NotImplementedException (); + int index = IndexOf (parameterName); + RemoveIndex (index); } protected override void SetParameter (int index, DbParameter value) { - list [index] = value; + Replace (index, value); } - [MonoTODO] protected virtual void Validate (int index, object value) { - throw new NotImplementedException (); - } + ValidateType (value); + DbParameterBase parameter = (DbParameterBase) value; + + if (parameter.Parent != null) { + if (parameter.Parent.Equals (this)) { + if (IndexOf (parameter) != index) + throw ExceptionHelper.CollectionAlreadyContains (ItemType,"ParameterName",parameter.ParameterName,this); + } + else { + // FIXME : The OleDbParameter with ParameterName 'MyParam2' is already contained by another OleDbParameterCollection. + throw new ArgumentException (""); + } + } + + if (parameter.ParameterName == null || parameter.ParameterName == String.Empty) { + int newIndex = 1; + string parameterName; + + do { + parameterName = "Parameter" + newIndex; + newIndex++; + } + while(IndexOf (parameterName) != -1); + + parameter.ParameterName = parameterName; + } + } protected virtual void ValidateType (object value) { + if (value == null) + throw ExceptionHelper.CollectionNoNullsAllowed (this,ItemType); + Type objectType = value.GetType (); Type itemType = ItemType; - if (objectType != itemType) - { + if (itemType.IsInstanceOfType(objectType)) { Type thisType = this.GetType (); string err = String.Format ("The {0} only accepts non-null {1} type objects, not {2} objects.", thisType.Name, itemType.Name, objectType.Name); throw new InvalidCastException (err); } } + private void RemoveIndex (int index) + { + DbParameterBase oldItem = (DbParameterBase)_list [index]; + oldItem.Parent = null; + _list.RemoveAt (index); + } + + private void Replace (int index, DbParameter value) + { + Validate (index, value); + DbParameterBase oldItem = (DbParameterBase)this [index]; + oldItem.Parent = null; + + ((DbParameterBase)value).Parent = this; + _list [index] = value; + } + #endregion // Methods } } diff --git a/mcs/class/System.Data/System.Data.ProviderBase/DbStringManager.cs b/mcs/class/System.Data/System.Data.ProviderBase/DbStringManager.cs deleted file mode 100644 index efc2cceaab7..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase/DbStringManager.cs +++ /dev/null @@ -1,56 +0,0 @@ -using java.util;
-
-namespace System.Data.Common
-{
- public class DbStringManager
- {
- public DbStringManager(string bundleName)
- {
- _bundleName = bundleName;
- _resourceBundle = ResourceBundle.getBundle(_bundleName);
- }
-
- private readonly string _bundleName;
-
- private readonly ResourceBundle _resourceBundle;
-
- public string GetString(string key)
- {
- try {
- return _resourceBundle.getString(key);
- }
- catch (MissingResourceException) {
- return null;
- }
- }
-
- public string GetString(string key, string defaultValue)
- {
- try {
- return _resourceBundle.getString(key);
- }
- catch (MissingResourceException) {
- return defaultValue;
- }
- }
-
-
- public string[] GetStringArray(String key)
- {
- try {
- string tmp = _resourceBundle.getString(key);
- java.util.StringTokenizer st = new java.util.StringTokenizer(tmp, ",");
-
- String[] strArr = new String[st.countTokens()];
-
- for (int i = 0; i < strArr.Length; i++) {
- strArr[i] = st.nextToken();
- }
- return strArr;
- }
- catch (MissingResourceException) {
- return null;
- }
- }
- }
-}
diff --git a/mcs/class/System.Data/System.Data.dll.sources b/mcs/class/System.Data/System.Data.dll.sources index 5c6e1466f5b..ce29833781e 100755 --- a/mcs/class/System.Data/System.Data.dll.sources +++ b/mcs/class/System.Data/System.Data.dll.sources @@ -173,6 +173,7 @@ System.Data.Common/DbProviderSpecificTypePropertyAttribute.cs System.Data.Common/DbTable.cs System.Data.Common/DbTransaction.cs System.Data.Common/DbTypes.cs +System.Data.Common/ExceptionHelper.cs System.Data.Common/FieldNameLookup.cs System.Data.Common/GroupByBehavior.cs System.Data.Common/IdentifierCase.cs |