88import java .nio .channels .FileChannel ;
99import java .util .Arrays ;
1010
11+ import com .fasterxml .jackson .databind .JsonNode ;
12+
1113public class Reader {
1214 private static final int DATA_SECTION_SEPARATOR_SIZE = 16 ;
1315 private static final byte [] METADATA_START_MARKER = { (byte ) 0xAB ,
@@ -63,8 +65,7 @@ public Reader(File database) throws MaxMindDbException, IOException {
6365 }
6466 }
6567
66- // FIXME - figure out what we are returning
67- public Object get (InetAddress address ) throws MaxMindDbException ,
68+ public JsonNode get (InetAddress address ) throws MaxMindDbException ,
6869 IOException {
6970
7071 long pointer = this .findAddressInTree (address );
@@ -136,7 +137,6 @@ long record = nodes[bit];
136137 nodeNum = record ;
137138 }
138139
139- // XXX - Can we get down here?
140140 throw new MaxMindDbException ("Something bad happened" );
141141 }
142142
@@ -184,8 +184,8 @@ private long[] splitNodeIntoRecords(ByteBuffer bytes)
184184 }
185185 }
186186
187- private Object resolveDataPointer (long pointer ) throws MaxMindDbException ,
188- IOException {
187+ private JsonNode resolveDataPointer (long pointer )
188+ throws MaxMindDbException , IOException {
189189 long resolved = (pointer - this .metadata .nodeCount )
190190 + this .metadata .searchTreeSize ;
191191
@@ -230,4 +230,13 @@ private long findMetadataStart() throws IOException {
230230 public Metadata getMetadata () {
231231 return this .metadata ;
232232 }
233+
234+ public void close () throws IOException {
235+ if (this .fc != null ) {
236+ this .fc .close ();
237+ }
238+ if (this .raf != null ) {
239+ this .raf .close ();
240+ }
241+ }
233242}
0 commit comments