static int getValidInt( final AsciiBuffer timestamp, final int startInclusive, final int endExclusive, final int min, final int max) { final int value = timestamp.getNatural(startInclusive, endExclusive); if (value < min || value > max) { throw new IllegalArgumentException(format("Invalid value: %s outside of range %d-%d", value, min, max)); } return value; }
private void collectImportantFields( final int equalsPosition, final int valueOffset, final int endOfField, final int valueLength) { if (tag == CHECKSUM) { checksum = string.getNatural(valueOffset, endOfField); checksumOffset = equalsPosition - 2; } else if (tag == MESSAGE_TYPE) { messageType = string.getMessageType(valueOffset, valueLength); } }
public static int decode(final AsciiBuffer date, final int offset) { final int endYear = offset + SIZE_OF_YEAR; final int endMonth = endYear + SIZE_OF_MONTH; final int endDay = endMonth + SIZE_OF_DAY; final int year = date.getNatural(offset, endYear); final int month = getValidInt(date, endYear, endMonth, 1, 12); final int day = getValidInt(date, endMonth, endDay, 1, 31); return toEpochDay(year, month, day); } }
/** * Decode a FIX local mkt date value from a buffer into an epoch days int value. * * @param timestamp the buffer containing the FIX local mkt date value * @param offset the position in the buffer where the value starts * @param length the length of the value in bytes * @return an int representing the number of days since the beginning of the epoch in the local timezone. */ public static int decode(final AsciiBuffer timestamp, final int offset, final int length) { final int endYear = offset + 4; final int endMonth = endYear + 2; final int endDay = endMonth + 2; final int year = timestamp.getNatural(offset, endYear); final int month = getValidInt(timestamp, endYear, endMonth, 1, 12); final int day = getValidInt(timestamp, endMonth, endDay, 1, 31); return toEpochDay(year, month, day); } }
final int endMonth = endYear + SIZE_OF_MONTH; final int year = buffer.getNatural(offset, endYear); final int month = buffer.getNatural(endYear, endMonth); final int weekOfMonth = buffer.getNatural(startWeek, endWeek); final int dayOfMonth = buffer.getNatural(endMonth, endDay);
private int parseGroup( final int tag, final int valueOffset, final int endOfField, final int end, final IntHashSet groupFields) { final int numberOfElements = string.getNatural(valueOffset, endOfField); acceptor.onGroupHeader(tag, numberOfElements); if (numberOfElements > 0) { if (groupBegin(tag, numberOfElements, 0) == STOP) { return ~endOfField; } final int position = parseFields(endOfField + 1, end, tag, groupFields, numberOfElements); if (position == end) { if (groupEnd(tag, numberOfElements, numberOfElements - 1) == STOP) { return ~position; } } return position; } return endOfField; }
if (offset + length > endSecond && time.isDigit(startFraction)) fraction = time.getNatural(startFraction, endFraction);
tag = string.getNatural(position, equalsPosition); final int valueOffset = equalsPosition + 1; final int endOfField = string.scan(valueOffset, end, START_OF_HEADER);