diff options
| author | frsyuki <frsyuki@users.sourceforge.jp> | 2010-09-27 03:05:32 +0900 |
|---|---|---|
| committer | frsyuki <frsyuki@users.sourceforge.jp> | 2010-09-27 03:05:32 +0900 |
| commit | 446a7fbd679fffd6b2b5e3c8b5673ed824aa133f (patch) | |
| tree | 53ae324bb14a8b5dca597e67f9b8fd016e5d4684 /java | |
| parent | 7974060a4010c91f978fe91e74b0e1967dc30a90 (diff) | |
| download | msgpack-python-446a7fbd679fffd6b2b5e3c8b5673ed824aa133f.tar.gz | |
java: adds CustomMessage class (currently not implemented on Packer, Unpacker and ClassTemplate)
Diffstat (limited to 'java')
| -rw-r--r-- | java/src/main/java/org/msgpack/CustomConverter.java | 39 | ||||
| -rw-r--r-- | java/src/main/java/org/msgpack/CustomMessage.java | 30 | ||||
| -rw-r--r-- | java/src/main/java/org/msgpack/CustomPacker.java | 39 | ||||
| -rw-r--r-- | java/src/main/java/org/msgpack/CustomUnpacker.java | 39 |
4 files changed, 147 insertions, 0 deletions
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 0000000..5905419 --- /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<Class, MessageConverter> map = new HashMap<Class, MessageConverter>(); +} + 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 0000000..f87898c --- /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 0000000..f828c31 --- /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<Class, MessagePacker> map = new HashMap<Class, MessagePacker>(); +} + 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 0000000..255368d --- /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<Class, MessageUnpacker> map = new HashMap<Class, MessageUnpacker>(); +} + |
