Skip to content

Commit 402d459

Browse files
committed
update Java version
1 parent 2779519 commit 402d459

File tree

10 files changed

+78
-776
lines changed

10 files changed

+78
-776
lines changed

api/com.upokecenter.cbor.CBORDateConverter.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747

4848
## Methods
4949

50-
* `CBORObject DateTimeFieldsToCBORObject​(int year,
51-
int[] lesserFields)`<br>
52-
Converts a date/time in the form of a year, month, day, hour, minute,
53-
second, fractional seconds, and time offset to a CBOR object.
5450
* `CBORObject DateTimeFieldsToCBORObject​(int smallYear,
5551
int month,
5652
int day)`<br>
@@ -239,38 +235,14 @@ Converts a date/time in the form of a year, month, day, hour, minute, and
239235

240236
* <code>CBORException</code> - An error occurred in conversion.
241237

242-
### DateTimeFieldsToCBORObject
243-
public CBORObject DateTimeFieldsToCBORObject​(int year, int[] lesserFields)
244-
Converts a date/time in the form of a year, month, day, hour, minute,
245-
second, fractional seconds, and time offset to a CBOR object.
246-
247-
**Parameters:**
248-
249-
* <code>year</code> - The year.
250-
251-
* <code>lesserFields</code> - An array that will store the fields (other than the
252-
year) of the date and time. See the TryGetDateTimeFields method for
253-
information on the "lesserFields" parameter.
254-
255-
**Returns:**
256-
257-
* A CBOR object encoding the given date fields according to the
258-
conversion type used to create this date converter.
259-
260-
**Throws:**
261-
262-
* <code>java.lang.NullPointerException</code> - The parameter <code>lesserFields</code> is null.
263-
264-
* <code>CBORException</code> - An error occurred in conversion.
265-
266238
### DateTimeFieldsToCBORObject
267239
public CBORObject DateTimeFieldsToCBORObject​(com.upokecenter.numbers.EInteger bigYear, int[] lesserFields)
268240
Converts a date/time in the form of a year, month, day, hour, minute,
269241
second, fractional seconds, and time offset to a CBOR object.
270242

271243
**Parameters:**
272244

273-
* <code>bigYear</code> - The year.
245+
* <code>bigYear</code> - The parameter <code>bigYear</code> is a Numbers.EInteger object.
274246

275247
* <code>lesserFields</code> - An array that will store the fields (other than the
276248
year) of the date and time. See the TryGetDateTimeFields method for

api/com.upokecenter.cbor.CBORObject.md

Lines changed: 7 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ Instead, convert both CBOR objects to numbers (with .AsNumber()), and
117117
use the first number's.Add() method.
118118
Instead, convert both CBOR objects to numbers (with .AsNumber()), and
119119
use the first number's.Add() method.
120-
* `CBORObject ApplyJSONPatch​(CBORObject patch)`<br>
121-
Returns a copy of this object after applying the operations in a JSON patch,
122-
in the form of a CBOR object.
123120
* `boolean AsBoolean()`<br>
124121
Returns false if this object is a CBOR false, null, or undefined value
125122
(whether or not the object has tags); otherwise, true.
@@ -202,12 +199,6 @@ Instead, use the following: (cbor.AsNumber().ToInt64Checked()), or
202199
Converts this object to a 32-bit floating point number.
203200
* `java.lang.String AsString()`<br>
204201
Gets the value of this object as a text string.
205-
* `CBORObject AtJSONPointer​(java.lang.String pointer)`<br>
206-
Gets the CBOR object referred to by a JSON Pointer according to RFC6901.
207-
* `CBORObject AtJSONPointer​(java.lang.String pointer,
208-
CBORObject defaultValue)`<br>
209-
Gets the CBOR object referred to by a JSON Pointer according to RFC6901, or
210-
a default value if the operation fails.
211202
* `long CalcEncodedSize() EncodeToBytes()`<br>
212203
Calculates the number of bytes this CBOR object takes when serialized as a
213204
byte array using the EncodeToBytes() method.
@@ -1127,9 +1118,7 @@ Gets the value of a CBOR object by integer index in this array or by integer
11271118

11281119
* The CBOR object referred to by index or key in this array or map. If
11291120
this is a CBOR map, returns <code>null</code> (not <code>
1130-
CBORObject.Null</code>) if an item with the given key doesn't exist (but
1131-
this behavior may change to throwing an exception in version 5.0 or
1132-
later).
1121+
CBORObject.Null</code>) if an item with the given key doesn't exist.
11331122

11341123
**Throws:**
11351124

