Exemple #1
0
        private static byte[] getOutputByCompress(byte[] toByteArray)
        {
            int unCompressedLength = 0;
            int compressedLength   = 0;

            byte[] input = toByteArray;
            unCompressedLength = input.Length;

            MemoryStream         memoryStream = new MemoryStream();
            Deflater             compressor   = new Deflater();
            DeflaterOutputStream defos        = new DeflaterOutputStream(memoryStream, compressor);

            defos.Write(input, 0, input.Length);
            defos.Flush();
            defos.Finish();
            byte[] output = memoryStream.ToArray();
            compressedLength = output.Length;

            memoryStream.Close();
            defos.Close();

            //set compress flag and compressedLength, unCompressedLength
            byte[] sendData = new byte[output.Length + TransferUtil.getLengthOfByte() + TransferUtil.getLengthOfInt() + TransferUtil.getLengthOfInt()];
            sendData[0] = TransferObject.COMPRESS_FLAG; //0:normal; 1:compress
            TransferOutputStream fos = new TransferOutputStream(sendData);

            fos.skipAByte();
            fos.writeInt(unCompressedLength);
            fos.writeInt(compressedLength);
            Array.Copy(output, 0, sendData, TransferUtil.getLengthOfByte() + TransferUtil.getLengthOfInt() + TransferUtil.getLengthOfInt(), output.Length);

            return(sendData);
        }
        public override byte[] getByteData()
        {
            int blength = getByteArrayLength();

            byte[] byteArray = new byte[TransferUtil.getLengthOfInt() + blength];

            TransferOutputStream touts = new TransferOutputStream(byteArray);

            touts.writeInt(blength);
            touts.writeString(calleeClass);
            touts.writeString(calleeMethod);
            touts.writeByte(returnType);
            touts.writeBoolean(compress);

            BooleanMapHelper.getByteArray(booleanMap, touts);
            ByteMapHelper.getByteArray(byteMap, touts);
            ShortMapHelper.getByteArray(shortMap, touts);
            CharMapHelper.getByteArray(charMap, touts);
            IntMapHelper.getByteArray(intMap, touts);
            LongMapHelper.getByteArray(longMap, touts);
            FloatMapHelper.getByteArray(floatMap, touts);
            DoubleMapHelper.getByteArray(doubleMap, touts);
            DateMapHelper.getByteArray(dateMap, touts);
            StringMapHelper.getByteArray(stringMap, touts);
            WrapperMapHelper.getByteArray(wrapperMap, touts);

            ByteArrayMapHelper.getByteArray(byteArrayMap, touts);
            IntArrayMapHelper.getByteArray(intArrayMap, touts);
            LongArrayMapHelper.getByteArray(longArrayMap, touts);
            FloatArrayMapHelper.getByteArray(floatArrayMap, touts);
            DoubleArrayMapHelper.getByteArray(doubleArrayMap, touts);
            StringArrayMapHelper.getByteArray(stringArrayMap, touts);

            return(byteArray);
        }
 public void getByteArray(TransferOutputStream touts)
 {
     touts.writeBoolean(allTypeBean.isAboolean());
     touts.writeByte(allTypeBean.getAbyte());
     touts.writeShort(allTypeBean.getAshort());
     touts.writeChar(allTypeBean.getAchar());
     touts.writeInt(allTypeBean.getAint());
     touts.writeLong(allTypeBean.getAlong());
     touts.writeFloat(allTypeBean.getAfloat());
     touts.writeDouble(allTypeBean.getAdouble());
     touts.writeDate(allTypeBean.getAdate());
     touts.writeString(allTypeBean.getAstring());
 }
 public static void getByteArray(Dictionary <String, Double> doubleMap, TransferOutputStream touts)
 {
     foreach (KeyValuePair <String, Double> item in doubleMap)
     {
         // type
         touts.writeByte(TransferObject.DATATYPE_DOUBLE);
         // key
         String key = item.Key;
         touts.writeString(key);
         // value
         double value = item.Value;
         touts.writeDouble(value);
     }
 }
Exemple #5
0
 public static void getByteArray(Dictionary <String, Boolean> booleanMap, TransferOutputStream touts)
 {
     foreach (KeyValuePair <String, Boolean> item in booleanMap)
     {
         // type
         touts.writeByte(TransferObject.DATATYPE_BOOLEAN);
         // key
         String key = item.Key;
         touts.writeString(key);
         // value
         bool value = item.Value;
         touts.writeBoolean(value);
     }
 }
 public static void getByteArray(Dictionary <String, int[]> intArrayMap, TransferOutputStream touts)
 {
     foreach (KeyValuePair <String, int[]> item in intArrayMap)
     {
         // type
         touts.writeByte(TransferObject.DATATYPE_INTARRAY);
         // key
         String key = item.Key;
         touts.writeString(key);
         // value
         int[] values = item.Value;
         touts.writeIntArray(values);
     }
 }
 public static void getByteArray(Dictionary <String, Char> charMap, TransferOutputStream touts)
 {
     foreach (KeyValuePair <String, Char> item in charMap)
     {
         // type
         touts.writeByte(TransferObject.DATATYPE_CHAR);
         // key
         String key = item.Key;
         touts.writeString(key);
         // value
         char value = item.Value;
         touts.writeChar(value);
     }
 }
 public static void getByteArray(Dictionary <String, Single> floatMap, TransferOutputStream touts)
 {
     foreach (KeyValuePair <String, Single> item in floatMap)
     {
         // type
         touts.writeByte(TransferObject.DATATYPE_FLOAT);
         // key
         String key = item.Key;
         touts.writeString(key);
         // value
         float value = item.Value;
         touts.writeFloat(value);
     }
 }
