Skip to content

Commit 4582ad3

Browse files
committed
Merge v08-buffer-api
2 parents 6b04287 + 31e1efa commit 4582ad3

37 files changed

+1365
-1349
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
package org.msgpack.core;
17+
18+
import org.msgpack.core.buffer.ArrayBufferOutput;
19+
import org.msgpack.core.buffer.MessageBuffer;
20+
import org.msgpack.core.buffer.MessageBufferOutput;
21+
22+
import java.io.IOException;
23+
import java.util.List;
24+
25+
/**
26+
* MessagePacker that is useful to produce byte array output
27+
*/
28+
public class MessageBufferPacker
29+
extends MessagePacker
30+
{
31+
public MessageBufferPacker(MessagePack.PackerConfig config)
32+
{
33+
this(new ArrayBufferOutput(), config);
34+
}
35+
36+
public MessageBufferPacker(ArrayBufferOutput out, MessagePack.PackerConfig config)
37+
{
38+
super(out, config);
39+
}
40+
41+
public MessageBufferOutput reset(MessageBufferOutput out)
42+
throws IOException
43+
{
44+
if (!(out instanceof ArrayBufferOutput)) {
45+
throw new IllegalArgumentException("MessageBufferPacker accepts only ArrayBufferOutput");
46+
}
47+
return super.reset(out);
48+
}
49+
50+
private ArrayBufferOutput getArrayBufferOut()
51+
{
52+
return (ArrayBufferOutput) out;
53+
}
54+
55+
public void clear()
56+
{
57+
getArrayBufferOut().clear();
58+
}
59+
60+
public byte[] toByteArray()
61+
{
62+
return getArrayBufferOut().toByteArray();
63+
}
64+
65+
public MessageBuffer toMessageBuffer()
66+
{
67+
return getArrayBufferOut().toMessageBuffer();
68+
}
69+
70+
public List<MessageBuffer> toBufferList()
71+
{
72+
return getArrayBufferOut().toBufferList();
73+
}
74+
}

msgpack-core/src/main/java/org/msgpack/core/MessageFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
//
1616
package org.msgpack.core;
1717

18-
import org.msgpack.core.MessagePack.Code;
1918
import org.msgpack.core.annotations.VisibleForTesting;
2019
import org.msgpack.value.ValueType;
20+
import org.msgpack.core.MessagePack.Code;
2121

2222
/**
2323
* Describes the list of the message format types defined in the MessagePack specification.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
package org.msgpack.core;
17+
18+
public class MessageInsufficientBufferException
19+
extends MessagePackException
20+
{
21+
public MessageInsufficientBufferException()
22+
{
23+
super();
24+
}
25+
26+
public MessageInsufficientBufferException(String message)
27+
{
28+
super(message);
29+
}
30+
31+
public MessageInsufficientBufferException(Throwable cause)
32+
{
33+
super(cause);
34+
}
35+
36+
public MessageInsufficientBufferException(String message, Throwable cause)
37+
{
38+
super(message, cause);
39+
}
40+
}

msgpack-core/src/main/java/org/msgpack/core/annotations/Insecure.java renamed to msgpack-core/src/main/java/org/msgpack/core/MessageNeverUsedFormatException.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,26 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515
//
16-
package org.msgpack.core.annotations;
16+
package org.msgpack.core;
1717

1818
/**
19-
* Annotates a code which must be used carefully.
19+
* Thrown when the input message pack format is invalid
2020
*/
21-
public @interface Insecure
21+
public class MessageNeverUsedFormatException
22+
extends MessageFormatException
2223
{
24+
public MessageNeverUsedFormatException(Throwable e)
25+
{
26+
super(e);
27+
}
28+
29+
public MessageNeverUsedFormatException(String message)
30+
{
31+
super(message);
32+
}
33+
34+
public MessageNeverUsedFormatException(String message, Throwable cause)
35+
{
36+
super(message, cause);
37+
}
2338
}

0 commit comments

Comments
 (0)