From 446a7fbd679fffd6b2b5e3c8b5673ed824aa133f Mon Sep 17 00:00:00 2001 From: frsyuki Date: Mon, 27 Sep 2010 03:05:32 +0900 Subject: [PATCH] java: adds CustomMessage class (currently not implemented on Packer, Unpacker and ClassTemplate) --- .../java/org/msgpack/CustomConverter.java | 39 +++++++++++++++++++ .../main/java/org/msgpack/CustomMessage.java | 30 ++++++++++++++ .../main/java/org/msgpack/CustomPacker.java | 39 +++++++++++++++++++ .../main/java/org/msgpack/CustomUnpacker.java | 39 +++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 java/src/main/java/org/msgpack/CustomConverter.java create mode 100644 java/src/main/java/org/msgpack/CustomMessage.java create mode 100644 java/src/main/java/org/msgpack/CustomPacker.java create mode 100644 java/src/main/java/org/msgpack/CustomUnpacker.java diff --git a/java/src/main/java/org/msgpack/CustomConverter.java b/java/src/main/java/org/msgpack/CustomConverter.java new file mode 100644 index 00000000..59054196 --- /dev/null +++ b/java/src/main/java/org/msgpack/CustomConverter.java @@ -0,0 +1,39 @@ +// +// MessagePack for Java +// +// Copyright (C) 2009-2010 FURUHASHI Sadayuki +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +package org.msgpack; + +import java.util.Map; +import java.util.HashMap; + +// FIXME public? +class CustomConverter { + public static void register(Class target, MessageConverter converter) { + map.put(target, converter); + } + + public static MessageConverter get(Class target) { + return map.get(target); + } + + public static boolean isRegistered(Class target) { + return map.containsKey(target); + } + + private static Map map = new HashMap(); +} + diff --git a/java/src/main/java/org/msgpack/CustomMessage.java b/java/src/main/java/org/msgpack/CustomMessage.java new file mode 100644 index 00000000..f87898cd --- /dev/null +++ b/java/src/main/java/org/msgpack/CustomMessage.java @@ -0,0 +1,30 @@ +// +// MessagePack for Java +// +// Copyright (C) 2009-2010 FURUHASHI Sadayuki +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +package org.msgpack; + +public class CustomMessage { + public static void registerPacker(Class target, MessagePacker packer) { + CustomPacker.register(target, packer); + } + + public static void registerTemplate(Class target, Template tmpl) { + CustomUnpacker.register(target, tmpl); + CustomConverter.register(target, tmpl); + } +} + diff --git a/java/src/main/java/org/msgpack/CustomPacker.java b/java/src/main/java/org/msgpack/CustomPacker.java new file mode 100644 index 00000000..f828c310 --- /dev/null +++ b/java/src/main/java/org/msgpack/CustomPacker.java @@ -0,0 +1,39 @@ +// +// MessagePack for Java +// +// Copyright (C) 2009-2010 FURUHASHI Sadayuki +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +package org.msgpack; + +import java.util.Map; +import java.util.HashMap; + +// FIXME public? +class CustomPacker { + public static void register(Class target, MessagePacker converter) { + map.put(target, converter); + } + + public static MessagePacker get(Class target) { + return map.get(target); + } + + public static boolean isRegistered(Class target) { + return map.containsKey(target); + } + + private static Map map = new HashMap(); +} + diff --git a/java/src/main/java/org/msgpack/CustomUnpacker.java b/java/src/main/java/org/msgpack/CustomUnpacker.java new file mode 100644 index 00000000..255368da --- /dev/null +++ b/java/src/main/java/org/msgpack/CustomUnpacker.java @@ -0,0 +1,39 @@ +// +// MessagePack for Java +// +// Copyright (C) 2009-2010 FURUHASHI Sadayuki +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +package org.msgpack; + +import java.util.Map; +import java.util.HashMap; + +// FIXME public? +class CustomUnpacker { + public static void register(Class target, MessageUnpacker converter) { + map.put(target, converter); + } + + public static MessageUnpacker get(Class target) { + return map.get(target); + } + + public static boolean isRegistered(Class target) { + return map.containsKey(target); + } + + private static Map map = new HashMap(); +} +