MCPcopy Index your code
hub / github.com/davidgiven/luje / parseAuthority

Method parseAuthority

lib/java/net/URI.java:484–552  ·  view source on GitHub ↗

determine the host, port and userinfo if the authority parses successfully to a server based authority behavour in error cases: if forceServer is true, throw URISyntaxException with the proper diagnostic messages. if forceServer is false assume this is a registry based uri, and just return leaving

(boolean forceServer)

Source from the content-addressed store, hash-verified

482 * regardless of the forceServer parameter e.g. malformed ipv6 address
483 */
484 private void parseAuthority(boolean forceServer)
485 throws URISyntaxException {
486 if (authority == null) {
487 return;
488 }
489
490 String temp, tempUserinfo = null, tempHost = null;
491 int index, hostindex = 0;
492 int tempPort = -1;
493
494 temp = authority;
495 index = temp.indexOf('@');
496 if (index != -1) {
497 // remove user info
498 tempUserinfo = temp.substring(0, index);
499 validateUserinfo(authority, tempUserinfo, 0);
500 temp = temp.substring(index + 1); // host[:port] is left
501 hostindex = index + 1;
502 }
503
504 index = temp.lastIndexOf(':');
505 int endindex = temp.indexOf(']');
506
507 if (index != -1 && endindex < index) {
508 // determine port and host
509 tempHost = temp.substring(0, index);
510
511 if (index < (temp.length() - 1)) { // port part is not empty
512 try {
513 tempPort = Integer.parseInt(temp.substring(index + 1));
514 if (tempPort < 0) {
515 if (forceServer) {
516 throw new URISyntaxException(
517 authority,
518 Messages.getString("luni.8B"), hostindex + index + 1); //$NON-NLS-1$
519 }
520 return;
521 }
522 } catch (NumberFormatException e) {
523 if (forceServer) {
524 throw new URISyntaxException(authority, Messages
525 .getString("luni.8B"), hostindex + index + 1); //$NON-NLS-1$
526 }
527 return;
528 }
529 }
530 } else {
531 tempHost = temp;
532 }
533
534 if (tempHost.equals("")) { //$NON-NLS-1$
535 if (forceServer) {
536 throw new URISyntaxException(authority, Messages
537 .getString("luni.A0"), hostindex); //$NON-NLS-1$
538 }
539 return;
540 }
541

Callers 2

parseURIMethod · 0.95
parseServerAuthorityMethod · 0.80

Calls 9

indexOfMethod · 0.95
substringMethod · 0.95
validateUserinfoMethod · 0.95
lastIndexOfMethod · 0.95
lengthMethod · 0.95
parseIntMethod · 0.95
getStringMethod · 0.95
equalsMethod · 0.95
isValidHostMethod · 0.95

Tested by

no test coverage detected