-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding
StringSerDe
helper class for NiFi utils package.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
nifi-sumo-common/src/main/java/com/crossbusiness/nifi/processors/StringSerDe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.crossbusiness.nifi.processors; | ||
|
||
import org.apache.nifi.distributed.cache.client.Deserializer; | ||
import org.apache.nifi.distributed.cache.client.Serializer; | ||
import org.apache.nifi.distributed.cache.client.exception.DeserializationException; | ||
import org.apache.nifi.distributed.cache.client.exception.SerializationException; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class StringSerDe implements Serializer<String>, Deserializer<String> { | ||
|
||
@Override | ||
public String deserialize(final byte[] value) throws DeserializationException, IOException { | ||
if (value == null) { | ||
return null; | ||
} | ||
|
||
return new String(value, StandardCharsets.UTF_8); | ||
} | ||
|
||
@Override | ||
public void serialize(final String value, final OutputStream out) throws SerializationException, IOException { | ||
out.write(value.getBytes(StandardCharsets.UTF_8)); | ||
} | ||
|
||
} |