@Override public ArrayList<RemoteObject> deserializeArray(String queryScope, String input) { String bodyFormat = getDeserializationBodyFormat(); if (XML.equals(bodyFormat)) { return deserializeArrayAsXml(queryScope, input); } else if (JSON.equals(bodyFormat)) { return deserializeArrayAsJson(queryScope, input); } else { return deserializeArrayAsJson(queryScope, input); } }
@Override public RemoteObject deserialize(String queryScope, String input) { String bodyFormat = getDeserializationBodyFormat(); // TODO parse role if auth object Parser parser = null; if (XML.equals(bodyFormat)) { parser = createXmlParser(queryScope, input); } else if (JSON.equals(bodyFormat)) { parser = createJsonParser(queryScope, input); } else { parser = createJsonParser(queryScope, input); } return deserialize(queryScope, parser); }
@Override public String serialize() { String bodyFormat = getSerializationBodyFormat(); SerializerBuilder builder = null; String recordSelector = HttpAdapter.createResponseWrangling(this).getRecordSelector(); if (XML.equals(bodyFormat)) { builder = new XmlSerializer.XmlSerializerBuilder(recordSelector); } else if (JSON.equals(bodyFormat)) { builder = new JsonSerializer.JsonSerializerBuilder(recordSelector); } else if (FORM_ENCODED.equals(bodyFormat)) { builder = new FormEncodedSerializer.FormEncodedSerializerBuilder(recordSelector); } final RouterAdapter routerAdapter = RemoteRailsConfig.getRouterAdapterByClass(this.getClass()); if (builder != null && routerAdapter != null) { builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("id"), "id"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("comments"), "comments"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("currency"), "currency"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("last_price"), "last_price"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("last_qty"), "last_qty"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("price"), "price"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("quantity"), "quantity"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("side"), "side"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("status"), "status"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("symbol"), "symbol"); builder.addFieldMapping( ((HttpAdapter) routerAdapter) .getConfigurationsAsConfiguration("POST") .getResponseRemoteFieldName("transact_time"), "transact_time"); return builder.create().serialize(this); } else { return super.serialize(); } }