@@ -34,11 +34,11 @@ class Decoder {
3434
3535 private final CharsetDecoder utfDecoder = UTF_8 .newDecoder ();
3636
37- private final ByteBuffer buffer ;
37+ private final Buffer buffer ;
3838
3939 private final ConcurrentHashMap <Class <?>, CachedConstructor <?>> constructors ;
4040
41- Decoder (NodeCache cache , ByteBuffer buffer , long pointerBase ) {
41+ Decoder (NodeCache cache , Buffer buffer , long pointerBase ) {
4242 this (
4343 cache ,
4444 buffer ,
@@ -49,7 +49,7 @@ class Decoder {
4949
5050 Decoder (
5151 NodeCache cache ,
52- ByteBuffer buffer ,
52+ Buffer buffer ,
5353 long pointerBase ,
5454 ConcurrentHashMap <Class <?>, CachedConstructor <?>> constructors
5555 ) {
@@ -61,7 +61,7 @@ class Decoder {
6161
6262 private final NodeCache .Loader cacheLoader = this ::decode ;
6363
64- <T > T decode (int offset , Class <T > cls ) throws IOException {
64+ <T > T decode (long offset , Class <T > cls ) throws IOException {
6565 if (offset >= this .buffer .capacity ()) {
6666 throw new InvalidDatabaseException (
6767 "The MaxMind DB file's data section contains bad data: "
@@ -73,7 +73,7 @@ <T> T decode(int offset, Class<T> cls) throws IOException {
7373 }
7474
7575 private <T > DecodedValue decode (CacheKey <T > key ) throws IOException {
76- int offset = key .offset ();
76+ long offset = key .offset ();
7777 if (offset >= this .buffer .capacity ()) {
7878 throw new InvalidDatabaseException (
7979 "The MaxMind DB file's data section contains bad data: "
@@ -132,8 +132,8 @@ private <T> DecodedValue decode(Class<T> cls, java.lang.reflect.Type genericType
132132
133133 DecodedValue decodePointer (long pointer , Class <?> cls , java .lang .reflect .Type genericType )
134134 throws IOException {
135- int targetOffset = ( int ) pointer ;
136- int position = buffer .position ();
135+ long targetOffset = pointer ;
136+ long position = buffer .position ();
137137
138138 CacheKey <?> key = new CacheKey <>(targetOffset , cls , genericType );
139139 DecodedValue o = cache .get (key , cacheLoader );
@@ -185,10 +185,10 @@ private <T> Object decodeByType(
185185 }
186186 }
187187
188- private String decodeString (int size ) throws CharacterCodingException {
189- int oldLimit = buffer .limit ();
188+ private String decodeString (long size ) throws CharacterCodingException {
189+ long oldLimit = buffer .limit ();
190190 buffer .limit (buffer .position () + size );
191- String s = utfDecoder .decode (buffer ). toString ( );
191+ String s = buffer .decode (utfDecoder );
192192 buffer .limit (oldLimit );
193193 return s ;
194194 }
@@ -221,7 +221,7 @@ private int decodeInteger(int base, int size) {
221221 return Decoder .decodeInteger (this .buffer , base , size );
222222 }
223223
224- static int decodeInteger (ByteBuffer buffer , int base , int size ) {
224+ static int decodeInteger (Buffer buffer , int base , int size ) {
225225 int integer = base ;
226226 for (int i = 0 ; i < size ; i ++) {
227227 integer = (integer << 8 ) | (buffer .get () & 0xFF );
@@ -412,7 +412,7 @@ private <T> Object decodeMapIntoObject(int size, Class<T> cls)
412412
413413 Integer parameterIndex = parameterIndexes .get (key );
414414 if (parameterIndex == null ) {
415- int offset = this .nextValueOffset (this .buffer .position (), 1 );
415+ long offset = this .nextValueOffset (this .buffer .position (), 1 );
416416 this .buffer .position (offset );
417417 continue ;
418418 }
@@ -485,7 +485,7 @@ private static <T> String getParameterName(
485485 + " is not annotated with MaxMindDbParameter." );
486486 }
487487
488- private int nextValueOffset (int offset , int numberToSkip )
488+ private long nextValueOffset (long offset , int numberToSkip )
489489 throws InvalidDatabaseException {
490490 if (numberToSkip == 0 ) {
491491 return offset ;
@@ -518,7 +518,7 @@ private int nextValueOffset(int offset, int numberToSkip)
518518 return nextValueOffset (offset , numberToSkip - 1 );
519519 }
520520
521- private CtrlData getCtrlData (int offset )
521+ private CtrlData getCtrlData (long offset )
522522 throws InvalidDatabaseException {
523523 if (offset >= this .buffer .capacity ()) {
524524 throw new InvalidDatabaseException (
@@ -566,7 +566,7 @@ private byte[] getByteArray(int length) {
566566 return Decoder .getByteArray (this .buffer , length );
567567 }
568568
569- private static byte [] getByteArray (ByteBuffer buffer , int length ) {
569+ private static byte [] getByteArray (Buffer buffer , int length ) {
570570 byte [] bytes = new byte [length ];
571571 buffer .get (bytes );
572572 return bytes ;
0 commit comments