summaryrefslogtreecommitdiff
path: root/java/src/main
diff options
context:
space:
mode:
authorfrsyuki <frsyuki@users.sourceforge.jp>2010-09-27 04:27:44 +0900
committerfrsyuki <frsyuki@users.sourceforge.jp>2010-09-27 04:27:44 +0900
commit0a41b253f3a688cbdd11c2cfcb574f1333b32a0e (patch)
treef46a08d0cce9aa57506379288e99f1fbee9152c8 /java/src/main
parent002b86198c2a4db8aa6372f12fdaa055b9157e89 (diff)
downloadmsgpack-python-0a41b253f3a688cbdd11c2cfcb574f1333b32a0e.tar.gz
java: adds templates for primitive types
Diffstat (limited to 'java/src/main')
-rw-r--r--java/src/main/java/org/msgpack/Templates.java43
-rw-r--r--java/src/main/java/org/msgpack/template/BigIntegerTemplate.java45
-rw-r--r--java/src/main/java/org/msgpack/template/BooleanTemplate.java44
-rw-r--r--java/src/main/java/org/msgpack/template/ByteTemplate.java44
-rw-r--r--java/src/main/java/org/msgpack/template/DoubleTemplate.java44
-rw-r--r--java/src/main/java/org/msgpack/template/FloatTemplate.java44
-rw-r--r--java/src/main/java/org/msgpack/template/IntegerTemplate.java44
-rw-r--r--java/src/main/java/org/msgpack/template/LongTemplate.java44
-rw-r--r--java/src/main/java/org/msgpack/template/ShortTemplate.java44
9 files changed, 393 insertions, 3 deletions
diff --git a/java/src/main/java/org/msgpack/Templates.java b/java/src/main/java/org/msgpack/Templates.java
index a31dd91..222f625 100644
--- a/java/src/main/java/org/msgpack/Templates.java
+++ b/java/src/main/java/org/msgpack/Templates.java
@@ -33,15 +33,52 @@ public class Templates {
}
- public static final Template TString = StringTemplate.getInstance();
+ public static final Template TByte = ByteTemplate.getInstance();
+ public static Template tByte() {
+ return TByte;
+ }
+
+ public static final Template TShort = ShortTemplate.getInstance();
+ public static Template tShort() {
+ return TShort;
+ }
+
+ public static final Template TInteger = IntegerTemplate.getInstance();
+ public static Template tInteger() {
+ return TInteger;
+ }
+
+ public static final Template TLong = LongTemplate.getInstance();
+ public static Template tLong() {
+ return TLong;
+ }
+
+ public static final Template TBigInteger = BigIntegerTemplate.getInstance();
+ public static Template tBigInteger() {
+ return TBigInteger;
+ }
+ public static final Template TFloat = FloatTemplate.getInstance();
+ public static Template tFloat() {
+ return TFloat;
+ }
+
+ public static final Template TDouble = DoubleTemplate.getInstance();
+ public static Template tDouble() {
+ return TDouble;
+ }
+
+ public static final Template TBoolean = BooleanTemplate.getInstance();
+ public static Template tBoolean() {
+ return TBoolean;
+ }
+
+ public static final Template TString = StringTemplate.getInstance();
public static Template tString() {
return TString;
}
-
public static final Template TByteArray = ByteArrayTemplate.getInstance();
-
public static Template tByteArray() {
return TByteArray;
}
diff --git a/java/src/main/java/org/msgpack/template/BigIntegerTemplate.java b/java/src/main/java/org/msgpack/template/BigIntegerTemplate.java
new file mode 100644
index 0000000..e8a2993
--- /dev/null
+++ b/java/src/main/java/org/msgpack/template/BigIntegerTemplate.java
@@ -0,0 +1,45 @@
+//
+// 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 java.math.BigInteger;
+import org.msgpack.*;
+
+public class BigIntegerTemplate implements Template {
+ private BigIntegerTemplate() { }
+
+ public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
+ return pac.unpackBigInteger();
+ }
+
+ public Object convert(MessagePackObject from) throws MessageTypeException {
+ return from.asBigInteger();
+ }
+
+ static public BigIntegerTemplate getInstance() {
+ return instance;
+ }
+
+ static final BigIntegerTemplate instance = new BigIntegerTemplate();
+
+ static {
+ CustomMessage.registerTemplate(BigInteger.class, instance);
+ }
+}
+
diff --git a/java/src/main/java/org/msgpack/template/BooleanTemplate.java b/java/src/main/java/org/msgpack/template/BooleanTemplate.java
new file mode 100644
index 0000000..0d64ecc
--- /dev/null
+++ b/java/src/main/java/org/msgpack/template/BooleanTemplate.java
@@ -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 BooleanTemplate implements Template {
+ private BooleanTemplate() { }
+
+ public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
+ return pac.unpackBoolean();
+ }
+
+ public Object convert(MessagePackObject from) throws MessageTypeException {
+ return from.asBoolean();
+ }
+
+ static public BooleanTemplate getInstance() {
+ return instance;
+ }
+
+ static final BooleanTemplate instance = new BooleanTemplate();
+
+ static {
+ CustomMessage.registerTemplate(Boolean.class, instance);
+ }
+}
+
diff --git a/java/src/main/java/org/msgpack/template/ByteTemplate.java b/java/src/main/java/org/msgpack/template/ByteTemplate.java
new file mode 100644
index 0000000..8d0e6e6
--- /dev/null
+++ b/java/src/main/java/org/msgpack/template/ByteTemplate.java
@@ -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 ByteTemplate implements Template {
+ private ByteTemplate() { }
+
+ public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
+ return pac.unpackByte();
+ }
+
+ public Object convert(MessagePackObject from) throws MessageTypeException {
+ return from.asByte();
+ }
+
+ static public ByteTemplate getInstance() {
+ return instance;
+ }
+
+ static final ByteTemplate instance = new ByteTemplate();
+
+ static {
+ CustomMessage.registerTemplate(Byte.class, instance);
+ }
+}
+
diff --git a/java/src/main/java/org/msgpack/template/DoubleTemplate.java b/java/src/main/java/org/msgpack/template/DoubleTemplate.java
new file mode 100644
index 0000000..2e26f50
--- /dev/null
+++ b/java/src/main/java/org/msgpack/template/DoubleTemplate.java
@@ -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 DoubleTemplate implements Template {
+ private DoubleTemplate() { }
+
+ public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
+ return pac.unpackDouble();
+ }
+
+ public Object convert(MessagePackObject from) throws MessageTypeException {
+ return from.asDouble();
+ }
+
+ static public DoubleTemplate getInstance() {
+ return instance;
+ }
+
+ static final DoubleTemplate instance = new DoubleTemplate();
+
+ static {
+ CustomMessage.registerTemplate(Double.class, instance);
+ }
+}
+
diff --git a/java/src/main/java/org/msgpack/template/FloatTemplate.java b/java/src/main/java/org/msgpack/template/FloatTemplate.java
new file mode 100644
index 0000000..8730172
--- /dev/null
+++ b/java/src/main/java/org/msgpack/template/FloatTemplate.java
@@ -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 FloatTemplate implements Template {
+ private FloatTemplate() { }
+
+ public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
+ return pac.unpackFloat();
+ }
+
+ public Object convert(MessagePackObject from) throws MessageTypeException {
+ return from.asFloat();
+ }
+
+ static public FloatTemplate getInstance() {
+ return instance;
+ }
+
+ static final FloatTemplate instance = new FloatTemplate();
+
+ static {
+ CustomMessage.registerTemplate(Float.class, instance);
+ }
+}
+
diff --git a/java/src/main/java/org/msgpack/template/IntegerTemplate.java b/java/src/main/java/org/msgpack/template/IntegerTemplate.java
new file mode 100644
index 0000000..c56c044
--- /dev/null
+++ b/java/src/main/java/org/msgpack/template/IntegerTemplate.java
@@ -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 IntegerTemplate implements Template {
+ private IntegerTemplate() { }
+
+ public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
+ return pac.unpackInt();
+ }
+
+ public Object convert(MessagePackObject from) throws MessageTypeException {
+ return from.asInt();
+ }
+
+ static public IntegerTemplate getInstance() {
+ return instance;
+ }
+
+ static final IntegerTemplate instance = new IntegerTemplate();
+
+ static {
+ CustomMessage.registerTemplate(Integer.class, instance);
+ }
+}
+
diff --git a/java/src/main/java/org/msgpack/template/LongTemplate.java b/java/src/main/java/org/msgpack/template/LongTemplate.java
new file mode 100644
index 0000000..a0c8210
--- /dev/null
+++ b/java/src/main/java/org/msgpack/template/LongTemplate.java
@@ -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 LongTemplate implements Template {
+ private LongTemplate() { }
+
+ public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
+ return pac.unpackLong();
+ }
+
+ public Object convert(MessagePackObject from) throws MessageTypeException {
+ return from.asLong();
+ }
+
+ static public LongTemplate getInstance() {
+ return instance;
+ }
+
+ static final LongTemplate instance = new LongTemplate();
+
+ static {
+ CustomMessage.registerTemplate(Long.class, instance);
+ }
+}
+
diff --git a/java/src/main/java/org/msgpack/template/ShortTemplate.java b/java/src/main/java/org/msgpack/template/ShortTemplate.java
new file mode 100644
index 0000000..b3bf43b
--- /dev/null
+++ b/java/src/main/java/org/msgpack/template/ShortTemplate.java
@@ -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 ShortTemplate implements Template {
+ private ShortTemplate() { }
+
+ public Object unpack(Unpacker pac) throws IOException, MessageTypeException {
+ return pac.unpackShort();
+ }
+
+ public Object convert(MessagePackObject from) throws MessageTypeException {
+ return from.asShort();
+ }
+
+ static public ShortTemplate getInstance() {
+ return instance;
+ }
+
+ static final ShortTemplate instance = new ShortTemplate();
+
+ static {
+ CustomMessage.registerTemplate(Short.class, instance);
+ }
+}
+