mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-22 08:26:35 +01:00
java: @MessagePackMessage(default field option)
This commit is contained in:
parent
2c823f1aaa
commit
d3a02fb2ca
@ -21,6 +21,7 @@ import java.io.OutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import org.msgpack.buffer.VectoredByteBuffer;
|
||||
import org.msgpack.util.codegen.DynamicTemplate;
|
||||
import org.msgpack.util.codegen.DynamicOrdinalEnumTemplate;
|
||||
import org.msgpack.util.codegen.FieldList;
|
||||
|
@ -155,7 +155,7 @@ public abstract class MessagePackObject implements Cloneable, MessagePackable {
|
||||
return convert((Class<T>)to.getClass(), to);
|
||||
}
|
||||
|
||||
private <T> T convert(Class<T> klass, T to) throws MessageTypeException {
|
||||
public <T> T convert(Class<T> klass, T to) throws MessageTypeException {
|
||||
// FIXME nullable?
|
||||
return (T)convert(new NullableTemplate(new ClassTemplate(klass)), to);
|
||||
}
|
||||
|
@ -27,5 +27,9 @@ public class MessageTypeException extends RuntimeException {
|
||||
public MessageTypeException(String s, Throwable t) {
|
||||
super(s, t);
|
||||
}
|
||||
|
||||
public MessageTypeException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,4 +25,5 @@ import java.lang.annotation.Target;
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface MessagePackDelegate {
|
||||
String value();
|
||||
}
|
||||
|
@ -21,8 +21,10 @@ import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import org.msgpack.template.FieldOption;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface MessagePackMessage {
|
||||
FieldOption value() default FieldOption.DEFAULT;
|
||||
}
|
||||
|
@ -143,12 +143,8 @@ public class VectoredByteBuffer implements GatheringByteChannel, ScatteringByteC
|
||||
// optimization: concatenates to the last buffer instead
|
||||
// of adding new reference
|
||||
ByteBuffer dup = vec.get(vec.size()-1);
|
||||
int dpos = dup.position();
|
||||
internalBuffer.put(b, off, len);
|
||||
ByteBuffer dup2 = internalBuffer.duplicate();
|
||||
dup2.position(dpos);
|
||||
dup2.limit(ipos + len);
|
||||
vec.set(vec.size()-1, dup2);
|
||||
dup.limit(ipos + len);
|
||||
return;
|
||||
}
|
||||
internalBuffer.put(b, off, len);
|
||||
|
@ -200,7 +200,7 @@ public class ClassTemplate implements Template {
|
||||
return tmpl.convert(pac.unpackObject(), to);
|
||||
}
|
||||
|
||||
throw new MessageTypeException();
|
||||
throw new MessageTypeException("unknown type: "+klass);
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new MessageTypeException(e.getMessage()); // FIXME
|
||||
|
@ -333,6 +333,8 @@ public class DynamicCodeGenBase implements Constants {
|
||||
return Templates.tString();
|
||||
} else if (c.equals(BigInteger.class)) {
|
||||
return Templates.tBigInteger();
|
||||
} else if (c.equals(byte[].class)) {
|
||||
return Templates.tByteArray();
|
||||
} else if (c.equals(ByteBuffer.class)) {
|
||||
return Templates.tByteBuffer();
|
||||
} else if (CustomConverter.isRegistered(c)) {// FIXME
|
||||
|
Loading…
x
Reference in New Issue
Block a user