Specifies the userinfo, host and port URI components all at once using a single string. This setter is "raw" in the sense that special characters in userinfo and host must be passed in percent-encoded. See RFC 3986 3.2 for t
(@Nullable String authority)
| 1005 | * port, or null to clear all three of those components |
| 1006 | */ |
| 1007 | @CanIgnoreReturnValue |
| 1008 | public Builder setRawAuthority(@Nullable String authority) { |
| 1009 | if (authority == null) { |
| 1010 | setUserInfo(null); |
| 1011 | setHost((String) null); |
| 1012 | setPort(-1); |
| 1013 | } else { |
| 1014 | // UserInfo. Easy because '@' cannot appear unencoded inside userinfo or host. |
| 1015 | int userInfoEnd = authority.indexOf('@'); |
| 1016 | if (userInfoEnd >= 0) { |
| 1017 | setRawUserInfo(authority.substring(0, userInfoEnd)); |
| 1018 | } else { |
| 1019 | setUserInfo(null); |
| 1020 | } |
| 1021 | |
| 1022 | // Host/Port. |
| 1023 | int hostStart = userInfoEnd >= 0 ? userInfoEnd + 1 : 0; |
| 1024 | int portStartColon = findPortStartColon(authority, hostStart); |
| 1025 | if (portStartColon < 0) { |
| 1026 | setRawHost(authority.substring(hostStart)); |
| 1027 | setPort(-1); |
| 1028 | } else { |
| 1029 | setRawHost(authority.substring(hostStart, portStartColon)); |
| 1030 | setRawPort(authority.substring(portStartColon + 1)); |
| 1031 | } |
| 1032 | } |
| 1033 | return this; |
| 1034 | } |
| 1035 | |
| 1036 | /** Builds a new instance of {@link Uri} as specified by the setters. */ |
| 1037 | public Uri build() { |