Skip to content

Commit a39ad12

Browse files
committed
Merge branch 'master' of github.com:msgpack/msgpack-java
2 parents 9f85721 + 8fa7315 commit a39ad12

40 files changed

Lines changed: 1005 additions & 52 deletions

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>junit</groupId>
2828
<artifactId>junit</artifactId>
29-
<version>4.8.1</version>
29+
<version>4.8.2</version>
3030
<scope>test</scope>
3131
</dependency>
3232
<dependency>

src/main/java/org/msgpack/MessagePack.java

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,31 @@ public MessagePack(MessagePack parent) {
4343
registry = new TemplateRegistry(parent.registry);
4444
}
4545

46+
public byte[] pack(Object v) throws IOException {
47+
return pack(v, getTemplate(v.getClass()));
48+
}
49+
50+
public byte[] pack(Object v, Template tmpl) throws IOException { // TODO IOException
51+
BufferPacker pk = new BufferPacker();
52+
tmpl.write(pk, v);
53+
return pk.toByteArray();
54+
}
55+
56+
public void pack(OutputStream out, Object v) throws IOException {
57+
pack(out, v, getTemplate(v.getClass()));
58+
}
59+
60+
public void pack(OutputStream out, Object v, Template tmpl) throws IOException {
61+
tmpl.write(new StreamPacker(out), v);
62+
}
63+
64+
public byte[] pack(Value v) throws IOException { // TODO IOException
65+
// FIXME ValueTemplate should do this
66+
BufferPacker pk = new BufferPacker();
67+
pk.write(v);
68+
return pk.toByteArray();
69+
}
70+
4671
public <T> T unpack(InputStream in, T v) throws IOException {
4772
// TODO
4873
Template tmpl = getTemplate(v.getClass());
@@ -55,6 +80,18 @@ public <T> T unpack(InputStream in, Class<T> c) throws IOException {
5580
return (T)tmpl.read(new StreamUnpacker(in), null);
5681
}
5782

83+
public Value unpack(byte[] b) throws IOException { // TODO IOException
84+
return unpack(b, 0, b.length);
85+
}
86+
87+
public Value unpack(byte[] b, int off, int len) throws IOException { // TODO IOException
88+
return new BufferUnpacker().wrap(b, off, len).readValue();
89+
}
90+
91+
public Value unpack(ByteBuffer buf) throws IOException { // TODO IOException
92+
return new BufferUnpacker().wrap(buf).readValue();
93+
}
94+
5895
public <T> T unpack(byte[] b, T v) throws IOException { // TODO IOException
5996
// TODO
6097
Template tmpl = getTemplate(v.getClass());
@@ -87,37 +124,6 @@ public <T> T unpack(ByteBuffer b, Class<T> c) { // TODO IOException
87124
return null;
88125
}
89126

90-
public Value unpack(byte[] b) throws IOException { // TODO IOException
91-
return unpack(b, 0, b.length);
92-
}
93-
94-
public Value unpack(byte[] b, int off, int len) throws IOException { // TODO IOException
95-
return new BufferUnpacker().wrap(b, off, len).readValue();
96-
}
97-
98-
public Value unpack(ByteBuffer buf) throws IOException { // TODO IOException
99-
return new BufferUnpacker().wrap(buf).readValue();
100-
}
101-
102-
public void pack(OutputStream out, Object v) throws IOException {
103-
Template tmpl = getTemplate(v.getClass());
104-
tmpl.write(new StreamPacker(out), v);
105-
}
106-
107-
public byte[] pack(Value v) throws IOException { // TODO IOException
108-
// FIXME ValueTemplate should do this
109-
BufferPacker pk = new BufferPacker();
110-
pk.write(v);
111-
return pk.toByteArray();
112-
}
113-
114-
public byte[] pack(Object v) throws IOException { // TODO IOException
115-
Template tmpl = getTemplate(v.getClass());
116-
BufferPacker pk = new BufferPacker();
117-
tmpl.write(pk, v);
118-
return pk.toByteArray();
119-
}
120-
121127
protected Template getTemplate(Class<?> c) {
122128
Template tmpl = registry.lookup(c);
123129
if(tmpl == null) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Copyright (C) 2009-2011 FURUHASHI Sadayuki
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
package org.msgpack.annotation;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
import org.msgpack.template.FieldOption;
25+
26+
27+
@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME)
28+
public @interface Beans {
29+
FieldOption value() default FieldOption.DEFAULT;
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Copyright (C) 2009-2011 FURUHASHI Sadayuki
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
package org.msgpack.annotation;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
26+
@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME)
27+
public @interface Delegate {
28+
String value();
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Copyright (C) 2009-2011 FURUHASHI Sadayuki
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
package org.msgpack.annotation;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
26+
@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
27+
@Retention(RetentionPolicy.RUNTIME)
28+
public @interface Ignore {
29+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Copyright (C) 2009-2011 FURUHASHI Sadayuki
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
package org.msgpack.annotation;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
26+
@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
27+
@Retention(RetentionPolicy.RUNTIME)
28+
public @interface Index {
29+
int value();
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Copyright (C) 2009-2011 FURUHASHI Sadayuki
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
package org.msgpack.annotation;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
import org.msgpack.template.FieldOption;
25+
26+
27+
@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME)
28+
public @interface Message {
29+
FieldOption value() default FieldOption.DEFAULT;
30+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Copyright (C) 2009-2011 FURUHASHI Sadayuki
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
package org.msgpack.annotation;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
import org.msgpack.template.FieldOption;
25+
26+
27+
/**
28+
* Annotation for java beans class
29+
* @author takeshita
30+
*
31+
*/
32+
@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME)
33+
public @interface MessagePackBeans {
34+
FieldOption value() default FieldOption.DEFAULT;
35+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Copyright (C) 2009-2011 FURUHASHI Sadayuki
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
package org.msgpack.annotation;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
26+
@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME)
27+
public @interface MessagePackDelegate {
28+
String value();
29+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Copyright (C) 2009-2011 FURUHASHI Sadayuki
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
package org.msgpack.annotation;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
import org.msgpack.template.FieldOption;
25+
26+
27+
@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME)
28+
public @interface MessagePackMessage {
29+
FieldOption value() default FieldOption.DEFAULT;
30+
}

0 commit comments

Comments
 (0)