Class CBORDataUtilities
-
Method Summary
Modifier and TypeMethodDescriptionstatic CBORObjectParseJSONNumber(byte[] bytes) Parses a number from a byte sequence whose format follows the JSON specification.static CBORObjectParseJSONNumber(byte[] bytes, int offset, int count) Parses a number whose format follows the JSON specification (RFC 8259) from a portion of a byte sequence, and converts that number to a CBOR object.static CBORObjectParseJSONNumber(byte[] bytes, int offset, int count, JSONOptions options) Parses a number from a byte sequence whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.static CBORObjectParseJSONNumber(byte[] bytes, JSONOptions options) Parses a number from a byte sequence whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.static CBORObjectParseJSONNumber(char[] chars) Parses a number from a sequence ofchars whose format follows the JSON specification.static CBORObjectParseJSONNumber(char[] chars, int offset, int count) Parses a number whose format follows the JSON specification (RFC 8259) from a portion of a sequence ofchars, and converts that number to a CBOR object.static CBORObjectParseJSONNumber(char[] chars, int offset, int count, JSONOptions options) Parses a number from a sequence ofchars whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.static CBORObjectParseJSONNumber(char[] chars, JSONOptions options) Parses a number from a sequence ofchars whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.static CBORObjectParseJSONNumber(String str) Parses a number whose format follows the JSON specification.static CBORObjectParseJSONNumber(String str, boolean integersOnly, boolean positiveOnly) Deprecated.Call the one-argument version of this method instead.static CBORObjectParseJSONNumber(String str, boolean integersOnly, boolean positiveOnly, boolean preserveNegativeZero) Deprecated.Instead, call ParseJSONNumber(str, jsonoptions) with a JSONOptions that sets preserveNegativeZero to the desired value, either true or false.static CBORObjectParseJSONNumber(String str, int offset, int count) Parses a number whose format follows the JSON specification (RFC 8259) from a portion of a text string, and converts that number to a CBOR object.static CBORObjectParseJSONNumber(String str, int offset, int count, JSONOptions options) Parses a number whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.static CBORObjectParseJSONNumber(String str, JSONOptions options) Parses a number whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.
-
Method Details
-
ParseJSONNumber
Parses a number whose format follows the JSON specification. The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.- Parameters:
str- A text string to parse as a JSON number.- Returns:
- A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as "-0" or "-0.0"). Returns null if the parsing fails, including if the string is null or empty.
-
ParseJSONNumber
@Deprecated public static CBORObject ParseJSONNumber(String str, boolean integersOnly, boolean positiveOnly) Deprecated.Call the one-argument version of this method instead. If this method call used positiveOnly = true, check that the String does not begin with '-' before calling that version. If this method call used integersOnly = true, check that the String does not contain '.', 'E', or 'e' before calling that version.Parses a number whose format follows the JSON specification (RFC 8259). The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.
Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.
- Parameters:
str- A text string to parse as a JSON number.integersOnly- If true, no decimal points or exponents are allowed in the string. The default is false.positiveOnly- If true, only positive numbers are allowed (the leading minus is disallowed). The default is false.- Returns:
- A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as "-0" or "-0.0"). Returns null if the parsing fails, including if the string is null or empty.
-
ParseJSONNumber
@Deprecated public static CBORObject ParseJSONNumber(String str, boolean integersOnly, boolean positiveOnly, boolean preserveNegativeZero) Deprecated.Instead, call ParseJSONNumber(str, jsonoptions) with a JSONOptions that sets preserveNegativeZero to the desired value, either true or false. If this method call used positiveOnly = true, check that the String does not begin with '-' before calling that version. If this method call used integersOnly = true, check that the String does not contain '.', 'E', or 'e' before calling that version.Parses a number whose format follows the JSON specification (RFC 8259).
Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.
- Parameters:
str- A text string to parse as a JSON number.integersOnly- If true, no decimal points or exponents are allowed in the string. The default is false.positiveOnly- If true, the leading minus is disallowed in the string. The default is false.preserveNegativeZero- If true, returns positive zero if the number is a zero that starts with a minus sign (such as "-0" or "-0.0"). Otherwise, returns negative zero in this case. The default is false.- Returns:
- A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty.
-
ParseJSONNumber
Parses a number whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.
Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.
- Parameters:
str- A text string to parse as a JSON number.options- An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.- Returns:
- A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty.
-
ParseJSONNumber
Parses a number whose format follows the JSON specification (RFC 8259) from a portion of a text string, and converts that number to a CBOR object.
Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.
- Parameters:
str- A text string containing the portion to parse as a JSON number.offset- An index, starting at 0, showing where the desired portion ofstrbegins.count- The length, in code units, of the desired portion ofstr(but not more thanstr's length).- Returns:
- A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty.
- Throws:
IllegalArgumentException- Eitheroffsetorcountis less than 0 or greater thanstr's length, orstr's length minusoffsetis less thancount.NullPointerException- The parameterstris null.
-
ParseJSONNumber
Parses a number whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.
Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.
- Parameters:
str- A text string to parse as a JSON number.offset- An index, starting at 0, showing where the desired portion ofstrbegins.count- The length, in code units, of the desired portion ofstr(but not more thanstr's length).options- An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.- Returns:
- A CBOR object that represents the parsed number. Returns null if the
parsing fails, including if the string is null or empty or
countis 0 or less. - Throws:
NullPointerException- The parameterstris null.IllegalArgumentException- Unsupported conversion kind.
-
ParseJSONNumber
Parses a number from a byte sequence whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.
Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A byte sequence representing a valid JSON number is not allowed to contain white space characters, including spaces.
- Parameters:
bytes- A sequence of bytes to parse as a JSON number.offset- An index, starting at 0, showing where the desired portion ofbytesbegins.count- The length, in code units, of the desired portion ofbytes(but not more thanbytes's length).options- An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.- Returns:
- A CBOR object that represents the parsed number. Returns null if the
parsing fails, including if the byte sequence is null or empty or
countis 0 or less. - Throws:
NullPointerException- The parameterbytesis null.IllegalArgumentException- Unsupported conversion kind.
-
ParseJSONNumber
Parses a number from a byte sequence whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.
Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A byte sequence representing a valid JSON number is not allowed to contain white space characters, including spaces.
- Parameters:
bytes- A sequence of bytes to parse as a JSON number.options- An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.- Returns:
- A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the byte sequence is null or empty.
-
ParseJSONNumber
Parses a number whose format follows the JSON specification (RFC 8259) from a portion of a byte sequence, and converts that number to a CBOR object.
Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A byte sequence representing a valid JSON number is not allowed to contain white space characters, including spaces.
- Parameters:
bytes- A sequence of bytes to parse as a JSON number.offset- An index, starting at 0, showing where the desired portion ofbytesbegins.count- The length, in code units, of the desired portion ofbytes(but not more thanbytes's length).- Returns:
- A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the byte sequence is null or empty.
- Throws:
IllegalArgumentException- Eitheroffsetorcountis less than 0 or greater thanbytes's length, orbytes's length minusoffsetis less thancount.NullPointerException- The parameterbytesis null.
-
ParseJSONNumber
Parses a number from a byte sequence whose format follows the JSON specification. The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.- Parameters:
bytes- A byte sequence to parse as a JSON number.- Returns:
- A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as "-0" or "-0.0"). Returns null if the parsing fails, including if the byte sequence is null or empty.
-
ParseJSONNumber
Parses a number from a sequence of
chars whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A sequence of
chars representing a valid JSON number is not allowed to contain white space characters, including spaces.- Parameters:
chars- A sequence ofchars to parse as a JSON number.offset- An index, starting at 0, showing where the desired portion ofcharsbegins.count- The length, in code units, of the desired portion ofchars(but not more thanchars's length).options- An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.- Returns:
- A CBOR object that represents the parsed number. Returns null if the
parsing fails, including if the sequence of
chars is null or empty orcountis 0 or less. - Throws:
NullPointerException- The parametercharsis null.IllegalArgumentException- Unsupported conversion kind.
-
ParseJSONNumber
Parses a number from a sequence of
chars whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A sequence of
chars representing a valid JSON number is not allowed to contain white space characters, including spaces.- Parameters:
chars- A sequence ofchars to parse as a JSON number.options- An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.- Returns:
- A CBOR object that represents the parsed number. Returns null if the
parsing fails, including if the sequence of
chars is null or empty.
-
ParseJSONNumber
Parses a number whose format follows the JSON specification (RFC 8259) from a portion of a sequence of
chars, and converts that number to a CBOR object.Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (".", full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A sequence of
chars representing a valid JSON number is not allowed to contain white space characters, including spaces.- Parameters:
chars- A sequence ofchars to parse as a JSON number.offset- An index, starting at 0, showing where the desired portion ofcharsbegins.count- The length, in code units, of the desired portion ofchars(but not more thanchars's length).- Returns:
- A CBOR object that represents the parsed number. Returns null if the
parsing fails, including if the sequence of
chars is null or empty. - Throws:
IllegalArgumentException- Eitheroffsetorcountis less than 0 or greater thanchars's length, orchars's length minusoffsetis less thancount.NullPointerException- The parametercharsis null.
-
ParseJSONNumber
Parses a number from a sequence ofchars whose format follows the JSON specification. The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.- Parameters:
chars- A sequence ofchars to parse as a JSON number.- Returns:
- A CBOR object that represents the parsed number. Returns positive
zero if the number is a zero that starts with a minus sign (such as "-0" or
"-0.0"). Returns null if the parsing fails, including if the sequence of
chars is null or empty.
-