예제 #1
0
        public override object ConvertSQLToCSharp(ISessionInterface session, object a)
        {
            IClobData data1  = (IClobData)a;
            int       length = (int)data1.Length(session);

            return(new string(data1.GetChars(session, 0L, length)));
        }
예제 #2
0
        public virtual long Position(ISessionInterface session, object data, object otherData, SqlType otherType, long offset)
        {
            if ((data == null) || (otherData == null))
            {
                return(-1L);
            }
            string str = (string)data;

            if (otherType.TypeCode == 40)
            {
                IClobData data2 = (IClobData)otherData;
                long      num2  = data2.Length(session);
                if ((offset + num2) > str.Length)
                {
                    return(-1L);
                }
                string str2 = data2.GetSubString(session, 0L, (int)num2);
                return((long)str.IndexOf(str2, (int)offset));
            }
            if (!otherType.IsCharacterType())
            {
                throw Error.RuntimeError(0xc9, "CharacterType");
            }
            string str3   = (string)otherData;
            long   length = str3.Length;

            if ((offset + length) > str.Length)
            {
                return(-1L);
            }
            return(str.IndexOf(str3, (int)offset));
        }
예제 #3
0
        public object RPad(Session session, object data, int width, string paddingChar)
        {
            if ((data == null) || (width < 0))
            {
                return(null);
            }
            if (string.IsNullOrEmpty(paddingChar))
            {
                return(data);
            }
            if (base.TypeCode == 40)
            {
                IClobData data2 = (IClobData)data;
                string    str   = data2.GetSubString(session, 0L, (int)data2.Length(session));
                if (str.Length > width)
                {
                    return(str.Substring(0, width));
                }
                str = (paddingChar.Length > 1) ? PadRight(str, width, paddingChar) : str.PadRight(width, paddingChar[0]);
                ClobDataId id1 = session.CreateClob((long)str.Length);
                id1.SetString(session, 0L, str);
                return(id1);
            }
            string str2 = (string)data;

            if (str2.Length > width)
            {
                return(str2.Substring(0, width));
            }
            if (paddingChar.Length > 1)
            {
                return(PadRight(str2, width, paddingChar));
            }
            return(str2.PadRight(width, paddingChar[0]));
        }
예제 #4
0
 public int Compare(IClobData a, IClobData b)
 {
     lock (this)
     {
         if (a.GetId() == b.GetId())
         {
             return(0);
         }
         return(this.CompareText(a.GetId(), b.GetId()));
     }
 }
예제 #5
0
        public override long Position(ISessionInterface session, object data, object otherData, SqlType otherType, long start)
        {
            IClobData data2 = (IClobData)data;

            if (otherType.TypeCode == 40)
            {
                return(data2.Position(session, (IClobData)otherData, start));
            }
            if (!otherType.IsCharacterType())
            {
                throw Error.RuntimeError(0xc9, "ClobType");
            }
            return(data2.Position(session, (string)otherData, start));
        }
예제 #6
0
 public object Lower(Session session, object data)
 {
     if (data == null)
     {
         return(null);
     }
     if (base.TypeCode == 40)
     {
         IClobData data2 = (IClobData)data;
         string    s     = data2.GetSubString(session, 0L, (int)data2.Length(session));
         s = this._collation.ToLowerCase(s);
         ClobDataId id1 = session.CreateClob((long)s.Length);
         id1.SetString(session, 0L, s);
         return(id1);
     }
     return(this._collation.ToLowerCase((string)data));
 }
예제 #7
0
 public int Compare(IClobData a, string b)
 {
     lock (this)
     {
         long    num2       = (long)this.GetLobHeader(a.GetId())[1];
         int[][] numArray   = this.GetBlockAddresses(a.GetId(), 0, 0x7fffffff);
         int     index      = 0;
         int     startIndex = 0;
         int     num5       = 0;
         do
         {
             int  blockAddress = numArray[index][0] + num5;
             long num8         = num2 - (((numArray[index][2] + num5) * this._lobBlockSize) / 2);
             if (num8 > (this._lobBlockSize / 2))
             {
                 num8 = this._lobBlockSize / 2;
             }
             string str    = new string(ArrayUtil.ByteArrayToChars(this._lobStore.GetBlockBytes(blockAddress, 1)), 0, (int)num8);
             int    length = b.Length - startIndex;
             if (length > (this._lobBlockSize / 2))
             {
                 length = this._lobBlockSize / 2;
             }
             string str2 = b.Substring(startIndex, length);
             int    num6 = this._database.collation.Compare(str, str2);
             if (num6 != 0)
             {
                 return(num6);
             }
             num5++;
             startIndex += this._lobBlockSize / 2;
             if (num5 == numArray[index][1])
             {
                 num5 = 0;
                 index++;
             }
         }while (index != numArray.Length);
         return(0);
     }
 }
예제 #8
0
        public override object Concat(Session session, object a, object b)
        {
            string str;
            string str2;

            if ((a == null) || (b == null))
            {
                return(null);
            }
            IClobData data = a as IClobData;

            if (data != null)
            {
                str = data.GetSubString(session, 0L, (int)data.Length(session));
            }
            else
            {
                str = a.ToString();
            }
            IClobData data2 = b as IClobData;

            if (data2 != null)
            {
                str2 = data2.GetSubString(session, 0L, (int)data2.Length(session));
            }
            else
            {
                str2 = b.ToString();
            }
            if (base.TypeCode == 40)
            {
                ClobDataId id1 = session.CreateClob((long)(str.Length + str2.Length));
                id1.SetString(session, 0L, str);
                id1.SetString(session, (long)str.Length, str2);
                return(id1);
            }
            return(str + str2);
        }
