Package net.webpdf.wsclient.tools
Class SerializeHelper
- java.lang.Object
-
- net.webpdf.wsclient.tools.SerializeHelper
-
public class SerializeHelper extends Object
TheSerializeHelperprovides a set of tools, to translate the server“s responses and data transfer objects, which may be provided using one of the definedDataFormats.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TfromJSON(@Nullable StreamSource streamSource, @NotNull Class<T> type)Deserialize the data transfer object to the given type from the givenDataFormat.JSONStreamSource.static <T> TfromJSON(@Nullable org.apache.hc.core5.http.HttpEntity httpEntity, @NotNull Class<T> type)Deserialize the data transfer object to the given type from the givenDataFormat.JSONHttpEntity.static <T> TfromXML(@Nullable StreamSource streamSource, @NotNull Class<T> type)Deserialize the data transfer object to the given type from the givenDataFormat.XMLStreamSource.static <T> TfromXML(@Nullable org.apache.hc.core5.http.HttpEntity httpEntity, @NotNull Class<T> type)Deserialize the data transfer object to the given type from the givenDataFormat.XMLHttpEntity.static @NotNull StringtoJSON(@Nullable Object object)Serialize a data transfer object toDataFormat.JSONstatic @NotNull StringtoXML(@Nullable Object object, @NotNull Class<?> type)Serialize a data transfer object toDataFormat.XML.
-
-
-
Method Detail
-
fromXML
@NotNull public static <T> T fromXML(@Nullable @Nullable org.apache.hc.core5.http.HttpEntity httpEntity, @NotNull @NotNull Class<T> type) throws ResultExceptionDeserialize the data transfer object to the given type from the givenDataFormat.XMLHttpEntity.- Type Parameters:
T- The expected type of the deserialized data transfer object.- Parameters:
httpEntity- The deserializableDataFormat.XMLHttpEntitytype- The expected type of the deserialized data transfer object.- Returns:
- The deserialized
DataFormat.XMLdata transfer object. - Throws:
ResultException- Shall be thrown upon a deserialization failure.
-
fromXML
@NotNull public static <T> T fromXML(@Nullable @Nullable StreamSource streamSource, @NotNull @NotNull Class<T> type) throws ResultExceptionDeserialize the data transfer object to the given type from the givenDataFormat.XMLStreamSource.- Type Parameters:
T- The expected type of the deserialized data transfer object.- Parameters:
streamSource- The deserializableDataFormat.XMLStreamSourcetype- The expected type of the deserialized data transfer object.- Returns:
- The deserialized
DataFormat.XMLdata transfer object. - Throws:
ResultException- Shall be thrown upon a deserialization failure.
-
fromJSON
@NotNull public static <T> T fromJSON(@Nullable @Nullable org.apache.hc.core5.http.HttpEntity httpEntity, @NotNull @NotNull Class<T> type) throws ResultExceptionDeserialize the data transfer object to the given type from the givenDataFormat.JSONHttpEntity.- Type Parameters:
T- The expected type of the deserialized data transfer object.- Parameters:
httpEntity- The deserializableDataFormat.JSONHttpEntitytype- The expected type of the deserialized data transfer object.- Returns:
- The deserialized
DataFormat.JSONdata transfer object. - Throws:
ResultException- Shall be thrown upon a deserialization failure.
-
fromJSON
@NotNull public static <T> T fromJSON(@Nullable @Nullable StreamSource streamSource, @NotNull @NotNull Class<T> type) throws ResultExceptionDeserialize the data transfer object to the given type from the givenDataFormat.JSONStreamSource.- Type Parameters:
T- The expected type of the deserialized data transfer object.- Parameters:
streamSource- The deserializableDataFormat.JSONStreamSourcetype- The expected type of the deserialized data transfer object.- Returns:
- The deserialized
DataFormat.JSONdata transfer object. - Throws:
ResultException- Shall be thrown upon a deserialization failure.
-
toJSON
@NotNull public static @NotNull String toJSON(@Nullable @Nullable Object object) throws ResultException
Serialize a data transfer object toDataFormat.JSON- Parameters:
object- The object to serialize.- Returns:
- The resulting
DataFormat.JSONString. - Throws:
ResultException- Shall be thrown upon a serialization failure.
-
toXML
@NotNull public static @NotNull String toXML(@Nullable @Nullable Object object, @NotNull @NotNull Class<?> type) throws ResultException
Serialize a data transfer object toDataFormat.XML.- Parameters:
object- The data transfer object to serialize.type- The annotated type of the data transfer object.- Returns:
- The resulting
DataFormat.XMLString. - Throws:
ResultException- Shall be thrown upon a serialization failure.
-
-