Skip to content

Commit 189797b

Browse files
committed
Rename Endpoint methods for consistency
1 parent 8ec1ca6 commit 189797b

3 files changed

Lines changed: 39 additions & 25 deletions

File tree

roc_jni/src/main/export/org_rocstreaming_roctoolkit_Endpoint.h

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

roc_jni/src/main/impl/endpoint.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void endpoint_set_resource(JNIEnv* env, jobject endpoint, const char* buf) {
134134
(*env)->SetObjectField(env, endpoint, attrId, (*env)->NewStringUTF(env, buf));
135135
}
136136

137-
JNIEXPORT void JNICALL Java_org_rocstreaming_roctoolkit_Endpoint_init(
137+
JNIEXPORT void JNICALL Java_org_rocstreaming_roctoolkit_Endpoint_nativeParseUri(
138138
JNIEnv* env, jobject thisObj, jstring juri) {
139139
jclass endpointClass = NULL;
140140
roc_endpoint* endpoint = NULL;
@@ -226,7 +226,7 @@ JNIEXPORT void JNICALL Java_org_rocstreaming_roctoolkit_Endpoint_init(
226226
}
227227
}
228228

229-
JNIEXPORT jstring JNICALL Java_org_rocstreaming_roctoolkit_Endpoint_getUri(
229+
JNIEXPORT jstring JNICALL Java_org_rocstreaming_roctoolkit_Endpoint_nativeFormatUri(
230230
JNIEnv* env, jobject thisObj) {
231231
roc_endpoint* endpoint = NULL;
232232
jstring juri = NULL;
@@ -263,7 +263,7 @@ JNIEXPORT jstring JNICALL Java_org_rocstreaming_roctoolkit_Endpoint_getUri(
263263
return juri;
264264
}
265265

266-
JNIEXPORT void JNICALL Java_org_rocstreaming_roctoolkit_Endpoint_validate(
266+
JNIEXPORT void JNICALL Java_org_rocstreaming_roctoolkit_Endpoint_nativeValidate(
267267
JNIEnv* env, jobject thisObj) {
268268
roc_endpoint* endpoint = NULL;
269269
char* uri = NULL;

src/main/java/org/rocstreaming/roctoolkit/Endpoint.java

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)