예제 #9
0
        public object Trim(ISessionInterface session, object data, string trim, bool leading, bool trailing)
        {
            string str;

            if (data == null)
            {
                return(null);
            }
            IClobData data2 = data as IClobData;

            if (data2 != null)
            {
                str = data2.GetSubString(session, 0L, (int)data2.Length(session));
            }
            else
            {
                str = (string)data;
            }
            if (leading & trailing)
            {
                str = str.Trim(trim.ToCharArray());
            }
            else if (leading)
            {
                str = str.TrimStart(trim.ToCharArray());
            }
            else if (trailing)
            {
                str = str.TrimEnd(trim.ToCharArray());
            }
            if (base.TypeCode == 40)
            {
                ClobDataId id1 = session.CreateClob((long)str.Length);
                id1.SetString(session, 0L, str);
                return(id1);
            }
            return(str);
        }
예제 #10
0
        public override int Compare(Session session, object a, object b, SqlType otherType, bool forEquality)
        {
            if (a == b)
            {
                return(0);
            }
            if (a == null)
            {
                return(-1);
            }
            if (b == null)
            {
                return(1);
            }
            IClobData data = (IClobData)a;
            string    str  = b as string;

            if (str != null)
            {
                return(session.database.lobManager.Compare(data, str));
            }
            return(session.database.lobManager.Compare(data, (IClobData)b));
        }
예제 #11
0
 protected abstract void WriteClob(IClobData o, SqlType type);
예제 #12
0
 protected override void WriteClob(IClobData o, SqlType type)
 {
     this.WriteLong(o.GetId());
 }
예제 #13
0
        public object Substring(ISessionInterface session, object data, long offset, long length, bool hasLength, bool trailing)
        {
            IClobData data2 = null;
            string    str   = null;
            long      num;
            long      num2;

            if (base.TypeCode == 40)
            {
                data2 = (IClobData)data;
                num   = data2.Length(session);
            }
            else
            {
                str = (string)data;
                num = str.Length;
            }
            if (offset < 0L)
            {
                offset += num + 1L;
            }
            if (trailing)
            {
                num2 = num;
                if (length > num)
                {
                    offset = 0L;
                    length = num;
                }
                else
                {
                    offset = num - length;
                }
            }
            else if (hasLength)
            {
                num2 = offset + length;
            }
            else
            {
                num2 = (num > offset) ? num : offset;
            }
            if (num2 < offset)
            {
                throw Error.GetError(0xd67);
            }
            if (((offset > num2) || (num2 < 0L)) || (offset > num))
            {
                offset = 0L;
                return(string.Empty);
            }
            if (offset < 0L)
            {
                offset = 0L;
            }
            if (num2 > num)
            {
                num2 = num;
            }
            length = num2 - offset;
            if (base.TypeCode == 40)
            {
                string     str2 = data2.GetSubString(session, offset, (int)length);
                ClobDataId id1  = session.CreateClob(length);
                id1.SetString(session, 0L, str2);
                return(id1);
            }
            return(str.Substring((int)offset, (int)length));
        }
예제 #14
0
        public object CastOrConvertToType(ISessionInterface session, object a, SqlType otherType, bool cast)
        {
            switch (otherType.TypeCode)
            {
            case 40:
            {
                IClobData data      = (IClobData)a;
                long      precision = data.Length(session);
                if ((base.Precision != 0) && (precision > base.Precision))
                {
                    if (data.NonSpaceLength(session) > base.Precision)
                    {
                        if (!cast)
                        {
                            throw Error.GetError(0xd49);
                        }
                        session.AddWarning(Error.GetError(0x3ec));
                    }
                    precision = base.Precision;
                }
                switch (base.TypeCode)
                {
                case 40:
                    if ((base.Precision != 0) && (precision > base.Precision))
                    {
                        return(data.GetClob(session, 0L, base.Precision));
                    }
                    return(a);

                case 100:
                case 1:
                case 12:
                    if (precision > 0x7fffffffL)
                    {
                        if (!cast)
                        {
                            throw Error.GetError(0xd49);
                        }
                        precision = 0x7fffffffL;
                    }
                    a = data.GetSubString(session, 0L, (int)precision);
                    return(this.ConvertToTypeLimits(session, a));
                }
                throw Error.RuntimeError(0xc9, "CharacterType");
            }

            case 100:
            case 1:
            case 12:
            {
                string s      = (string)a;
                int    length = s.Length;
                if ((base.Precision != 0) && (length > base.Precision))
                {
                    if (StringUtil.RightTrimSize(s) > base.Precision)
                    {
                        if (!cast)
                        {
                            throw Error.GetError(0xd49);
                        }
                        session.AddWarning(Error.GetError(0x3ec));
                    }
                    a = s.Substring(0, (int)base.Precision);
                }
                int typeCode = base.TypeCode;
                if (typeCode <= 12)
                {
                    switch (typeCode)
                    {
                    case 1:
                        return(this.ConvertToTypeLimits(session, a));

                    case 12:
                        return(a);
                    }
                    break;
                }
                if (typeCode == 40)
                {
                    ClobDataId id1 = session.CreateClob((long)s.Length);
                    id1.SetString(session, 0L, s);
                    return(id1);
                }
                if (typeCode != 100)
                {
                    break;
                }
                return(a);
            }

            case 0x457:
                throw Error.GetError(0x15b9);

            default:
            {
                string str2 = otherType.ConvertToString(a);
                if ((base.Precision != 0) && (str2.Length > base.Precision))
                {
                    throw Error.GetError(0xd49);
                }
                a = str2;
                return(this.ConvertToTypeLimits(session, a));
            }
            }
            throw Error.RuntimeError(0xc9, "CharacterType");
        }
예제 #15
0
 public long Position(ISessionInterface session, IClobData searchstr, long start)
 {
     return(0L);
 }