@@ -1158,30 +1158,33 @@ public static <TKey, TValue> CBORObject FromObject(Map<TKey,
11581158
11591159 /**
11601160 * Generates a CBORObject from an arbitrary object. The following types are
1161- * specially handled by this method: null , primitive types, strings,
1162- * CBORObject , arbitrary-precision decimal , arbitrary-precision binary
1163- * float , arbitrary-precision rational number, the custom
1164- * arbitrary-precision integer , lists, arrays, enumerations (
1165- * <code>Enum</code> objects), and maps. <p>In the .NET version, if the object
1166- * is a type not specially handled by this method, returns a CBOR map
1167- * with the values of each of its read/write properties (or all
1168- * properties in the case of an anonymous type). Properties are
1169- * converted to their camel-case names (meaning if a name starts with A
1170- * to Z, that letter is lower-cased). If the property name begins with
1171- * the word "Is", that word is deleted from the name. Also, .NET
1172- * <code>Enum</code> objects will be converted to their integer values, and a
1173- * multidimensional array is converted to an array of arrays.</p> <p>In
1174- * the Java version, if the object is a type not specially handled by
1175- * this method, this method checks the CBOR object for methods starting
1176- * with the word "get" or "is" that take no parameters, and returns a
1177- * CBOR map with one entry for each such method found. For each method
1178- * found, the starting word "get" or "is" is deleted from its name, and
1179- * the name is converted to camel case (meaning if a name starts with A
1180- * to Z, that letter is lower-cased). Also, Java <code>Enum</code> objects
1181- * will be converted to the result of their name method.</p> <p>If the
1182- * input is a byte array, the byte array is copied to a new byte array.
1183- * (This method can't be used to decode CBOR data from a byte array; for
1184- * that, use the DecodeFromBytes method instead.).</p>
1161+ * specially handled by this method: null; primitive types; string;
1162+ * CBORObject; the <code>EDecimal</code>, <code>EFloat</code>, <code>EInteger</code>, and
1163+ * <code>ERational</code> classes in the new <code>PeterO.Numbers</code> library (in
1164+ * .NET) or the <code>com.github.peteroupc/numbers</code> artifact (in Java);
1165+ * the legacy <code>ExtendedDecimal</code>, <code>ExtendedFloat</code>,
1166+ * <code>ExtendedInteger</code>, and <code>ExtendedRational</code> classes in this
1167+ * library; arrays; enumerations (<code>Enum</code> objects); and maps. <p>In
1168+ * the .NET version, if the object is a type not specially handled by
1169+ * this method, returns a CBOR map with the values of each of its
1170+ * read/write properties (or all properties in the case of an anonymous
1171+ * type). Properties are converted to their camel-case names (meaning if
1172+ * a name starts with A to Z, that letter is lower-cased). If the
1173+ * property name begins with the word "Is", that word is deleted from
1174+ * the name. Also, .NET <code>Enum</code> objects will be converted to their
1175+ * integer values, and a multidimensional array is converted to an array
1176+ * of arrays.</p> <p>In the Java version, if the object is a type not
1177+ * specially handled by this method, this method checks the CBOR object
1178+ * for methods starting with the word "get" or "is" that take no
1179+ * parameters, and returns a CBOR map with one entry for each such
1180+ * method found. For each method found, the starting word "get" or "is"
1181+ * is deleted from its name, and the name is converted to camel case
1182+ * (meaning if a name starts with A to Z, that letter is lower-cased).
1183+ * Also, Java <code>Enum</code> objects will be converted to the result of
1184+ * their name method.</p> <p>If the input is a byte array, the byte
1185+ * array is copied to a new byte array. (This method can't be used to
1186+ * decode CBOR data from a byte array; for that, use the DecodeFromBytes
1187+ * method instead.).</p>
11851188 * @param obj An arbitrary object.
11861189 * @return A CBOR object corresponding to the given object. Returns
11871190 * CBORObject.Null if the object is null.
@@ -1205,6 +1208,22 @@ public static CBORObject FromObject(Object obj) {
12051208 if (obj instanceof BigInteger ) {
12061209 return FromObject ((BigInteger )obj );
12071210 }
1211+ EInteger eif = ((obj instanceof EInteger ) ? (EInteger )obj : null );
1212+ if (eif != null ) {
1213+ return FromObject (eif );
1214+ }
1215+ EDecimal edf = ((obj instanceof EDecimal ) ? (EDecimal )obj : null );
1216+ if (edf != null ) {
1217+ return FromObject (edf );
1218+ }
1219+ EFloat eff = ((obj instanceof EFloat ) ? (EFloat )obj : null );
1220+ if (eff != null ) {
1221+ return FromObject (eff );
1222+ }
1223+ ERational erf = ((obj instanceof ERational ) ? (ERational )obj : null );
1224+ if (erf != null ) {
1225+ return FromObject (erf );
1226+ }
12081227 ExtendedDecimal df = ((obj instanceof ExtendedDecimal ) ? (ExtendedDecimal )obj : null );
12091228 if (df != null ) {
12101229 return FromObject (df );
0 commit comments