Skip to content

Commit b2c678e

Browse files
Added javadoc to new classes
Change-Id: I1657d9f5571f18bf515858f017a5c28fbe257f67
1 parent daeb1e6 commit b2c678e

3 files changed

Lines changed: 97 additions & 0 deletions

File tree

websockets-rxjava-example/src/main/java/com/appunite/websocket/rx/object/GsonObjectSerializer.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2015 Jacek Marchwicki <jacek.marchwicki@gmail.com>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License
15+
*/
16+
117
package com.appunite.websocket.rx.object;
218

319
import com.google.gson.Gson;

websockets-rxjava/src/main/java/com/appunite/websocket/rx/object/ObjectParseException.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
1+
/*
2+
* Copyright (C) 2015 Jacek Marchwicki <jacek.marchwicki@gmail.com>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License
15+
*/
16+
117
package com.appunite.websocket.rx.object;
218

19+
/**
20+
* Exception throw by {@link ObjectSerializer} if serialization or deserialization fail
21+
*/
322
public class ObjectParseException extends Exception {
423

24+
/**
25+
* {@inheritDoc}
26+
*/
527
public ObjectParseException() {
628
}
729

30+
/**
31+
* {@inheritDoc}
32+
*/
833
public ObjectParseException(String message) {
934
super(message);
1035
}
1136

37+
/**
38+
* {@inheritDoc}
39+
*/
1240
public ObjectParseException(String message, Throwable cause) {
1341
super(message, cause);
1442
}
@@ -17,6 +45,9 @@ public ObjectParseException(Throwable cause) {
1745
super(cause);
1846
}
1947

48+
/**
49+
* {@inheritDoc}
50+
*/
2051
public ObjectParseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
2152
super(message, cause, enableSuppression, writableStackTrace);
2253
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,65 @@
1+
/*
2+
* Copyright (C) 2015 Jacek Marchwicki <jacek.marchwicki@gmail.com>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License
15+
*/
16+
117
package com.appunite.websocket.rx.object;
218

319
import javax.annotation.Nonnull;
420

21+
/**
22+
* Serialize and deserialize objects from web socket
23+
*/
524
public interface ObjectSerializer {
25+
26+
/**
27+
* Serialize string message
28+
* @param message string message from socket
29+
* @return serialized object
30+
* @throws ObjectParseException if serialization fail
31+
*/
632
@Nonnull Object serialize(@Nonnull String message) throws ObjectParseException;
733

34+
/**
35+
* Serialize binary message
36+
* @param message binary message from socket
37+
* @return serialized object
38+
* @throws ObjectParseException if serialization fail
39+
*/
840
@Nonnull Object serialize(@Nonnull byte[] message) throws ObjectParseException;
941

42+
/**
43+
* Deserialize to binary message (is called only if {@link #isBinary(Object)} return true)
44+
* @param message object to deserialize
45+
* @return de-serialized object
46+
* @throws ObjectParseException if serialization fail
47+
*/
1048
@Nonnull byte[] deserializeBinary(@Nonnull Object message) throws ObjectParseException;
1149

50+
/**
51+
* Deserialize to string message (is called only if {@link #isBinary(Object)} return false)
52+
* @param message object to deserialize
53+
* @return de-serialized object
54+
* @throws ObjectParseException if serialization fail
55+
*/
1256
@Nonnull String deserializeString(@Nonnull Object message) throws ObjectParseException;
1357

58+
/**
59+
* Determine if message should be serialized to binary
60+
* @param message object to deserialize
61+
* @return true if should use binary serialize {@link #deserializeBinary(Object)}, false if
62+
* should use string serialize {@link #deserializeString(Object)}
63+
*/
1464
boolean isBinary(@Nonnull Object message);
1565
}

0 commit comments

Comments
 (0)