test_class.file: app/src/test/java/org/jak_linux/dns66/db/RuleDatabaseTest.java
test_class.identifier: RuleDatabaseTest
test_case.body: @Test
      public void testParseLine() throws Exception {
          // Standard format lines
          assertEquals("example.com", RuleDatabase.parseLine("0.0.0.0 example.com"));
          assertEquals("example.com", RuleDatabase.parseLine("127.0.0.1 example.com"));
          assertEquals("example.com", RuleDatabase.parseLine("::1 example.com"));
          assertEquals("example.com", RuleDatabase.parseLine("example.com"));
          // Comments
          assertEquals("example.com", RuleDatabase.parseLine("example.com # foo"));
          assertEquals("example.com", RuleDatabase.parseLine("0.0.0.0 example.com # foo"));
          assertEquals("example.com", RuleDatabase.parseLine("::1 example.com # foo"));
          // Check lower casing
          assertEquals("example.com", RuleDatabase.parseLine("example.cOm"));
          assertEquals("example.com", RuleDatabase.parseLine("127.0.0.1 example.cOm"));
          assertEquals("example.com", RuleDatabase.parseLine("::1 example.cOm"));
          // Space trimming
          assertNull(RuleDatabase.parseLine(" 127.0.0.1 example.com"));
          assertEquals("127.0.0.1.example.com", RuleDatabase.parseLine("127.0.0.1.example.com "));
          assertEquals("::1.example.com", RuleDatabase.parseLine("::1.example.com "));
          assertEquals("0.0.0.0.example.com", RuleDatabase.parseLine("0.0.0.0.example.com "));
          assertEquals("example.com", RuleDatabase.parseLine("127.0.0.1 example.com "));
          assertEquals("example.com", RuleDatabase.parseLine("127.0.0.1 example.com\t"));
          assertEquals("example.com", RuleDatabase.parseLine("127.0.0.1   example.com "));
          assertEquals("example.com", RuleDatabase.parseLine("127.0.0.1\t example.com "));
          assertEquals("example.com", RuleDatabase.parseLine("::1\t example.com "));
          // Space between values
          // Invalid lines
          assertNull(RuleDatabase.parseLine("127.0.0.1 "));
          assertNull(RuleDatabase.parseLine("127.0.0.1"));
          assertNull(RuleDatabase.parseLine("0.0.0.0"));
          assertNull(RuleDatabase.parseLine("0.0.0.0 "));
          assertNull(RuleDatabase.parseLine("::1 "));
          assertNull(RuleDatabase.parseLine("::1"));
          assertNull(RuleDatabase.parseLine("invalid example.com"));
          assertNull(RuleDatabase.parseLine("invalid\texample.com"));
          assertNull(RuleDatabase.parseLine("invalid long line"));
          assertNull(RuleDatabase.parseLine("# comment line"));
          assertNull(RuleDatabase.parseLine(""));
          assertNull(RuleDatabase.parseLine("\t"));
          assertNull(RuleDatabase.parseLine(" "));
      }
