test_class.declarator: parser = new HostParser()
test_class.modifier: private final
test_class.original_string: private final HostParser parser = new HostParser();
test_class.type: HostParser
test_class.var_name: parser
test_class.file: plugins/networktables/src/test/java/edu/wpi/first/shuffleboard/plugin/networktables/HostParserTest.java
test_class.identifier: HostParserTest
test_case.body: @Test
    public void testTeamNumber() {
      var hostInfo = parser.parse("246").get();
      assertEquals("246", hostInfo.getHost());
      assertEquals(HostParser.DEFAULT_PORT, hostInfo.getPort());
    }
test_case.class_method_signature: HostParserTest.testTeamNumber()
test_case.full_signature: @Test public void testTeamNumber()
test_case.identifier: testTeamNumber
test_case.invocations: get parse assertEquals getHost assertEquals getPort
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testTeamNumber()
focal_class.declarator: log = Logger.getLogger(HostParser.class.getName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = Logger.getLogger(HostParser.class.getName());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: DEFAULT_PORT = NetworkTableInstance.kDefaultPort
focal_class.modifier: public static final
focal_class.original_string: public static final int DEFAULT_PORT = NetworkTableInstance.kDefaultPort;
focal_class.type: int
focal_class.var_name: DEFAULT_PORT
focal_class.file: plugins/networktables/src/main/java/edu/wpi/first/shuffleboard/plugin/networktables/HostParser.java
focal_class.identifier: HostParser
focal_class.class_method_signature: HostParser.parse(String rawHost)
focal_class.full_signature: public Optional<NtHostInfo> parse(String rawHost)
focal_class.identifier: parse
focal_class.modifiers: public
focal_class.parameters: (String rawHost)
focal_class.return: Optional<NtHostInfo>
focal_class.signature: Optional<NtHostInfo> parse(String rawHost)
focal_method.body: public Optional<NtHostInfo> parse(String rawHost) {
      try {
        // Make sure the URI starts with http:// or https// so the URI constructor can parse it
        String str = rawHost.startsWith("http://") || rawHost.startsWith("https://") ? rawHost : "http://" + rawHost;
  
        URI uri = new URI(str);
        String host = uri.getHost();
  
        if (host == null) {
          log.warning("No host or invalid host specified: '" + rawHost + "'");
          return Optional.empty();
        }
  
        int port = uri.getPort();
  
        if (port == -1) {
          return Optional.of(NtHostInfo.onDefaultPort(host));
        } else {
          return Optional.of(new NtHostInfo(host, port));
        }
      } catch (URISyntaxException e) {
        log.log(Level.WARNING, "Invalid NetworkTables host: " + rawHost, e);
        return Optional.empty();
      }
    }
focal_method.class_method_signature: HostParser.parse(String rawHost)
focal_method.full_signature: public Optional<NtHostInfo> parse(String rawHost)
focal_method.identifier: parse
focal_method.invocations: startsWith startsWith getHost warning empty getPort of onDefaultPort of log empty
focal_method.modifiers: public
focal_method.parameters: (String rawHost)
focal_method.return: Optional<NtHostInfo>
focal_method.signature: Optional<NtHostInfo> parse(String rawHost)