java.lang.Object
com.maxmind.db.BufferHolder
Holds a ByteBuffer for MaxMind database access. Provides thread-safe access to database data either memory-mapped or loaded into memory.
Field Summary
FieldsConstructor Summary
ConstructorsConstructorDescriptionBufferHolder(File database, Reader.FileMode mode) Create a BufferHolder from a database file.BufferHolder(InputStream stream) Construct a ThreadBuffer from the provided URL.BufferHolder(ByteBuffer buffer) Create a BufferHolder from a ByteBuffer.Method Summary
All MethodsModifier and TypeMethodDescription(package private) ByteBufferget()Returns a duplicate of the underlying ByteBuffer.
Field Details
buffer
The buffer backing the reads. Do not pass it outside this class - doing so removes the thread safety.
Constructor Details
BufferHolder
BufferHolder(File database, Reader.FileMode mode) throws IOException Create a BufferHolder from a database file.- Parameters:
database- the database filemode- the file mode- Throws:
IOException- if the file cannot be read
BufferHolder
BufferHolder(InputStream stream) throws IOException Construct a ThreadBuffer from the provided URL.- Parameters:
stream- the source of my bytes.- Throws:
IOException- if unable to read from your source.NullPointerException- if you provide a NULL InputStream
BufferHolder
BufferHolder(ByteBuffer buffer) Create a BufferHolder from a ByteBuffer. This is just to ease unit testing.- Parameters:
buffer- the byte buffer
Method Details
get
ByteBuffer get()Returns a duplicate of the underlying ByteBuffer. The returned ByteBuffer should not be shared between threads.- Returns:
- a duplicate of the underlying ByteBuffer