diff options
Diffstat (limited to 'src/org/traccar/ExtendedObjectDecoder.java')
-rw-r--r-- | src/org/traccar/ExtendedObjectDecoder.java | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/org/traccar/ExtendedObjectDecoder.java b/src/org/traccar/ExtendedObjectDecoder.java index 900b7bdbc..329490d29 100644 --- a/src/org/traccar/ExtendedObjectDecoder.java +++ b/src/org/traccar/ExtendedObjectDecoder.java @@ -16,6 +16,7 @@ package org.traccar; import java.net.SocketAddress; +import java.nio.charset.Charset; import java.util.Collection; import org.jboss.netty.buffer.ChannelBuffer; @@ -34,16 +35,13 @@ import javax.xml.bind.DatatypeConverter; public abstract class ExtendedObjectDecoder implements ChannelUpstreamHandler { private void saveOriginal(Object decodedMessage, Object originalMessage) { - if (Context.getConfig().getBoolean("database.saveOriginal")) { - if (decodedMessage instanceof Position) { - Position position = (Position) decodedMessage; - if (originalMessage instanceof ChannelBuffer) { - position.set(Event.KEY_ORIGINAL, - ChannelBuffers.hexDump((ChannelBuffer) originalMessage)); - } else if (originalMessage instanceof String) { - position.set(Event.KEY_ORIGINAL, - DatatypeConverter.printHexBinary(((String) originalMessage).getBytes())); - } + if (Context.getConfig().getBoolean("database.saveOriginal") && decodedMessage instanceof Position) { + Position position = (Position) decodedMessage; + if (originalMessage instanceof ChannelBuffer) { + position.set(Event.KEY_ORIGINAL, ChannelBuffers.hexDump((ChannelBuffer) originalMessage)); + } else if (originalMessage instanceof String) { + position.set(Event.KEY_ORIGINAL, DatatypeConverter.printHexBinary( + ((String) originalMessage).getBytes(Charset.defaultCharset()))); } } } |