Exemple #9
0
 public static void getByteArray(Dictionary <String, Int16> shortMap, TransferOutputStream touts)
 {
     foreach (KeyValuePair <String, Int16> item in shortMap)
     {
         // type
         touts.writeByte(TransferObject.DATATYPE_SHORT);
         // key
         String key = item.Key;
         touts.writeString(key);
         // value
         short value = item.Value;
         touts.writeShort(value);
     }
 }
Exemple #10
0
 public static void getByteArray(Dictionary <String, String> stringMap, TransferOutputStream touts)
 {
     foreach (KeyValuePair <String, String> item in stringMap)
     {
         // type
         touts.writeByte(TransferObject.DATATYPE_STRING);
         // key
         String key = item.Key;
         touts.writeString(key);
         // value
         String value = item.Value;
         touts.writeString(value);
     }
 }
        public override byte[] getByteData()
        {
            int blength = getByteArrayLength();

            byte[] byteArray = new byte[TransferUtil.getLengthOfInt() + blength];

            TransferOutputStream touts = new TransferOutputStream(byteArray);

            touts.writeInt(blength);
            touts.writeString(calleeClass);
            touts.writeString(calleeMethod);
            touts.writeByte(returnType);
            touts.writeBoolean(compress);

            foreach (ValueObject vo in paramList)
            {
                if (vo.dataType == DATATYPE_BOOLEAN)
                {
                    touts.writeByte(DATATYPE_BOOLEAN);
                    touts.writeBoolean((bool)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_BYTE)
                {
                    touts.writeByte(DATATYPE_BYTE);
                    touts.writeByte((byte)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_SHORT)
                {
                    touts.writeByte(DATATYPE_SHORT);
                    touts.writeShort((short)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_CHAR)
                {
                    touts.writeByte(DATATYPE_CHAR);
                    touts.writeChar((char)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_INT)
                {
                    touts.writeByte(DATATYPE_INT);
                    touts.writeInt((int)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_LONG)
                {
                    touts.writeByte(DATATYPE_LONG);
                    touts.writeLong((long)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_FLOAT)
                {
                    touts.writeByte(DATATYPE_FLOAT);
                    touts.writeFloat((float)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_DOUBLE)
                {
                    touts.writeByte(DATATYPE_DOUBLE);
                    touts.writeDouble((double)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_DATE)
                {
                    touts.writeByte(DATATYPE_DATE);
                    touts.writeDate((DateTime)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_STRING)
                {
                    touts.writeByte(DATATYPE_STRING);
                    touts.writeString((string)vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_BYTEARRAY)
                {
                    touts.writeByte(DATATYPE_BYTEARRAY);
                    touts.writeByteArray((byte[])vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_INTARRAY)
                {
                    touts.writeByte(DATATYPE_INTARRAY);
                    touts.writeIntArray((int[])vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_LONGARRAY)
                {
                    touts.writeByte(DATATYPE_LONGARRAY);
                    touts.writeLongArray((long[])vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_FLOATARRAY)
                {
                    touts.writeByte(DATATYPE_FLOATARRAY);
                    touts.writeFloatArray((float[])vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_DOUBLEARRAY)
                {
                    touts.writeByte(DATATYPE_DOUBLEARRAY);
                    touts.writeDoubleArray((double[])vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_STRINGARRAY)
                {
                    touts.writeByte(DATATYPE_STRINGARRAY);
                    touts.writeStringArray((string[])vo.dataObject);
                }
                else if (vo.dataType == DATATYPE_WRAPPER)
                {
                    touts.writeByte(DATATYPE_WRAPPER);
                    touts.writeWrapper((TransferObjectWrapper)vo.dataObject);
                }
            }

            return(byteArray);
        }
Exemple #12
0
 public void getByteArray(TransferOutputStream touts)
 {
     touts.writeInt(account.getId());
     touts.writeString(account.getName());
     touts.writeString(account.getAddress());
 }
 public static void getByteArray(Dictionary <String, TransferObjectWrapper> wrapperMap, TransferOutputStream touts)
 {
     foreach (KeyValuePair <String, TransferObjectWrapper> item in wrapperMap)
     {
         // type
         touts.writeByte(TransferObject.DATATYPE_WRAPPER);
         // key
         String key = item.Key;
         touts.writeString(key);
         // value
         TransferObjectWrapper value = item.Value;
         touts.writeWrapper(value);
     }
 }