Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Parsing Process for DSRequest setValues() API

    Hi Isomorphic. When using the setValues() API of server side DSRequest, what type of objects are expected in the Map<String, Object>? I can see that sending plain Strings for every field works, with some very basic values, but I don't know if this optimal and if I should instead send the appropriate Object type according to the field type? My ultimate goal is to guarantee that dates, decimals and other non-text data types get parsed and used correctly in the DataSource.OP_ADD operation.

    Thanks

    #2
    See the QuickStart Guide, beginning of the Server Framework chapter, for a mapping between field types and Java types used to represent them.

    Comment


      #3
      Thanks Isomorphic. Follow up question: if I report Map of Strings, how come numeric and date values are properly recognized?

      For instance, sending a Map like this to setValues():
      Code:
      static Map<String,String> test = new HashMap();
      static {
          test.put("numericField","100");
          test.put("dateField","2016-04-26");
      }
      Will get me proper Integer and Date values in my DB (asuming that in my DB those fields are INTEGER and DATE fields).

      Would you care to elaborate a little bit about the parsing process you follow? Is there a specific standard integer, decimal, boolean and date String representation you accept and recognize properly (instead of their Integer, Double/Float, Boolean and Date objects)?

      Thanks
      Last edited by carlossierra; 26 Apr 2016, 19:25. Reason: Code formatting...

      Comment


        #4
        You should use actual Date, Number and Boolean instances as per docs. We don't generally parse - there are just a couple of circumstances where we will parse to try to make up for a developer mistake, or where passing through a value of the wrong type directly to the DB might result in a lucky accident where it still works. However the only approach we support is to provide the correct types as per docs.

        Comment


          #5
          Excelent. It's very clear. Thanks for the fast reply!

          Comment

          Working...
          X