private static void tooManyFields() throws FIXMessageOverflowException { throw new FIXMessageOverflowException("Too many fields"); }
private static void tooLongMessage() throws FIXMessageOverflowException { throw new FIXMessageOverflowException("Too long message"); }
/** * Receive data from the underlying socket channel. For each message * received, invoke the message listener if applicable. * * @return the number of bytes read, possibly zero, or -1 if the channel * has reached end-of-stream * @throws IOException if an I/O error occurs */ public int receive() throws IOException { int bytes = channel.read(rxBuffer); if (bytes <= 0) return bytes; rxBuffer.flip(); while (parser.parse(rxBuffer)); rxBuffer.compact(); if (rxBuffer.position() == rxBuffer.capacity()) throw new FIXMessageOverflowException("Too long message"); lastRxMillis = currentTimeMillis; return bytes; }
/** * Read this message from a buffer. * * @param buffer a buffer * @return true if this message was successfully read from the buffer, * otherwise false * @throws FIXMessageOverflowException if the number of fields exceeds the * maximum number of fields * @throws FIXValueOverflowException if the length of a value exceeds the * capacity of the value container */ public boolean get(ByteBuffer buffer) throws FIXMessageOverflowException, FIXValueOverflowException { reset(); while (buffer.hasRemaining()) { if (count == tags.length) throw new FIXMessageOverflowException("Too many fields"); int tag = FIXTags.get(buffer); if (tag == 0) return false; tags[count] = tag; if (!values[count].get(buffer)) return false; count++; } return true; }