mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 18:29:53 +00:00
java: adds type-conversion mechanisms
This commit is contained in:
parent
446a7fbd67
commit
391034a785
14 changed files with 427 additions and 2 deletions
44
java/src/main/java/org/msgpack/template/StringTemplate.java
Normal file
44
java/src/main/java/org/msgpack/template/StringTemplate.java
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// 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.template;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.msgpack.*;
|
||||
|
||||
public class StringTemplate implements Template {
|
||||
private StringTemplate() { }
|
||||
|
||||
public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
|
||||
return pac.unpackString();
|
||||
}
|
||||
|
||||
public Object convert(MessagePackObject from) throws MessageTypeException {
|
||||
return from.asString();
|
||||
}
|
||||
|
||||
static public StringTemplate getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
static final StringTemplate instance = new StringTemplate();
|
||||
|
||||
static {
|
||||
CustomMessage.registerTemplate(String.class, instance);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue