java: adds CustomMessage class (currently not implemented on Packer, Unpacker and ClassTemplate)

This commit is contained in:
frsyuki 2010-09-27 03:05:32 +09:00
parent 7974060a40
commit 446a7fbd67
4 changed files with 147 additions and 0 deletions

View 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>();
}

View 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);
}
}

View 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>();
}

View 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>();
}