//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: Clob(java.sql.Clob clob) throws java.sql.SQLException internal Clob(java.sql.Clob clob) { long length = clob.length(); if (length >= 0) { value = clob.getSubString(1, (int)length); } }
public JdbcClob(java.sql.Clob clob) { if (clob == null) { throw new ArgumentNullException("clob"); } m_clob = clob; }
/// <summary> /// Frees the <c>CLOB</c> reference that this <c>IClob</c> object /// represents, releasing any resources that this object holds to /// maintain the reference. /// </summary> /// <remarks> /// This object is invalid while in a freed state; any attempt to /// invoke a method other than <c>Free</c>, <c>Wrap(object)</c> /// or <c>Unwrap()</c> while in this state will result in raising /// an exception. While in a freed state, subsequent calls to /// <c>Free</c> have no further effect. After calling <c>Free</c>, /// an <c>IClob</c> may subsequently transition out of a freed state /// as the result of calling <c>Wrap(object)</c>. /// </remarks> /// <exception cref="System.Data.Common.DbException"> /// If there is an error accessing the <c>CLOB</c> value. /// </exception> void IClob.Free() { lock (this) { CheckFree(); m_clob = null; } }
/// <summary> /// Constructs a new <c>JdbcClob</c> instance that wraps an internally /// constructed <c>java.sql.Clob</c> object that, in turn, represents /// the given <c>CLOB</c> <c>data</c>. /// </summary> /// <param name="data"> /// A character sequence representing the <c>CLOB</c> data. /// </param> /// <exception cref="ArgumentNullException"> /// When <c>data</c> is null. /// </exception> /// <exception cref="HsqlDataSourceException"> /// When internal construction of the wrapped <c>java.sql.Clob</c> /// instance fails for any reason. /// </exception> public JdbcClob(string data) { if (data == null) { throw new ArgumentNullException("data"); } try { m_clob = new org.hsqldb.jdbc.jdbcClob(data); } catch (java.sql.SQLException ex) { throw new HsqlDataSourceException(ex); } }
/// <summary> /// Initializes this object with up to <c>length</c> characters /// obtained from the specified <c>reader</c>. /// </summary> /// <param name="reader"> /// The source of characters. /// </param> /// <param name="length"> /// The maximum number of characters to obtain. /// </param> /// <exception cref="ArgumentNullException"> /// When <c>reader</c> is null. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// When <c>length</c> is less than zero (0). /// </exception> /// <exception cref="IOException"> /// When access to reader throws an <c>IOException</c>. /// </exception> /// <exception cref="HsqlDataSourceException"> /// When construction of the wrapped <c>java.sql.Clob</c> /// instance fails for any reason. /// </exception> internal void Initialize(TextReader reader, int length) { if (reader == null) { throw new ArgumentNullException( "reader"); } else if (length < 0) { throw new ArgumentOutOfRangeException( "length", "value: " + length); } int capacity = Math.Min(1024, length); StringBuilder sb = new StringBuilder(capacity, length); int charsRead = 0; char[] buffer = new char[capacity]; while (charsRead < length) { int count = reader.Read( buffer, 0, Math.Min(capacity, (length - charsRead))); if (count == 0) { break; } sb.Append(buffer, 0, count); charsRead += count; } try { m_clob = new org.hsqldb.jdbc.jdbcClob(sb.ToString()); } catch (java.sql.SQLException ex) { throw new HsqlDataSourceException(ex); } }
/// <summary> /// Retrieves the character position at which the specified /// <c>IClob</c> object <c>searchString</c> appears in this /// <c>IClob</c> object. The search begins at position /// <c>start</c>. /// </summary> /// <param name="searchString"> /// The <c>IClob</c> object for which to search. /// </param> /// <param name="start"> /// The position at which to begin searching; /// the first position is 1. /// </param> /// <returns> /// The position at which the <c>searchString</c> appears or -1 /// if it is not present; the first position is 1. /// </returns> /// <exception cref="HsqlDataSourceException"> /// If there is an error accessing the <c>CLOB</c> value. /// </exception> long IClob.Position(IClob searchString, long start) { lock (this) { CheckFree(); try { java.sql.Clob wrapped = searchString.UnWrap() as java.sql.Clob; if (wrapped == null) { long length = searchString.Length; if (length > int.MaxValue) { throw new ArgumentException( "Maximum input length exceeded", "searchString"); } // TODO: this is *very* inefficient for large values. string s = searchString.GetSubString(0, (int)length); return(m_clob.position(s, start)); } else { return(m_clob.position(wrapped, start)); } } catch (java.sql.SQLException se) { throw new HsqlDataSourceException(se); } catch (java.lang.Exception e) { throw new HsqlDataSourceException(e.toString(), e); } } }
/// <summary> /// Wraps the given object, exposing it as an <c>IClob</c> /// through this object. /// </summary> /// <param name="obj"> /// The object to wrap; instances of <c>java.sql.Clob</c>, string, /// <see cref="Stream"/> and <see cref="TextReader"/> are currently /// supported and all unwrap as <c>java.sql.Clob</c>. /// </param> /// <exception cref="ArgumentException"> /// When <c>obj</c> is not a <c>java.sql.Clob</c>, /// <c>string</c>, <see cref="Stream"/> or /// <see cref="TextReader"/>. /// </exception> /// <exception cref="ArgumentNullException"> /// When <c>obj</c> is <c>null</c>. /// </exception> /// <exception cref="HsqlDataSourceException"> /// When this <c>IClob</c> is not in the freed state. /// </exception> void IClob.Wrap(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } else if(obj is java.sql.Clob) { lock (this) { CheckNotFree(); m_clob = (java.sql.Clob)obj; } } else if (obj is string) { lock (this) { CheckNotFree(); try { m_clob = new org.hsqldb.jdbc.jdbcClob((string)obj); } catch (java.sql.SQLException se) { throw new HsqlDataSourceException(se); } catch (java.lang.Exception e) { throw new HsqlDataSourceException(e.toString(), e); } } } else if (obj is Stream) { lock (this) { CheckNotFree(); Initialize( new System.IO.StreamReader((Stream)obj), int.MaxValue); } } else if (obj is TextReader) { lock (this) { CheckNotFree(); Initialize((TextReader)obj, int.MaxValue); } } else { string message = "typeof(" + obj.GetType() + ")"; throw new ArgumentException(message, "obj"); } }
/// <summary> /// Constructs a new <c>JdbcClob</c> instance that wraps an internally /// constructed <c>java.sql.Clob</c> object that, in turn, represents /// the given <c>CLOB</c> <c>data</c>. /// </summary> /// <param name="data"> /// A character sequence representing the <c>CLOB</c> data. /// </param> /// <exception cref="ArgumentNullException"> /// When <c>data</c> is null. /// </exception> /// <exception cref="HsqlDataSourceException"> /// When internal construction of the wrapped <c>java.sql.Clob</c> /// instance fails for any reason. /// </exception> public JdbcClob(string data) { if (data == null) { throw new ArgumentNullException("data"); } try { m_clob = new org.hsqldb.jdbc.jdbcClob(data); } catch(java.sql.SQLException ex) { throw new HsqlDataSourceException(ex); } }
/// <summary> /// Wraps the given object, exposing it as an <c>IClob</c> /// through this object. /// </summary> /// <param name="obj"> /// The object to wrap; instances of <c>java.sql.Clob</c>, string, /// <see cref="Stream"/> and <see cref="TextReader"/> are currently /// supported and all unwrap as <c>java.sql.Clob</c>. /// </param> /// <exception cref="ArgumentException"> /// When <c>obj</c> is not a <c>java.sql.Clob</c>, /// <c>string</c>, <see cref="Stream"/> or /// <see cref="TextReader"/>. /// </exception> /// <exception cref="ArgumentNullException"> /// When <c>obj</c> is <c>null</c>. /// </exception> /// <exception cref="HsqlDataSourceException"> /// When this <c>IClob</c> is not in the freed state. /// </exception> void IClob.Wrap(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } else if (obj is java.sql.Clob) { lock (this) { CheckNotFree(); m_clob = (java.sql.Clob)obj; } } else if (obj is string) { lock (this) { CheckNotFree(); try { m_clob = new org.hsqldb.jdbc.jdbcClob((string)obj); } catch (java.sql.SQLException se) { throw new HsqlDataSourceException(se); } catch (java.lang.Exception e) { throw new HsqlDataSourceException(e.toString(), e); } } } else if (obj is Stream) { lock (this) { CheckNotFree(); Initialize( new System.IO.StreamReader((Stream)obj), int.MaxValue); } } else if (obj is TextReader) { lock (this) { CheckNotFree(); Initialize((TextReader)obj, int.MaxValue); } } else { string message = "typeof(" + obj.GetType() + ")"; throw new ArgumentException(message, "obj"); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public long position(java.sql.Clob searchstr, long start) throws java.sql.SQLException public virtual long position(java.sql.Clob searchstr, long start) { return(position(searchstr.getSubString(1, (int)searchstr.length()), start--)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public ValueClob(java.sql.Clob val) throws java.sql.SQLException public ValueClob(java.sql.Clob val) { clob = new Clob(val); }