WriteDouble() public abstract method

Writes a double value to the stream. The double will be written with the following syntax: D b64 b56 b48 b40 b32 b24 b16 b8
public abstract WriteDouble ( double dblValue ) : void
dblValue double the double value to write
return void
コード例 #1
0
        /// <summary>
        /// Writes primitive objects and arrayy of primitive objects
        /// </summary>
        /// <param name="obj">Object to write</param>
        /// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        /// <exception cref="CHessianException"/>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            switch (m_intCode)
            {
            case BOOLEAN:
                abstractHessianOutput.WriteBoolean(((bool)obj));
                break;

            case BYTE:
            case SBYTE:
            case SHORT:
            case INTEGER:
                abstractHessianOutput.WriteInt(Convert.ToInt32(obj));
                break;

            case LONG:
                abstractHessianOutput.WriteLong((long)obj);
                break;

            case FLOAT:
                abstractHessianOutput.WriteDouble(Convert.ToDouble(obj));
                break;

            case DOUBLE:
                abstractHessianOutput.WriteDouble((double)obj);
                break;

            case CHARACTER:
                abstractHessianOutput.WriteInt((char)obj);
                break;

            case STRING:
                abstractHessianOutput.WriteString((string)obj);
                break;

            case DATE:
                DateTime dt       = (DateTime)obj;
                long     javaTime = CDateSerializer.MakeJavaDate(dt);
                abstractHessianOutput.WriteUTCDate(javaTime);
                break;

            case INTEGER_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                int[] arrData = (int[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[int");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteInt(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case STRING_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                String[] arrData = (String[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[string");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteString(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case BOOLEAN_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                bool[] arrData = (bool[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[boolean");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteBoolean(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case BYTE_ARRAY:
            {
                byte[] arrData = (byte[])obj;
                abstractHessianOutput.WriteBytes(arrData, 0, arrData.Length);
                break;
            }

            case SBYTE_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                sbyte[] arrData = (sbyte[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[sbyte");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteInt(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case SHORT_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                short[] arrData = (short[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[short");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteInt(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }


            case LONG_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                long[] arrData = (long[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[long");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteLong(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case FLOAT_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                float[] arrData = (float[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[float");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteDouble(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case DOUBLE_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                double[] arrData = (double[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[double");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteDouble(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }


            case CHARACTER_ARRAY:
            {
                char[] arrData = (char[])obj;
                abstractHessianOutput.WriteString(arrData, 0, arrData.Length);
                break;
            }

            case OBJECT_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                Object[] arrData = (Object[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[object");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteObject(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            default:
                throw new CHessianException(m_intCode + " " + obj.GetType().ToString());
            }
            #endregion
        }
コード例 #2
0
		/// <summary>
		/// Writes primitive objects and arrayy of primitive objects
		/// </summary>
		/// <param name="obj">Object to write</param>
		/// <param name="abstractHessianOutput">HessianOutput - Instance</param>
		/// <exception cref="CHessianException"/>
		public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
		{
			switch (m_intCode)
			{
				case BOOLEAN:
					abstractHessianOutput.WriteBoolean(((bool) obj));
					break;
				case BYTE:
				case SBYTE:
				case SHORT:
				case INTEGER:
					abstractHessianOutput.WriteInt(Convert.ToInt32(obj));
					break;
				case LONG:
					abstractHessianOutput.WriteLong((long) obj);
					break;
				case FLOAT:
					abstractHessianOutput.WriteDouble(Convert.ToDouble(obj));
					break;
				case DOUBLE:
					abstractHessianOutput.WriteDouble((double) obj);
					break;
				case CHARACTER:
					abstractHessianOutput.WriteInt((char) obj);
					break;
				case STRING:
					abstractHessianOutput.WriteString((string) obj);
					break;
				case DATE:					
                    DateTime dt = (DateTime)obj;
                    long javaTime = CDateSerializer.MakeJavaDate(dt);
                    abstractHessianOutput.WriteUTCDate(javaTime);
                    break; 

				case INTEGER_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					int[] arrData = (int[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[int");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteInt(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}

				case STRING_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					String[] arrData = (String[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[string");
					for (int i = 0; i < arrData.Length; i++)
					{
						abstractHessianOutput.WriteString(arrData[i]);
					}
					abstractHessianOutput.WriteListEnd();
					break;
				}
				case BOOLEAN_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					bool[] arrData = (bool[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[boolean");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteBoolean(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}

				case BYTE_ARRAY:
				{
					byte[] arrData = (byte[]) obj;
					abstractHessianOutput.WriteBytes(arrData, 0, arrData.Length);
					break;
				}

                case SBYTE_ARRAY:
                {
                    if (abstractHessianOutput.AddRef(obj))
                        return;

                    sbyte[] arrData = (sbyte[])obj;
                    abstractHessianOutput.WriteListBegin(arrData.Length, "[sbyte");
                    for (int i = 0; i < arrData.Length; i++)
                        abstractHessianOutput.WriteInt(arrData[i]);
                    abstractHessianOutput.WriteListEnd();
                    break;
                }

				case SHORT_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					short[] arrData = (short[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[short");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteInt(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}


				case LONG_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					long[] arrData = (long[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[long");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteLong(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}

				case FLOAT_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					float[] arrData = (float[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[float");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteDouble(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}

				case DOUBLE_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					double[] arrData = (double[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[double");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteDouble(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}


				case CHARACTER_ARRAY:
				{
					char[] arrData = (char[]) obj;
					abstractHessianOutput.WriteString(arrData, 0, arrData.Length);
					break;
				}

				case OBJECT_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					Object[] arrData = (Object[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[object");
					for (int i = 0; i < arrData.Length; i++)
					{
						abstractHessianOutput.WriteObject(arrData[i]);
					}
					abstractHessianOutput.WriteListEnd();
					break;
				}

				default:
					throw new CHessianException(m_intCode + " " + obj.GetType().ToString());
			}
		#endregion
		}