@@ -2980,10 +2969,7 @@ Generates a CBOR object from a data stream in JavaScript object Notation
29802969
UTF-16, or UTF-32 encoding; the encoding is detected by assuming
29812970
that the first character read must be a byte-order mark or a nonzero
29822971
basic character (U+0001 to U+007F). (In previous versions, only
2983-
UTF-8 was allowed.). (This behavior may change to supporting only
2984-
UTF-8, with or without a byte order mark, in version 5.0 or later,
2985-
perhaps with an option to restore the previous behavior of also
2986-
supporting UTF-16 and UTF-32.).
2972+
UTF-8 was allowed.).
29872973

29882974
**Parameters:**
29892975

@@ -3111,10 +3097,7 @@ Generates a CBOR object from a data stream in JavaScript object Notation
31113097
UTF-32 encoding; the encoding is detected by assuming that the first
31123098
character read must be a byte-order mark or a nonzero basic
31133099
character (U+0001 to U+007F). (In previous versions, only UTF-8 was
3114-
allowed.). (This behavior may change to supporting only UTF-8, with
3115-
or without a byte order mark, in version 5.0 or later, perhaps with
3116-
an option to restore the previous behavior of also supporting UTF-16
3117-
and UTF-32.).
3100+
allowed.).
31183101

31193102
**Parameters:**
31203103

@@ -3156,10 +3139,7 @@ Generates a CBOR object from a data stream in JavaScript object Notation
31563139
begin with a byte-order mark (U+FEFF). The byte array can be in
31573140
UTF-8, UTF-16, or UTF-32 encoding; the encoding is detected by
31583141
assuming that the first character read must be a byte-order mark or
3159-
a nonzero basic character (U+0001 to U+007F). (This behavior may
3160-
change to supporting only UTF-8, with or without a byte order mark,
3161-
in version 5.0 or later, perhaps with an option to restore the
3162-
previous behavior of also supporting UTF-16 and UTF-32.).
3142+
a nonzero basic character (U+0001 to U+007F).
31633143

31643144
**Returns:**
31653145

@@ -3189,10 +3169,7 @@ Generates a CBOR object from a byte array in JavaScript object Notation
31893169
begin with a byte-order mark (U+FEFF). The byte array can be in
31903170
UTF-8, UTF-16, or UTF-32 encoding; the encoding is detected by
31913171
assuming that the first character read must be a byte-order mark or
3192-
a nonzero basic character (U+0001 to U+007F). (This behavior may
3193-
change to supporting only UTF-8, with or without a byte order mark,
3194-
in version 5.0 or later, perhaps with an option to restore the
3195-
previous behavior of also supporting UTF-16 and UTF-32.).
3172+
a nonzero basic character (U+0001 to U+007F).
31963173

31973174
* <code>jsonoptions</code> - Specifies options to control how the JSON data is decoded
31983175
to CBOR. See the JSONOptions class.
@@ -3228,10 +3205,7 @@ Generates a CBOR object from a byte array in JavaScript object Notation
32283205
byte-order mark (U+FEFF). The portion can be in UTF-8, UTF-16, or
32293206
UTF-32 encoding; the encoding is detected by assuming that the first
32303207
character read must be a byte-order mark or a nonzero basic
3231-
character (U+0001 to U+007F). (This behavior may change to
3232-
supporting only UTF-8, with or without a byte order mark, in version
3233-
5.0 or later, perhaps with an option to restore the previous
3234-
behavior of also supporting UTF-16 and UTF-32.).
3208+
character (U+0001 to U+007F).
32353209

32363210
* <code>offset</code> - An index, starting at 0, showing where the desired portion of
32373211
<code>bytes</code> begins.
@@ -3272,10 +3246,7 @@ Generates a CBOR object from a byte array in JavaScript object Notation
32723246
byte-order mark (U+FEFF). The portion can be in UTF-8, UTF-16, or
32733247
UTF-32 encoding; the encoding is detected by assuming that the first
32743248
character read must be a byte-order mark or a nonzero basic
3275-
character (U+0001 to U+007F). (This behavior may change to
3276-
supporting only UTF-8, with or without a byte order mark, in version
3277-
5.0 or later, perhaps with an option to restore the previous
3278-
behavior of also supporting UTF-16 and UTF-32.).
3249+
character (U+0001 to U+007F).
32793250

32803251
* <code>offset</code> - An index, starting at 0, showing where the desired portion of
32813252
<code>bytes</code> begins.
@@ -4360,99 +4331,6 @@ Writes the binary representation of this CBOR object and returns a byte
43604331

43614332
* <code>java.lang.NullPointerException</code> - The parameter <code>options</code> is null.
43624333

