test_class.declarator: logger = LoggerFactory.getLogger(URLParserTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory.getLogger(URLParserTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.file: ch-commons-util/src/test/java/com/cloudhopper/commons/util/URLParserTest.java
test_class.identifier: URLParserTest
test_case.body: @Test
      public void parse1() throws Exception {
          URL url0 = URLParser.parse("file:///");
          Assert.assertEquals("file", url0.getProtocol());
          Assert.assertEquals(null, url0.getUsername());
          Assert.assertEquals(null, url0.getPassword());
          Assert.assertEquals(null, url0.getHost());
          Assert.assertEquals(null, url0.getPort());
          Assert.assertEquals("/", url0.getPath());
      }
test_case.class_method_signature: URLParserTest.parse1()
test_case.full_signature: @Test public void parse1()
test_case.identifier: parse1
test_case.invocations: parse assertEquals getProtocol assertEquals getUsername assertEquals getPassword assertEquals getHost assertEquals getPort assertEquals getPath
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void parse1()
focal_class.declarator: logger = LoggerFactory.getLogger(URLParser.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(URLParser.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: ch-commons-util/src/main/java/com/cloudhopper/commons/util/URLParser.java
focal_class.identifier: URLParser
focal_class.class_method_signature: URLParser.URLParser()
focal_class.full_signature: private  URLParser()
focal_class.identifier: URLParser
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  URLParser()
focal_class.class_method_signature: URLParser.decode(String str0)
focal_class.full_signature: static private String decode(String str0)
focal_class.identifier: decode
focal_class.modifiers: static private
focal_class.parameters: (String str0)
focal_class.return: String
focal_class.signature: String decode(String str0)
focal_class.class_method_signature: URLParser.parse(String url)
focal_class.full_signature: static public URL parse(String url)
focal_class.identifier: parse
focal_class.modifiers: static public
focal_class.parameters: (String url)
focal_class.return: URL
focal_class.signature: URL parse(String url)
focal_method.body: static public URL parse(String url) throws MalformedURLException {
  
          int pos = 0;
  
  //        logger.debug("parsing URL: " + url);
  
          //
          // parse protocol
          //
          int i = url.indexOf("://");
          if (i < 0) {
              throw new MalformedURLException("Invalid URL [" + url + "]: no protocol specified");
          }
  
          // the url we'll be returning
          URL r = new URL();
          
          String protocol = url.substring(0, i);
          r.setProtocol(protocol);
  //        logger.debug("parsed protocol: " + protocol);
  
          // skip :// part
          pos = i + 3;
  
          // username[:password]
          i = url.indexOf('@', pos);
          if (i >= 0) {
              // found url to contain a username and possibly a password
  //            logger.debug("found @ char to indicate username:password");
              String userPass = url.substring(pos, i);
              int atPos = userPass.indexOf(':');
              if (atPos >= 0) {
                  // password exists in this string
                  String username = userPass.substring(0, atPos);
                  String password = userPass.substring(atPos+1);
                  if (username != null && username.length() > 0) {
                      r.setUsername(decode(username));
                  }
                  if (password != null && password.length() > 0) {
                      r.setPassword(decode(password));
                  }
              } else {
  //                logger.debug("userPass part only includes a username");
                  if (userPass.length() > 0) {
                      r.setUsername(decode(userPass));
                  }
              }
              // update the position for the next parsing section
              pos = i + 1;
          }
  
          //
          // host[:port]
          //
          i = url.indexOf('/', pos);
          if (i < 0) {
              // maybe to the query string then
              i = url.indexOf('?', pos);
              if (i < 0) {
                  // host:port is to the complete end of this string
                  i = url.length();
              }
          }
  
          // extract entire host and/or port
          String hostPort = url.substring(pos, i);
  
          // did a host actually exist?
          if (hostPort != null && hostPort.length() > 0) {
              // does this hostPort contain a port?
              int colPos = hostPort.indexOf(':');
              if (colPos >= 0) {
                  String host = hostPort.substring(0, colPos);
                  r.setHost(host);
  //                logger.debug("parsed host: " + host);
  
                  String tempPort = hostPort.substring(colPos+1);
                  try {
                      Integer port = Integer.valueOf(tempPort);
                      r.setPort(port);
  //                    logger.debug("parsed port: " + port);
                  } catch (NumberFormatException e) {
                      throw new MalformedURLException("Invalid URL [" + url + "]: port '" + tempPort + "' was not an integer");
                  }
              } else {
                  // entire string is the host
                  r.setHost(hostPort);
  //                logger.debug("parsed host: " + hostPort);
              }
          } else {
  //            logger.debug("no host parsed");
          }
  
          // next position we'll start parsing from actually starts next
          pos = i;
  
          // we may be done
          if (pos >= url.length()) {
  //            logger.debug("early parsing exist after host:port section");
              return r;
          }
  
          // if we get here, then we know there is more data in the url to parse
          // the next character will either be / or ?
          if (url.charAt(pos) == '/') {
              // we either will read to end of string or till ?
              i = url.indexOf('?');
              if (i < 0) {
                  // read till end of string
                  i = url.length();
              }
              String path = url.substring(pos, i);
              r.setPath(decode(path));
  //            logger.debug("parsed path: " + path);
          }
  
          pos = i;
  
          // we may be done
          if (pos >= url.length()) {
  //            logger.debug("early parsing exist after path section");
              return r;
          }
  
          // we may have parsed the path above, now parse the query string
          if (url.charAt(pos) == '?') {
              String query = url.substring(pos+1);
              if (query != null && query.length() > 0) {
                  r.setQuery(query);
              }
          }
  
          return r;
      }
focal_method.class_method_signature: URLParser.parse(String url)
focal_method.full_signature: static public URL parse(String url)
focal_method.identifier: parse
focal_method.invocations: indexOf substring setProtocol indexOf substring indexOf substring substring length setUsername decode length setPassword decode length setUsername decode indexOf indexOf length substring length indexOf substring setHost substring valueOf setPort setHost length charAt indexOf length substring setPath decode length charAt substring length setQuery
focal_method.modifiers: static public
focal_method.parameters: (String url)
focal_method.return: URL
focal_method.signature: URL parse(String url)