test_case.class_method_signature: RuleDatabaseTest.testParseLine()
test_case.full_signature: @Test public void testParseLine()
test_case.identifier: testParseLine
test_case.invocations: assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertNull parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertEquals parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine assertNull parseLine
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testParseLine()
focal_class.declarator: TAG = "RuleDatabase"
focal_class.modifier: private static final
focal_class.original_string: private static final String TAG = "RuleDatabase";
focal_class.type: String
focal_class.var_name: TAG
focal_class.declarator: instance = new RuleDatabase()
focal_class.modifier: private static final
focal_class.original_string: private static final RuleDatabase instance = new RuleDatabase();
focal_class.type: RuleDatabase
focal_class.var_name: instance
focal_class.declarator: blockedHosts = new AtomicReference<>(new HashSet<String>())
focal_class.modifier: final
focal_class.original_string: final AtomicReference<HashSet<String>> blockedHosts = new AtomicReference<>(new HashSet<String>());
focal_class.type: AtomicReference<HashSet<String>>
focal_class.var_name: blockedHosts
focal_class.declarator: nextBlockedHosts = null
focal_class.original_string: HashSet<String> nextBlockedHosts = null;
focal_class.type: HashSet<String>
focal_class.var_name: nextBlockedHosts
focal_class.file: app/src/main/java/org/jak_linux/dns66/db/RuleDatabase.java
focal_class.identifier: RuleDatabase
focal_class.class_method_signature: RuleDatabase.RuleDatabase()
focal_class.full_signature:   RuleDatabase()
focal_class.identifier: RuleDatabase
focal_class.parameters: ()
focal_class.signature:  RuleDatabase()
focal_class.class_method_signature: RuleDatabase.getInstance()
focal_class.full_signature: public static RuleDatabase getInstance()
focal_class.identifier: getInstance
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: RuleDatabase
focal_class.signature: RuleDatabase getInstance()
focal_class.class_method_signature: RuleDatabase.parseLine(String line)
focal_class.full_signature: @Nullable static String parseLine(String line)
focal_class.identifier: parseLine
focal_class.modifiers: @Nullable static
focal_class.parameters: (String line)
focal_class.return: String
focal_class.signature: String parseLine(String line)
focal_class.class_method_signature: RuleDatabase.isBlocked(String host)
focal_class.full_signature: public boolean isBlocked(String host)
focal_class.identifier: isBlocked
focal_class.modifiers: public
focal_class.parameters: (String host)
focal_class.return: boolean
focal_class.signature: boolean isBlocked(String host)
focal_class.class_method_signature: RuleDatabase.isEmpty()
focal_class.full_signature:  boolean isEmpty()
focal_class.identifier: isEmpty
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isEmpty()
focal_class.class_method_signature: RuleDatabase.initialize(Context context)
focal_class.full_signature: public synchronized void initialize(Context context)
focal_class.identifier: initialize
focal_class.modifiers: public synchronized
focal_class.parameters: (Context context)
focal_class.return: void
focal_class.signature: void initialize(Context context)
focal_class.class_method_signature: RuleDatabase.loadItem(Context context, Configuration.Item item)
focal_class.full_signature: private void loadItem(Context context, Configuration.Item item)
focal_class.identifier: loadItem
focal_class.modifiers: private
focal_class.parameters: (Context context, Configuration.Item item)
focal_class.return: void
focal_class.signature: void loadItem(Context context, Configuration.Item item)
focal_class.class_method_signature: RuleDatabase.addHost(Configuration.Item item, String host)
focal_class.full_signature: private void addHost(Configuration.Item item, String host)
focal_class.identifier: addHost
focal_class.modifiers: private
focal_class.parameters: (Configuration.Item item, String host)
focal_class.return: void
focal_class.signature: void addHost(Configuration.Item item, String host)
focal_class.class_method_signature: RuleDatabase.loadReader(Configuration.Item item, Reader reader)
focal_class.full_signature:  boolean loadReader(Configuration.Item item, Reader reader)
focal_class.identifier: loadReader
focal_class.parameters: (Configuration.Item item, Reader reader)
focal_class.return: boolean
focal_class.signature: boolean loadReader(Configuration.Item item, Reader reader)
focal_method.body: @Nullable
      static String parseLine(String line) {
          int endOfLine = line.indexOf('#');
  
          if (endOfLine == -1)
              endOfLine = line.length();
  
          // Trim spaces
          while (endOfLine > 0 && Character.isWhitespace(line.charAt(endOfLine - 1)))
              endOfLine--;
  
          // The line is empty.
          if (endOfLine <= 0)
              return null;
  
          // Find beginning of host field
          int startOfHost = 0;
  
          if (line.regionMatches(0, "127.0.0.1", 0, 9) && (endOfLine <= 9 || Character.isWhitespace(line.charAt(9))))
              startOfHost += 10;
          else if (line.regionMatches(0, "::1", 0, 3) && (endOfLine <= 3 || Character.isWhitespace(line.charAt(3))))
              startOfHost += 4;
          else if (line.regionMatches(0, "0.0.0.0", 0, 7) && (endOfLine <= 7 || Character.isWhitespace(line.charAt(7))))
              startOfHost += 8;
  
          // Trim of space at the beginning of the host.
          while (startOfHost < endOfLine && Character.isWhitespace(line.charAt(startOfHost)))
              startOfHost++;
  
          // Reject lines containing a space
          for (int i = startOfHost; i < endOfLine; i++) {
              if (Character.isWhitespace(line.charAt(i)))
                  return null;
          }
  
          if (startOfHost >= endOfLine)
              return null;
  
          return line.substring(startOfHost, endOfLine).toLowerCase(Locale.ENGLISH);
      }
focal_method.class_method_signature: RuleDatabase.parseLine(String line)
focal_method.full_signature: @Nullable static String parseLine(String line)
focal_method.identifier: parseLine
focal_method.invocations: indexOf length isWhitespace charAt regionMatches isWhitespace charAt regionMatches isWhitespace charAt regionMatches isWhitespace charAt isWhitespace charAt isWhitespace charAt toLowerCase substring
focal_method.modifiers: @Nullable static
focal_method.parameters: (String line)
focal_method.return: String
focal_method.signature: String parseLine(String line)