/// <summary>
        ///
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public byte[] parse(FIELDS field)
        {
            fieldLength = field.GetLength();
            fieldType   = field.getType();
            fieldFormat = field.GetFormat();

            if (field.IsFixed())
            {
                return(fixedFieldParser());
            }
            else
            {
                return(varFieldParser());
            }
        }
        public DataElement <T> SetField(FIELDS field, byte[] value)
        {
            byte[] fValue = value;

            if (value == null)
            {
                throw new ISOException(field + " is Null");
            }
            //Length check and padding
            if (field.IsFixed())
            {
                if (field.GetLength() % 2 != 0)
                {
                    if (field.getType().Equals("n"))
                    {
//                        byte[] _fixed = new byte[(int) Math.Ceiling(field.GetLength()/2f)*2];
//
//                        for (int i = 0; i<fValue.Length; i++) {
//                            _fixed[i] = (byte) ((fValue[i] & 0x0F) << 4);
//                            if (i + 1 < value.Length)
//                                _fixed[i] += Convert.ToByte((fValue[i + 1] & 0xF0) >> 4);
//                        }
//
//                        _fixed[fValue.Length - 1] = (byte) (_fixed[fValue.Length - 1] + 0x0F);
//                        fValue = _fixed;
                    }
                }
                else if (field.GetLength() - (fValue.Length * 2) > 0 && field.getType().Equals("n"))
                {
                    ByteArray valueBuffer = new ByteArray();
                    valueBuffer.append(fValue);
                    valueBuffer.prepend(
                        Encoding.ASCII.GetBytes(new char[(field.GetLength() - (fValue.Length * 2)) / 2])
                        );
                    fValue = valueBuffer.array();
                    valueBuffer.clear();
                }

                if (fValue.Length > field.GetLength())
                {
                    fValue = Arrays.CopyOfRange(fValue, fValue.Length - field.GetLength(), fValue.Length);
                }
            }
            else
            {
                int dLen = fValue.Length;
                switch (field.getType())
                {
                case "z":
                    if (dLen > field.GetLength())
                    {
                        fValue = Arrays.CopyOfRange(fValue, fValue.Length - field.GetLength(), fValue.Length);
                    }

                    dLen = fValue.Length * 2;

                    break;
                }

                ByteArray valueBuffer = new ByteArray();
                valueBuffer.append(fValue);

                switch (field.GetFormat())
                {
                case "LL":
                    if (2 - dLen.ToString().Length <= 0)
                    {
                        valueBuffer.prepend(StringUtil.HexStringToByteArray(dLen + ""));
                    }
                    else
                    {
                        var eLen = (new String('0', (2 - dLen.ToString().Length) + dLen));
                        valueBuffer.prepend(
                            StringUtil.HexStringToByteArray(
                                eLen.Substring(eLen.Length - 2, 2)
                                ));
                    }
                    break;

                case "LLL":
                {
                    var eLen = '0' + new String('0', (4 - dLen.ToString().Length)) + dLen;

                    valueBuffer.prepend(
                        StringUtil.HexStringToByteArray(
                            eLen.Substring(eLen.Length - 4, 4)
                            ));
                }
                break;
                }

                fValue = valueBuffer.array();


                valueBuffer.clear();
                valueBuffer = null;
            }

            AddOrUpdateElement(field, fValue);

            return(this);
        }