java.lang.Object
com.maxmind.db.Reader.Walker
Enclosing class:
Reader

private class Reader.Walkerextends Object
Walks the search tree writing the IPv4 ranges of one country.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final ByteBuffer
    Buffer holding the database data.
    private final String
    The country code being walked.
    private int
    Record number of the country being walked, -1 until found.
    private final Set<Integer>
    Node numbers already reported as not found.
    private final int
    Number of nodes in the search tree.
    private final Writer
    Where the walk writes its output.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Walker(String country, Writer out)
    Write all IPv4 address ranges for the given country to out.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Writes the IPv4 ranges of the country, call once only.
    private void
    walk(int record, int ip, int depth)
    Recursive, depth first

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _country

      private final String _country
      The country code being walked.
    • _out

      private final Writer _out
      Where the walk writes its output.
    • _nodeCount

      private final int _nodeCount
      Number of nodes in the search tree.
    • _buffer

      private final ByteBuffer _buffer
      Buffer holding the database data.
    • _negativeCache

      private final Set<Integer> _negativeCache
      Node numbers already reported as not found.
    • _countryRecord

      private int _countryRecord
      Record number of the country being walked, -1 until found.
  • Constructor Details

    • Walker

      public Walker(String country, Writer out) throws IOException
      Write all IPv4 address ranges for the given country to out.
      Parameters:
      country - the ISO 3166-1 alpha-2 code, upper case
      out - where the ranges are written, in CIDR form
      Throws:
      IOException - declared by the signature, not thrown here
  • Method Details

    • walk

      public void walk() throws IOException
      Writes the IPv4 ranges of the country, call once only.
      Throws:
      IOException - if the output write fails
    • walk

      private void walk(int record, int ip, int depth) throws IOException
      Recursive, depth first
      Parameters:
      record - the node number being visited
      ip - the IPv4 prefix walked so far, packed into the high bits of an int
      depth - the number of address bits already walked
      Throws:
      IOException - if the output write fails