|
| 1 | +# com.upokecenter.cbor.CBORDataUtilities |
| 2 | + |
| 3 | + public final class CBORDataUtilities extends Object |
| 4 | + |
| 5 | +Contains methods useful for reading and writing data, with a focus on CBOR. |
| 6 | + |
| 7 | +## Methods |
| 8 | + |
| 9 | +* `static CBORObject ParseJSONNumber(String str)`<br> |
| 10 | + Parses a number whose format follows the JSON specification. |
| 11 | +* `static CBORObject ParseJSONNumber(String str, |
| 12 | + boolean integersOnly, |
| 13 | + boolean positiveOnly)`<br> |
| 14 | + Parses a number whose format follows the JSON specification (RFC 7159). |
| 15 | +* `static CBORObject ParseJSONNumber(String str, |
| 16 | + boolean integersOnly, |
| 17 | + boolean positiveOnly, |
| 18 | + boolean preserveNegativeZero)`<br> |
| 19 | + Parses a number whose format follows the JSON specification (RFC 7159). |
| 20 | + |
| 21 | +## Method Details |
| 22 | + |
| 23 | +### ParseJSONNumber |
| 24 | + public static CBORObject ParseJSONNumber(String str) |
| 25 | +Parses a number whose format follows the JSON specification. See |
| 26 | + #ParseJSONNumber(String, integersOnly, parseOnly) for more |
| 27 | + information. |
| 28 | + |
| 29 | +**Parameters:** |
| 30 | + |
| 31 | +* <code>str</code> - A string to parse. The string is not allowed to contain white |
| 32 | + space characters, including spaces. |
| 33 | + |
| 34 | +**Returns:** |
| 35 | + |
| 36 | +* A CBOR object that represents the parsed number. Returns positive |
| 37 | + zero if the number is a zero that starts with a minus sign (such as |
| 38 | + "-0" or "-0.0"). Returns null if the parsing fails, including if the |
| 39 | + string is null or empty. |
| 40 | + |
| 41 | +### ParseJSONNumber |
| 42 | + public static CBORObject ParseJSONNumber(String str, boolean integersOnly, boolean positiveOnly) |
| 43 | +Parses a number whose format follows the JSON specification (RFC 7159). |
| 44 | + Roughly speaking, a valid number consists of an optional minus sign, |
| 45 | + one or more basic digits (starting with 1 to 9 unless the only digit |
| 46 | + is 0), an optional decimal point (".", full stop) with one or more |
| 47 | + basic digits, and an optional letter E or e with an optional plus or |
| 48 | + minus sign and one or more basic digits (the exponent). |
| 49 | + |
| 50 | +**Parameters:** |
| 51 | + |
| 52 | +* <code>str</code> - A string to parse. The string is not allowed to contain white |
| 53 | + space characters, including spaces. |
| 54 | + |
| 55 | +* <code>integersOnly</code> - If true, no decimal points or exponents are allowed in |
| 56 | + the string. |
| 57 | + |
| 58 | +* <code>positiveOnly</code> - If true, only positive numbers are allowed (the leading |
| 59 | + minus is disallowed). |
| 60 | + |
| 61 | +**Returns:** |
| 62 | + |
| 63 | +* A CBOR object that represents the parsed number. Returns positive |
| 64 | + zero if the number is a zero that starts with a minus sign (such as |
| 65 | + "-0" or "-0.0"). Returns null if the parsing fails, including if the |
| 66 | + string is null or empty. |
| 67 | + |
| 68 | +### ParseJSONNumber |
| 69 | + public static CBORObject ParseJSONNumber(String str, boolean integersOnly, boolean positiveOnly, boolean preserveNegativeZero) |
| 70 | +Parses a number whose format follows the JSON specification (RFC 7159). |
| 71 | + Roughly speaking, a valid number consists of an optional minus sign, |
| 72 | + one or more basic digits (starting with 1 to 9 unless the only digit |
| 73 | + is 0), an optional decimal point (".", full stop) with one or more |
| 74 | + basic digits, and an optional letter E or e with an optional plus or |
| 75 | + minus sign and one or more basic digits (the exponent). |
| 76 | + |
| 77 | +**Parameters:** |
| 78 | + |
| 79 | +* <code>str</code> - A string to parse. The string is not allowed to contain white |
| 80 | + space characters, including spaces. |
| 81 | + |
| 82 | +* <code>integersOnly</code> - If true, no decimal points or exponents are allowed in |
| 83 | + the string. |
| 84 | + |
| 85 | +* <code>positiveOnly</code> - If true, only positive numbers are allowed (the leading |
| 86 | + minus is disallowed). |
| 87 | + |
| 88 | +* <code>preserveNegativeZero</code> - If true, returns positive zero if the number is |
| 89 | + a zero that starts with a minus sign (such as "-0" or "-0.0"). |
| 90 | + Otherwise, returns negative zero in this case. |
| 91 | + |
| 92 | +**Returns:** |
| 93 | + |
| 94 | +* A CBOR object that represents the parsed number. Returns null if the |
| 95 | + parsing fails, including if the string is null or empty. |
0 commit comments