mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-24 17:30:46 +02:00
java: adds CustomMessage class (currently not implemented on Packer, Unpacker and ClassTemplate)
This commit is contained in:
39
java/src/main/java/org/msgpack/CustomConverter.java
Normal file
39
java/src/main/java/org/msgpack/CustomConverter.java
Normal file
@@ -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>();
|
||||||
|
}
|
||||||
|
|
||||||
30
java/src/main/java/org/msgpack/CustomMessage.java
Normal file
30
java/src/main/java/org/msgpack/CustomMessage.java
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
39
java/src/main/java/org/msgpack/CustomPacker.java
Normal file
39
java/src/main/java/org/msgpack/CustomPacker.java
Normal file
@@ -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>();
|
||||||
|
}
|
||||||
|
|
||||||
39
java/src/main/java/org/msgpack/CustomUnpacker.java
Normal file
39
java/src/main/java/org/msgpack/CustomUnpacker.java
Normal file
@@ -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>();
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user