@@ -94,12 +94,14 @@ public class Endpoint {
9494 private String resource ;
9595
9696 /**
97- * Create endpoint from uri
97+ * Create endpoint from URI
9898 *
99- * @param uri uri
99+ * @param uri URI to parse
100+ *
101+ * @throws IllegalArgumentException if URI is invalid
100102 */
101- public Endpoint (String uri ) {
102- init (uri );
103+ public Endpoint (String uri ) throws IllegalArgumentException {
104+ nativeParseUri (uri );
103105 }
104106
105107 /**
@@ -115,14 +117,16 @@ public Endpoint(String uri) {
115117 * <p>
116118 * If port is set to -1, the standard port for endpoint protocol is used. This is
117119 * allowed only if the protocol defines its standard port.
118- * @param resource resource nullable. Specifies percent-encoded path and query
120+ * @param resource resource is nullable. Specifies percent-encoded path and query
121+ *
122+ * @throws IllegalArgumentException if URI components don't form a valid URI
119123 */
120- public Endpoint (Protocol protocol , String host , int port , String resource ) {
124+ public Endpoint (Protocol protocol , String host , int port , String resource ) throws IllegalArgumentException {
121125 this .protocol = Check .notNull (protocol , "protocol" );
122126 this .host = Check .notEmpty (host , "host" );
123127 this .port = port ;
124128 this .resource = resource ;
125- validate ();
129+ nativeValidate ();
126130 }
127131
128132 /**
@@ -138,19 +142,29 @@ public Endpoint(Protocol protocol, String host, int port, String resource) {
138142 * <p>
139143 * If port is set to -1, the standard port for endpoint protocol is used. This is
140144 * allowed only if the protocol defines its standard port.
145+ *
146+ * @throws IllegalArgumentException if URI components don't form a valid URI
141147 */
142148 public Endpoint (Protocol protocol , String host , int port ) {
143149 this (protocol , host , port , null );
144150 }
145151
152+ /**
153+ * Get string URI describing this endpoint.
154+ */
155+ public String getUri () {
156+ return nativeFormatUri ();
157+ }
158+
159+ /**
160+ * Get string URI describing this endpoint.
161+ */
146162 @ Override
147163 public String toString () {
148164 return getUri ();
149165 }
150166
151- public native String getUri ();
152-
153- private native void init (String uri ) throws IllegalArgumentException ;
154-
155- private native void validate () throws IllegalArgumentException ;
167+ private native void nativeParseUri (String uri ) throws IllegalArgumentException ;
168+ private native String nativeFormatUri ();
169+ private native void nativeValidate () throws IllegalArgumentException ;
156170}
0 commit comments