1 package org.openflow.codec.io;
3 import java.nio.ByteBuffer;
6 * Creates a new IDataBuffer by allocating new space. DataBuffers is responsible
7 * to create buffer class that will used by test cases. currently it instantiate
8 * ByteDataBuffer (java's ByteBuffer) but it can be updated to support other
9 * data buffer in future.
14 public final class DataBuffers {
16 * private constructor to protect instantiation
18 private DataBuffers() {
23 * get a new data buffer.
26 * The new buffer's capacity, in bytes
28 * @return The new data buffer
30 * @throws IllegalArgumentException
31 * If the <tt>capacity</tt> is a negative integer
33 public static IDataBuffer allocate(int capacity) {
35 ByteBuffer bytebuffer = ByteBuffer.allocateDirect(capacity);
36 ByteDataBuffer dataBuffer = new ByteDataBuffer(bytebuffer);