コード例 #1
0
ファイル: FixUtils.java プロジェクト: mingfang/to-fix
  public static byte[] getTagStringValue(
      final byte[] msgType, final int tag, final ByteBuffer src, final byte[] dst)
      throws FixSessionException {
    int start = 0;
    final int end = dst.length;
    byte c = SOH;

    Utils.fillNul(dst);

    while ((c = src.get()) != SOH) {

      if (start >= end) {
        throw new FixSessionException(
            SessionRejectReason.VALUE_IS_INCORRECT_OUT_OF_RANGE_FOR_THIS_TAG,
            ("Value length exceeds maximum of " + end).getBytes(),
            tag,
            msgType);
      } else {
        dst[start] = c;
        start++;
      }
    }

    if (start == 0)
      throw new FixSessionException(
          SessionRejectReason.TAG_SPECIFIED_WITHOUT_A_VALUE,
          "Tag specified without a value".getBytes(),
          tag,
          msgType);

    return dst;
  }
コード例 #2
0
ファイル: FixUtils.java プロジェクト: mingfang/to-fix
  public static long getTagFloatValue(final byte[] msgType, final int tag, final ByteBuffer buf)
      throws FixSessionException {
    byte c;
    int start = 0;
    final int end = FIX_MAX_DIGITS - 2;

    Utils.fillNul(digitsBuf);

    while ((c = buf.get()) != SOH) {

      digitsBuf[start++] = c;

      if (start == end) {
        throw new FixSessionException(
            SessionRejectReason.VALUE_IS_INCORRECT_OUT_OF_RANGE_FOR_THIS_TAG,
            ("Value is incorrect or out of range for this tag " + FIX_MAX_DIGITS).getBytes(),
            tag,
            msgType);
      }
    }
    try {
      final long val = fixFloatValueOf(digitsBuf, start);
      return val;
    } catch (final NumberFormatException n) {
      throw new FixSessionException(
          SessionRejectReason.INCORRECT_DATA_FORMAT_FOR_VALUE,
          "Incorrect data format for value".getBytes(),
          tag,
          msgType);
    }
  }