4363-
### AtJSONPointer
4364-
public CBORObject AtJSONPointer​(java.lang.String pointer)
4365-
Gets the CBOR object referred to by a JSON Pointer according to RFC6901. For
4366-
more information, see the overload taking a default value parameter.
4367-
4368-
**Parameters:**
4369-
4370-
* <code>pointer</code> - A JSON pointer according to RFC 6901.
4371-
4372-
**Returns:**
4373-
4374-
* An object within this CBOR object. Returns this object if pointer is
4375-
the empty string (even if this object has a CBOR type other than
4376-
array or map).
4377-
4378-
**Throws:**
4379-
4380-
* <code>CBORException</code> - Thrown if the pointer is null, or
4381-
if the pointer is invalid, or if there is no object at the given
4382-
pointer, or the special key "-" appears in the pointer, or if the
4383-
pointer is non-empty and this object has a CBOR type other than
4384-
array or map.
4385-
4386-
### AtJSONPointer
4387-
public CBORObject AtJSONPointer​(java.lang.String pointer, CBORObject defaultValue)
4388-
Gets the CBOR object referred to by a JSON Pointer according to RFC6901, or
4389-
a default value if the operation fails. The syntax for a JSON
4390-
Pointer is: <pre>'/' KEY '/' KEY.get(...)</pre> where KEY represents
4391-
a key into the JSON object or its sub-objects in the hierarchy. For
4392-
example, <pre>/foo/2/bar</pre> means the same as
4393-
<pre>obj.get('foo')[2]['bar']</pre> in JavaScript. If "~" and/or "/"
4394-
occurs in a key, it must be escaped with "~0" or "~1", respectively,
4395-
in a JSON pointer. JSON pointers also support the special key "-"
4396-
(as in "/foo/-") to indicate the end of an array, but this method
4397-
treats this key as an error since it refers to a nonexistent item.
4398-
Indices to arrays (such as 2 in the example) must contain only basic
4399-
digits 0 to 9 and no leading zeros. (Note that RFC 6901 was
4400-
published before JSON was extended to support top-level values other
4401-
than arrays and key-value dictionaries.).
4402-
4403-
**Parameters:**
4404-
4405-
* <code>pointer</code> - A JSON pointer according to RFC 6901.
4406-
4407-
* <code>defaultValue</code> - The parameter <code>defaultValue</code> is a Cbor.CBORObject
4408-
object.
4409-
4410-
**Returns:**
4411-
4412-
* An object within the specified JSON object. Returns this object if
4413-
pointer is the empty string (even if this object has a CBOR type
4414-
other than array or map). Returns <code>defaultValue</code> if the
4415-
pointer is null, or if the pointer is invalid, or if there is no
4416-
object at the given pointer, or the special key "-" appears in the
4417-
pointer, or if the pointer is non-empty and this object has a CBOR
4418-
type other than array or map.
4419-
4420-
### ApplyJSONPatch
4421-
public CBORObject ApplyJSONPatch​(CBORObject patch)
4422-
Returns a copy of this object after applying the operations in a JSON patch,
4423-
in the form of a CBOR object. JSON patches are specified in RFC 6902
4424-
and their format is summarized in the remarks below.<p><b>Remarks:</b>
4425-
A JSON patch is an array with one or more maps. Each map has the
4426-
following keys: </p><ul> <li>"op" - Required. This key's value is the
4427-
patch operation and must be "add", "remove", "move", "copy", "test",
4428-
or "replace", in basic lower case letters and no other case
4429-
combination.</li> <li>"value" - Required if the operation is "add",
4430-
"replace", or "test" and specifies the item to add (insert), or that
4431-
will replace the existing item, or to check an existing item for
4432-
equality, respectively. (For "test", the operation fails if the
4433-
existing item doesn't match the specified value.)</li> <li>"path" -
4434-
Required for all operations. A JSON Pointer (RFC 6901) specifying the
4435-
destination path in the CBOR object for the operation. For more
4436-
information, see RFC 6901 or the documentation for
4437-
AtJSONPointer(pointer, defaultValue).</li> <li>"from" - Required if
4438-
the operation is "move" or "copy". A JSON Pointer (RFC 6901)
4439-
specifying the path in the CBOR object where the source value is
4440-
located.</li></ul>
4441-
4442-
**Parameters:**
4443-
4444-
* <code>patch</code> - A JSON patch in the form of a CBOR object; it has the form
4445-
summarized in the remarks.
4446-
4447-
**Returns:**
4448-
4449-
* The result of the patch operation.
4450-
4451-
**Throws:**
4452-
4453-
* <code>CBORException</code> - The parameter <code>patch</code> is
4454-
null or the patch operation failed.
4455-
44564334
### equals
44574335
public boolean equals​(java.lang.Object obj)
44584336
Determines whether this object and another object are equal and have the

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

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ public boolean TryGetDateTimeFields(CBORObject obj, EInteger[] year, int[]
201201
// TODO: In next major version, return false instead of throwing an
202202
// exception if the arguments are invalid, to conform to convention
203203
// with Try* methods in DotNet.
204+
// TODO: In next minor version, add overload that takes an out parameter
205+
// for year to DotNet version.
204206
if (year == null) {
205207
throw new NullPointerException("year");
206208
}
@@ -370,25 +372,7 @@ public CBORObject DateTimeFieldsToCBORObject(
370372
/**
371373
* Converts a date/time in the form of a year, month, day, hour, minute,
372374
* second, fractional seconds, and time offset to a CBOR object.
373-
* @param year The year.
374-
* @param lesserFields An array that will store the fields (other than the
375-
* year) of the date and time. See the TryGetDateTimeFields method for
376-
* information on the "lesserFields" parameter.
377-
* @return A CBOR object encoding the given date fields according to the
378-
* conversion type used to create this date converter.
379-
* @throws NullPointerException The parameter {@code lesserFields} is null.
380-
* @throws com.upokecenter.cbor.CBORException An error occurred in conversion.
381-
*/
382-
public CBORObject DateTimeFieldsToCBORObject(int year, int[]
383-
lesserFields) {
384-
return this.DateTimeFieldsToCBORObject(EInteger.FromInt32(year),
385-
lesserFields);
386-
}
387-
388-
/**
389-
* Converts a date/time in the form of a year, month, day, hour, minute,
390-
* second, fractional seconds, and time offset to a CBOR object.
391-
* @param bigYear The year.
375+
* @param bigYear The parameter {@code bigYear} is a Numbers.EInteger object.
392376
* @param lesserFields An array that will store the fields (other than the
393377
* year) of the date and time. See the TryGetDateTimeFields method for
394378
* information on the "lesserFields" parameter.
@@ -400,6 +384,8 @@ public CBORObject DateTimeFieldsToCBORObject(int year, int[]
400384
*/
401385
public CBORObject DateTimeFieldsToCBORObject(EInteger bigYear, int[]
402386
lesserFields) {
387+
// TODO: In next minor version, add overload that takes int rather than
388+
// EInteger
403389
if (bigYear == null) {
404390
throw new NullPointerException("bigYear");
405391
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,6 @@ private CBORObject NextJSONValue(
423423
String errstr = (str.length() <= 100) ? str : (str.substring(0,100) + "...");
424424
this.RaiseError("JSON number can't be parsed. " + errstr);
425425
}
426-
} else {
427-
// check if character can validly appear after a JSON number
428-
if (c != ',' && c != ']' && c != '}' && c != -1 &&
429-
c != 0x20 && c != 0x0a && c != 0x0d && c != 0x09) {
430-
this.RaiseError("Invalid character after JSON number");
431-
}
432426
}
433427
if (c == 0x20 || c == 0x0a || c == 0x0d || c == 0x09) {
434428
nextChar[0] = this.SkipWhitespaceJSON();

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,6 @@ private CBORObject NextJSONNonnegativeNumber(int c, int[] nextChar) {
430430
// errstr = (str.length() <= 100) ? str : (str.substring(0, // 100) + "...");
431431
this.RaiseError("JSON number can't be parsed. " + errstr);
432432
}
433-
} else {
434-
// check if character can validly appear after a JSON number
435-
if (c != ',' && c != ']' && c != '}' && c != -1 &&
436-
c != 0x20 && c != 0x0a && c != 0x0d && c != 0x09) {
437-
this.RaiseError("Invalid character after JSON number");
438-
}
439433
}
440434
if (c == -1 || (c != 0x20 && c != 0x0a && c != 0x0d && c != 0x09)) {
441435
nextChar[0] = c;

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,6 @@ private CBORObject NextJSONNonnegativeNumber(int c, int[] nextChar) {
333333
}
334334
// System.out.println("endIndex="+endIndex[0]+", "+
335335
// this.jstring.substring(endIndex[0], (endIndex[0])+(// Math.min(20, this.endPos-endIndex[0]))));
336-
} else {
337-
// check if character can validly appear after a JSON number
338-
if (c != ',' && c != ']' && c != '}' && c != -1 &&
339-
c != 0x20 && c != 0x0a && c != 0x0d && c != 0x09) {
340-
this.RaiseError("Invalid character after JSON number");
341-
}
342336
}
343337
if (c == -1 || (c != 0x20 && c != 0x0a && c != 0x0d && c != 0x09)) {
344338
nextChar[0] = c;

0 commit comments

Comments
 (0)