Skip to content

Commit 467ddb5

Browse files
committed
update Java version
1 parent 1cb2aae commit 467ddb5

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ project, add the following to the `dependencies` section in your `pom.xml` file:
2525
<dependency>
2626
<groupId>com.upokecenter</groupId>
2727
<artifactId>cbor</artifactId>
28-
<version>4.3.0</version>
28+
<version>4.4.0</version>
2929
</dependency>
3030
```
3131

api/com.upokecenter.cbor.CBORObject.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -4917,12 +4917,12 @@ try { if (ms != null) { ms.close(); } } catch (java.io.IOException ex) {}
49174917
in Java for the Java version) shows how to use a subclassed
49184918
<code>OutputStream</code> together with a <code>ByteArrayOutputStream</code> to
49194919
limit the size of supported JSON serializations of CBOR objects.</p>
4920-
<pre> /* maximum supported JSON size in bytes*/ final int maxSize = 20000; ByteArrayOutputStream ba = new ByteArrayOutputStream(); /* throws UnsupportedOperationException if too big*/ cborObject.WriteJSONTo(new FilterOutputStream(ba) { private int size = 0; public void write(byte[] b, int off, int len) { if (len&gt;(maxSize-size)) { throw new UnsupportedOperationException(); } size+=len; out.write(b, off, len); } public void write(byte b) { if (size &gt;= maxSize) { throw new UnsupportedOperationException(); } size++; out.write(b); } }); byte[] bytes = ba.toByteArray(); </pre> <p>The
4921-
following example (originally written in C# for the.NET version)
4922-
shows how to use a.NET MemoryStream to limit the size of supported
4923-
JSON serializations of CBOR objects. The disadvantage is that the
4924-
extra memory needed to do so can be wasteful, especially if the
4925-
average serialized object is much smaller than the maximum size
4920+
<pre> /* maximum supported JSON size in bytes*/ final int maxSize = 20000; ByteArrayOutputStream ba = new ByteArrayOutputStream(); /* throws UnsupportedOperationException if too big*/ cborObject.WriteJSONTo(new FilterOutputStream(ba) { private int size = 0; public void write(byte[] b, int off, int len) { if (len&gt;(maxSize-size)) { throw new UnsupportedOperationException(); } size+=len; out.write(b, off, len); } public void write(byte b) { if (size &gt;= maxSize) { throw new UnsupportedOperationException(); } size++; out.write(b); } }); byte[] bytes = ba.toByteArray(); </pre>
4921+
<p>The following example (originally written in C# for the.NET
4922+
version) shows how to use a.NET MemoryStream to limit the size of
4923+
supported JSON serializations of CBOR objects. The disadvantage is
4924+
that the extra memory needed to do so can be wasteful, especially if
4925+
the average serialized object is much smaller than the maximum size
49264926
given (for example, if the maximum size is 20000 bytes, but the
49274927
average serialized object has a size of 50 bytes).</p> <pre> byte[] backing = new byte[20000]; /* maximum supported JSON size in bytes*/ byte[] bytes1, bytes2; {
49284928
java.io.ByteArrayOutputStream ms = null;
@@ -5313,11 +5313,11 @@ try { if (ms != null) { ms.close(); } } catch (java.io.IOException ex) {}
53135313
} </pre> <p>The following example (written in Java for
53145314
the Java version) shows how to use a subclassed <code>OutputStream</code>
53155315
together with a <code>ByteArrayOutputStream</code> to limit the size of
5316-
supported CBOR serializations.</p> <pre> /* maximum supported CBOR size in bytes*/ final int maxSize = 20000; ByteArrayOutputStream ba = new ByteArrayOutputStream(); /* throws UnsupportedOperationException if too big*/ cborObject.WriteTo(new FilterOutputStream(ba) { private int size = 0; public void write(byte[] b, int off, int len) { if (len&gt;(maxSize-size)) { throw new UnsupportedOperationException(); } size+=len; out.write(b, off, len); } public void write(byte b) { if (size &gt;= maxSize) { throw new UnsupportedOperationException(); } size++; out.write(b); } }); byte[] bytes = ba.toByteArray(); </pre> <p>The
5317-
following example (originally written in C# for the.NET version)
5318-
shows how to use a.NET MemoryStream to limit the size of supported
5319-
CBOR serializations. The disadvantage is that the extra memory
5320-
needed to do so can be wasteful, especially if the average
5316+
supported CBOR serializations.</p> <pre> /* maximum supported CBOR size in bytes*/ final int maxSize = 20000; ByteArrayOutputStream ba = new ByteArrayOutputStream(); /* throws UnsupportedOperationException if too big*/ cborObject.WriteTo(new FilterOutputStream(ba) { private int size = 0; public void write(byte[] b, int off, int len) { if (len&gt;(maxSize-size)) { throw new UnsupportedOperationException(); } size+=len; out.write(b, off, len); } public void write(byte b) { if (size &gt;= maxSize) { throw new UnsupportedOperationException(); } size++; out.write(b); } }); byte[] bytes = ba.toByteArray(); </pre>
5317+
<p>The following example (originally written in C# for the.NET
5318+
version) shows how to use a.NET MemoryStream to limit the size of
5319+
supported CBOR serializations. The disadvantage is that the extra
5320+
memory needed to do so can be wasteful, especially if the average
53215321
serialized object is much smaller than the maximum size given (for
53225322
example, if the maximum size is 20000 bytes, but the average
53235323
serialized object has a size of 50 bytes).</p> <pre> byte[] backing = new byte[20000]; /* maximum supported CBOR size in bytes*/ byte[] bytes1, bytes2; {

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.upokecenter</groupId>
55
<artifactId>cbor</artifactId>
66
<packaging>jar</packaging>
7-
<version>4.4.0-SNAPSHOT</version>
7+
<version>4.4.0</version>
88
<name>CBOR (Concise Binary Object Representation)</name>
99
<description>A Java implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 8949.</description>
1010
<url>https://github.com/peteroupc/CBOR-Java</url>

src/main/java/com/upokecenter/cbor/CBORObject.java

+11-12
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,6 @@ public long CalcEncodedSize() {
19041904
return this.CalcEncodedSize(0);
19051905
}
19061906

1907-
// TODO: Use CBOREncodeOptions in CalcEncodedSize
19081907
private long CalcEncodedSize(int depth) {
19091908
if (depth > 1000) {
19101909
throw new CBORException("Too deeply nested");
@@ -5902,12 +5901,12 @@ public CBORObject UntagOne() {
59025901
* in Java for the Java version) shows how to use a subclassed
59035902
* <code>OutputStream</code> together with a <code>ByteArrayOutputStream</code> to
59045903
* limit the size of supported JSON serializations of CBOR objects.</p>
5905-
* <pre> &#x2f;&#x2a; maximum supported JSON size in bytes&#x2a;&#x2f; final int maxSize = 20000; ByteArrayOutputStream ba = new ByteArrayOutputStream(); &#x2f;&#x2a; throws UnsupportedOperationException if too big&#x2a;&#x2f; cborObject.WriteJSONTo(new FilterOutputStream(ba) { private int size = 0; public void write(byte[] b, int off, int len) { if (len>(maxSize-size)) { throw new UnsupportedOperationException(); } size+=len; out.write(b, off, len); } public void write(byte b) { if (size >= maxSize) { throw new UnsupportedOperationException(); } size++; out.write(b); } }); byte[] bytes = ba.toByteArray(); </pre> <p>The
5906-
* following example (originally written in C# for the.NET version)
5907-
* shows how to use a.NET MemoryStream to limit the size of supported
5908-
* JSON serializations of CBOR objects. The disadvantage is that the
5909-
* extra memory needed to do so can be wasteful, especially if the
5910-
* average serialized object is much smaller than the maximum size
5904+
* <pre> &#x2f;&#x2a; maximum supported JSON size in bytes&#x2a;&#x2f; final int maxSize = 20000; ByteArrayOutputStream ba = new ByteArrayOutputStream(); &#x2f;&#x2a; throws UnsupportedOperationException if too big&#x2a;&#x2f; cborObject.WriteJSONTo(new FilterOutputStream(ba) { private int size = 0; public void write(byte[] b, int off, int len) { if (len&gt;(maxSize-size)) { throw new UnsupportedOperationException(); } size+=len; out.write(b, off, len); } public void write(byte b) { if (size &gt;= maxSize) { throw new UnsupportedOperationException(); } size++; out.write(b); } }); byte[] bytes = ba.toByteArray(); </pre>
5905+
* <p>The following example (originally written in C# for the.NET
5906+
* version) shows how to use a.NET MemoryStream to limit the size of
5907+
* supported JSON serializations of CBOR objects. The disadvantage is
5908+
* that the extra memory needed to do so can be wasteful, especially if
5909+
* the average serialized object is much smaller than the maximum size
59115910
* given (for example, if the maximum size is 20000 bytes, but the
59125911
* average serialized object has a size of 50 bytes).</p> <pre> byte[] backing = new byte[20000]; &#x2f;&#x2a; maximum supported JSON size in bytes&#x2a;&#x2f; byte[] bytes1, bytes2; {
59135912
java.io.ByteArrayOutputStream ms = null;
@@ -6466,11 +6465,11 @@ public static int WriteValue(
64666465
} </pre> <p>The following example (written in Java for
64676466
* the Java version) shows how to use a subclassed <code>OutputStream</code>
64686467
* together with a <code>ByteArrayOutputStream</code> to limit the size of
6469-
* supported CBOR serializations.</p> <pre> &#x2f;&#x2a; maximum supported CBOR size in bytes&#x2a;&#x2f; final int maxSize = 20000; ByteArrayOutputStream ba = new ByteArrayOutputStream(); &#x2f;&#x2a; throws UnsupportedOperationException if too big&#x2a;&#x2f; cborObject.WriteTo(new FilterOutputStream(ba) { private int size = 0; public void write(byte[] b, int off, int len) { if (len>(maxSize-size)) { throw new UnsupportedOperationException(); } size+=len; out.write(b, off, len); } public void write(byte b) { if (size >= maxSize) { throw new UnsupportedOperationException(); } size++; out.write(b); } }); byte[] bytes = ba.toByteArray(); </pre> <p>The
6470-
* following example (originally written in C# for the.NET version)
6471-
* shows how to use a.NET MemoryStream to limit the size of supported
6472-
* CBOR serializations. The disadvantage is that the extra memory
6473-
* needed to do so can be wasteful, especially if the average
6468+
* supported CBOR serializations.</p> <pre> &#x2f;&#x2a; maximum supported CBOR size in bytes&#x2a;&#x2f; final int maxSize = 20000; ByteArrayOutputStream ba = new ByteArrayOutputStream(); &#x2f;&#x2a; throws UnsupportedOperationException if too big&#x2a;&#x2f; cborObject.WriteTo(new FilterOutputStream(ba) { private int size = 0; public void write(byte[] b, int off, int len) { if (len&gt;(maxSize-size)) { throw new UnsupportedOperationException(); } size+=len; out.write(b, off, len); } public void write(byte b) { if (size &gt;= maxSize) { throw new UnsupportedOperationException(); } size++; out.write(b); } }); byte[] bytes = ba.toByteArray(); </pre>
6469+
* <p>The following example (originally written in C# for the.NET
6470+
* version) shows how to use a.NET MemoryStream to limit the size of
6471+
* supported CBOR serializations. The disadvantage is that the extra
6472+
* memory needed to do so can be wasteful, especially if the average
64746473
* serialized object is much smaller than the maximum size given (for
64756474
* example, if the maximum size is 20000 bytes, but the average
64766475
* serialized object has a size of 50 bytes).</p> <pre> byte[] backing = new byte[20000]; &#x2f;&#x2a; maximum supported CBOR size in bytes&#x2a;&#x2f; byte[] bytes1, bytes2; {

0 commit comments

Comments
 (0)