java.lang.Object
com.maxmind.geoip2.DatabaseReader.Builder
- Enclosing class:
DatabaseReader
Constructs a Builder for the DatabaseReader. The file passed to it must be a valid GeoIP2 database file.
Builder creates instances of DatabaseReader from values set by the methods.
Only the values set in the Builder constructor are required.
Field Summary
Constructor Summary
ConstructorsConstructorDescriptionBuild a reader that memory-maps the database file.Builder(InputStream stream) Build a reader that reads the database from the stream.Method Summary
All MethodsModifier and TypeMethodDescriptionbuild()Build a reader from the fields set on this builder.fileMode(Reader.FileMode val) Reader.FileMode.MEMORY, but you provided a different FileMode to this method.Set the locale preference order for name properties.Set the node cache used to hold decoded search-tree nodes.
Field Details
database
Databasestream
Streamlocales
mode
Reader.FileMode modeModecache
NodeCache cacheCache
Constructor Details
Builder
Build a reader that reads the database from the stream.- Parameters:
stream- the stream containing the GeoIP2 database to use.
Builder
Build a reader that memory-maps the database file.- Parameters:
database- the GeoIP2 database file to use.
Method Details
locales
Set the locale preference order for name properties.- Parameters:
val- List of locale codes to use in name property from most preferred to least preferred.- Returns:
- Builder object
withCache
Set the node cache used to hold decoded search-tree nodes.- Parameters:
cache- backing cache instance- Returns:
- Builder object
fileMode
Reader.FileMode.MEMORY, but you provided a different FileMode to this method.- Parameters:
val- The file mode used to open the GeoIP2 database- Returns:
- Builder object
- Throws:
IllegalArgumentException- if you initialized the Builder with a URL, which uses
build
Build a reader from the fields set on this builder.- Returns:
- an instance of
DatabaseReadercreated from these fields - Throws:
IOException- if there is an error reading the database