Java 类com.google.gson.internal.StringMap 实例源码

项目:wordpress_app_android    文件:NotificationSettingsFragment.java   
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (preference instanceof CheckBoxPreference) {
        CheckBoxPreference checkBoxPreference = (CheckBoxPreference) preference;
        boolean isChecked = (Boolean) newValue;
        int id = checkBoxPreference.getOrder();
        StringMap<Double> blogMap = mMutedBlogsList.get(id);
        blogMap.put("value", (!isChecked) ? 1.0 : 0.0);
        mMutedBlogsList.set(id, blogMap);
        StringMap<ArrayList> mutedBlogsMap = (StringMap<ArrayList>) mNotificationSettings.get("muted_blogs");
        mutedBlogsMap.put("value", mMutedBlogsList);
        mNotificationSettings.put("muted_blogs", mutedBlogsMap);
        checkBoxPreference.setChecked(isChecked);
        mNotificationSettingsChanged = true;
    }
    return false;
}
项目:wordpress_app_android    文件:NotificationSettingsFragment.java   
private void enabledButtonClick(View v) {
    StringMap<String> muteUntilMap = (StringMap<String>) mNotificationSettings.get("mute_until");
    if (muteUntilMap != null) {
        if (v.getId() == R.id.notificationsOff) {
            muteUntilMap.put("value", "forever");
        } else if (v.getId() == R.id.notifications1Hour) {
            muteUntilMap.put("value", String.valueOf((System.currentTimeMillis() / 1000) + 3600));
        } else if (v.getId() == R.id.notifications8Hours) {
            muteUntilMap.put("value", String.valueOf((System.currentTimeMillis() / 1000) + (3600 * 8)));
        }
        CheckBoxPreference enabledCheckBoxPreference = (CheckBoxPreference) findPreference(getString(R.string
                .pref_notifications_enabled));
        enabledCheckBoxPreference.setChecked(false);
        mNotificationSettings.put("mute_until", muteUntilMap);
        mNotificationSettingsChanged = true;
    }
}
项目:wordpress_app_android    文件:ABTestingUtils.java   
private static void fetchRemoteControlData() {
    Response.Listener<String> listener = new Response.Listener<String>() {
        public void onResponse(String response) {
            Gson gson = new Gson();
            try {
                sRemoteControlMap = gson.fromJson(response, StringMap.class);
            } catch (JsonSyntaxException jsonSyntaxException) {
                AppLog.e(T.UTILS, jsonSyntaxException);
            }
        }
    };
    Response.ErrorListener errorListener = new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            AppLog.w(T.UTILS, "Unable to fetch: " + REMOTE_CONTROL_URL);
            AppLog.e(T.UTILS, volleyError);
        }
    };
    StringRequest req = new StringRequest(Request.Method.GET, REMOTE_CONTROL_URL, listener, errorListener);
    if (WordPress.requestQueue != null) {
        WordPress.requestQueue.add(req);
    }
}
项目:wordpress_app_android    文件:TestUtils.java   
public static Object castIt(Object value) {
    if (value instanceof HashMap) {
        return injectDateInHashMap((HashMap<String, Object>) value);
    } else if (value instanceof String) {
        Date newValue = parseStringToDate((String) value);
        if (newValue != null) {
            return newValue;
        } else {
            return value;
        }
    } else if (value instanceof Double) {
        return (int) Math.round((Double) value);
    } else if (value instanceof Object[]) {
        return injectDateInArray((Object[]) value);
    } else if (value instanceof StringMap) {
        return injectDateInHashMap(stringMapToHashMap((StringMap) value));
    }
    return value;
}
项目:zeppelin    文件:HeliumRestApiTest.java   
@Test
public void testGetAllEnabledPackageInfo() throws IOException {
    // No enabled packages initially
    GetMethod get1 = httpGet("/helium/enabledPackage");
    assertThat(get1, isAllowed());
    Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body");
    assertEquals(body1.size(), 0);

    // Enable "name1" package
    ZeppelinServer.helium.enable("name1","artifact1");

    GetMethod get2 = httpGet("/helium/enabledPackage");
    assertThat(get2, isAllowed());
    Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body");

    assertEquals(body2.size(), 1);
    StringMap<Object> pkg = (StringMap<Object>) body2.get(0).get("pkg");
    assertEquals(pkg.get("name"), "name1");
}
项目:zeppelin    文件:HeliumRestApiTest.java   
@Test
public void testEnableDisablePackage() throws IOException {
    String packageName = "name1";
    PostMethod post1 = httpPost("/helium/enable/" + packageName, "");
    assertThat(post1, isAllowed());
    post1.releaseConnection();

    GetMethod get1 = httpGet("/helium/package/" + packageName);
    Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body");
    assertEquals(body1.get(0).get("enabled"), true);

    PostMethod post2 = httpPost("/helium/disable/" + packageName, "");
    assertThat(post2, isAllowed());
    post2.releaseConnection();

    GetMethod get2 = httpGet("/helium/package/" + packageName);
    Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body");
    assertEquals(body2.get(0).get("enabled"), false);
}
项目:biblio    文件:BulkBookLoad.java   
public static void main(String[] args) throws IOException {
    HttpClient client = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet("https://www.kimonolabs.com/api/43h8bb74?apikey=a506e75ca96092b0f73b0ff59c15abe6");
    HttpResponse response = client.execute(request);

    LOGGER.info("Response code [{}]", response.getStatusLine().getStatusCode());

    String responseContent = IOUtils.toString(response.getEntity().getContent());
    final KimonoIsbn kimonoIsbn = new Gson().fromJson(responseContent, KimonoIsbn.class);
    LOGGER.info(kimonoIsbn.toString());

    final List<StringMap> books = kimonoIsbn.getResults().get("books");
    for (StringMap book : books) {
        final String isbnUrl = (String) book.get("isbn");
        LOGGER.info(isbnUrl);
        send(isbnUrl);
    }
}
项目:cloud-odata-java    文件:FilterToJsonTest.java   
@SuppressWarnings("unchecked")
@Test
public void testToJsonBinaryProperty() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "a eq b");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkBinary(jsonMap, "eq", null);

  StringMap<Object> left = (StringMap<Object>) jsonMap.get(LEFT);
  checkProperty(left, null, "a");

  StringMap<Object> right = (StringMap<Object>) jsonMap.get(RIGHT);
  checkProperty(right, null, "b");
}
项目:cloud-odata-java    文件:FilterToJsonTest.java   
@SuppressWarnings("unchecked")
@Test
public void testToJsonBinaryLiteral() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "'a' eq 'b'");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkBinary(jsonMap, "eq", "Edm.Boolean");

  StringMap<Object> left = (StringMap<Object>) jsonMap.get(LEFT);
  checkLiteral(left, "Edm.String", "a");

  StringMap<Object> right = (StringMap<Object>) jsonMap.get(RIGHT);
  checkLiteral(right, "Edm.String", "b");
}
项目:cloud-odata-java    文件:FilterToJsonTest.java   
@SuppressWarnings("unchecked")
@Test
public void testToJsonMember() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "Location/Country");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkMember(jsonMap, null);

  StringMap<Object> source = (StringMap<Object>) jsonMap.get(SOURCE);
  checkProperty(source, null, "Location");

  StringMap<Object> path = (StringMap<Object>) jsonMap.get(PATH);
  checkProperty(path, null, "Country");
}
项目:cloud-odata-java    文件:FilterToJsonTest.java   
@SuppressWarnings("unchecked")
@Test
public void testToJsonMember2() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "Location/Country/PostalCode");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkMember(jsonMap, null);

  StringMap<Object> source1 = (StringMap<Object>) jsonMap.get(SOURCE);
  checkMember(source1, null);

  StringMap<Object> source2 = (StringMap<Object>) source1.get(SOURCE);
  checkProperty(source2, null, "Location");

  StringMap<Object> path1 = (StringMap<Object>) source1.get(PATH);
  checkProperty(path1, null, "Country");

  StringMap<Object> path = (StringMap<Object>) jsonMap.get(PATH);
  checkProperty(path, null, "PostalCode");
}
项目:cloud-odata-java    文件:EntryJsonCreateInlineTest.java   
@Test
public void createThreeLevelsDeepInsert() throws Exception {
  String content = "{\"Name\" : \"Room 2\",\"nr_Building\" : {\"Name\" : \"Building 2\",\"nb_Rooms\" : {\"results\" : [{"
      + "\"nr_Employees\" : {\"__deferred\" : {\"uri\" : \"" + getEndpoint() + "Rooms('1')/nr_Employees\""
      + "}},\"nr_Building\" : {\"__deferred\" : {\"uri\" : \"" + getEndpoint() + "/Rooms('1')/nr_Building\""
      + "}}}]}}}";

  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);

  //Check inline building
  StringMap<?> map = getStringMap(body);
  map = (StringMap<?>) map.get("nr_Building");
  assertNotNull(map);
  assertEquals("Building 2", map.get("Name"));

  //Check inline rooms of the inline building
  map = (StringMap<?>) map.get("nb_Rooms");
  assertNotNull(map);

  ArrayList<?> results = (ArrayList<?>) map.get("results");
  assertNotNull(results);
  assertEquals(2, results.size());
}
项目:cloud-odata-java    文件:EntryJsonCreateInlineTest.java   
@Test
public void createEntryRoomWithInlineEmptyFeedArray() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":[],"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);
  checkEtag(response, "W/\"2\"");

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));

  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));
}
项目:cloud-odata-java    文件:EntryJsonCreateInlineTest.java   
@Test
public void createEntryRoomWithInlineEmptyFeedObject() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":{\"results\":[]},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);
  checkEtag(response, "W/\"2\"");

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));

  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));
}
项目:cloud-odata-java    文件:EntryJsonCreateTest.java   
@Test
public void createEntryRoomWithLink() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\","
      + "\"nr_Employees\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Employees\"}},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  assertNotNull(content);
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));
  @SuppressWarnings("unchecked")
  StringMap<Object> employeesMap = (StringMap<Object>) map.get("nr_Employees");
  assertNotNull(employeesMap);
  @SuppressWarnings("unchecked")
  StringMap<String> deferredMap = (StringMap<String>) employeesMap.get("__deferred");
  assertNotNull(deferredMap);
  assertEquals(getEndpoint() + "Rooms('104')/nr_Employees", deferredMap.get("uri"));
}
项目:cloud-odata-java    文件:EntryJsonCreateTest.java   
@Test
public void createEntryEmployee() throws Exception {
  String content = "{iVBORw0KGgoAAAANSUhEUgAAAB4AAAAwCAIAAACJ9F2zAAAAA}";

  assertNotNull(content);
  HttpResponse response = postUri("Employees", content, HttpContentType.TEXT_PLAIN, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("7", map.get("EmployeeId"));
  assertEquals("Employee 7", map.get("EmployeeName"));
  assertNull(map.get("EntryData"));
  response = callUri("Employees('7')/$value");
  checkMediaType(response, HttpContentType.TEXT_PLAIN);
}
项目:wordpress_app_android    文件:NotificationSettingsFragment.java   
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    // Update the mNoteSettings map with the new value
    if (preference instanceof CheckBoxPreference) {
        CheckBoxPreference checkBoxPreference = (CheckBoxPreference) preference;
        boolean isChecked = (Boolean) newValue;
        String key = preference.getKey();
        StringMap<Integer> typeMap = (StringMap<Integer>) mNotificationSettings.get(key);
        typeMap.put("value", (isChecked) ? 1 : 0);
        mNotificationSettings.put(key, typeMap);
        checkBoxPreference.setChecked(isChecked);
        mNotificationSettingsChanged = true;
    }
    return false;
}
项目:wordpress_app_android    文件:NotificationSettingsFragment.java   
public int compare(StringMap<?> blog1, StringMap<?> blog2) {
    String blogName1 = blog1.get("blog_name").toString();
    if (blogName1.length() == 0) {
        blogName1 = blog1.get("url").toString();
    }

    String blogName2 = blog2.get("blog_name").toString();
    if (blogName2.length() == 0) {
        blogName2 = blog2.get("url").toString();
    }

    return blogName1.compareToIgnoreCase(blogName2);
}
项目:wordpress_app_android    文件:TestUtils.java   
public static HashMap<String, Object> stringMapToHashMap(StringMap<?> stringMap) {
    HashMap<String, Object> res = new HashMap<String, Object>();
    for (String key : stringMap.keySet()) {
        Object value = stringMap.get(key);
        if (StringMap.class.isInstance(value)) {
            HashMap<String, Object> newValue = stringMapToHashMap((StringMap<?>) value);
            res.put(key, newValue);
        } else {
            res.put(key, value);
        }
    }
    return res;
}
项目:zeppelin    文件:InterpreterSetting.java   
public void setProperties(Object object) {
  if (object instanceof StringMap) {
    StringMap<String> map = (StringMap) properties;
    Properties newProperties = new Properties();
    for (String key : map.keySet()) {
      newProperties.put(key, map.get(key));
    }
    this.properties = newProperties;
  } else {
    this.properties = object;
  }
}
项目:zeppelin    文件:HeliumRestApiTest.java   
@Test
public void testGetSinglePackageInfo() throws IOException {
    String packageName = "name1";
    GetMethod get = httpGet("/helium/package/" + packageName);
    assertThat(get, isAllowed());
    Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    List<StringMap<Object>> body = (List<StringMap<Object>>) resp.get("body");

    assertEquals(body.size(), 1);
    StringMap<Object> pkg = (StringMap<Object>) body.get(0).get("pkg");
    assertEquals(pkg.get("name"), "name1");
}
项目:zeppelin    文件:HeliumRestApiTest.java   
@Test
public void testGetAllPackageConfigs() throws IOException {
    GetMethod get = httpGet("/helium/config/");
    assertThat(get, isAllowed());
    Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    StringMap<Object> body = (StringMap<Object>) resp.get("body");
    // ToDo: Apply config with POST command and check update
    assertEquals(body.size(), 0);
}
项目:zeppelin    文件:HeliumRestApiTest.java   
@Test
public void testGetPackageConfig() throws IOException {
    String packageName = "name1";
    String artifact = "artifact1";
    GetMethod get = httpGet("/helium/config/" + packageName + "/" + artifact);
    assertThat(get, isAllowed());
    Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    StringMap<Object> body = (StringMap<Object>) resp.get("body");
    assertTrue(body.containsKey("confPersisted"));
}
项目:mobile    文件:MapClientRedu.java   
@Override
protected void initTypes() {
    Type stringMapListType = new TypeToken<List<StringMap>>(){}.getType();

    super.userClass = StringMap.class;
    super.userList = stringMapListType;
    super.subjectClass =StringMap.class;
    super.subjectList = stringMapListType;
    super.enrollmentClass = StringMap.class;
    super.enrollmentList = stringMapListType;
    super.courseClass = StringMap.class;
    super.courseList = stringMapListType;
    super.spaceClass = StringMap.class;
    super.spaceList = stringMapListType;
    super.statusClass = StringMap.class;
    super.statusList = stringMapListType;
    super.environmentClass = StringMap.class;
    super.chatMessageClass = StringMap.class;
    super.chatMessageList = stringMapListType;
    super.chatClass = StringMap.class;
    super.chatList = stringMapListType;
    super.lectureClass = StringMap.class;
    super.lectureList = stringMapListType;
    super.folderClass = StringMap.class;
    super.folderList = stringMapListType;
    super.fileClass = StringMap.class;
    super.fileList = stringMapListType;
    super.progressClass = StringMap.class;
    super.progressList = stringMapListType;

}
项目:tajo    文件:TestQueryResource.java   
@Test
public void testGetAllQueries() throws Exception {
  String sessionId = generateNewSessionAndGetId();
  SubmitQueryRequest queryRequest = createNewQueryRequest("select * from lineitem");

  GetSubmitQueryResponse response = restClient.target(queriesURI)
      .request().header(tajoSessionIdHeaderName, sessionId)
      .post(Entity.entity(queryRequest, MediaType.APPLICATION_JSON),
              new GenericType<>(GetSubmitQueryResponse.class));

  assertNotNull(response);
  assertEquals(ResultCode.OK, response.getResultCode());
  String location = response.getUri().toString();
  assertTrue(location != null && !location.isEmpty());

  String queryId = location.lastIndexOf('/') >= 0?
    location.substring(location.lastIndexOf('/')+1):null;

  assertTrue(queryId != null && !queryId.isEmpty());

  Map<String, List<StringMap>> queriesMap = restClient.target(queriesURI)
      .request().get(new GenericType<>(Map.class));

  assertNotNull(queriesMap);

  List<StringMap> queryInfoList = queriesMap.get("queries");
  assertNotNull(queryInfoList);

  boolean assertQueryIdFound = false;
  for (StringMap queryInfo: queryInfoList) {
    if (queryId.equals(queryInfo.get("queryIdStr"))) {
      assertQueryIdFound = true;
    }
  }

  assertTrue(assertQueryIdFound);
}
项目:SeleniumBestPracticesBook    文件:ProductValidationTest.java   
@Test
public void testAllProductsWithApiResponse() throws Exception {
  for (StringMap productInfo : TestData.getProductsFromApi()) {
    selenium.get(TestData.getBaseUrl() + productInfo.get("url"));
    verifyProductInfo(productInfo);
  }
}
项目:SeleniumBestPracticesBook    文件:ProductValidationTest.java   
@Test
public void testAllProductsWithApiResponse() throws Exception {
  for (StringMap productInfo : TestData.getProductsFromApi()) {
    selenium.get(TestData.getBaseUrl() + productInfo.get("url"));
    verifyProductInfo(productInfo);
  }
}
项目:javaListsInMeteor    文件:MeteorListSendReceive.java   
@Override
List<MeteorCsvListItem> convert(Observable client, JSONObject result) {
    if(result.has("error")){
        // throw error
        String error = result.getString("error");
        throw Utils.IllState(this.getClass(),error);
    }
    String className = result.getString("className");
    String classNameOfListObjects = tableName;
    List<MeteorCsvListItem> ret=null;
    if(className.compareTo(classNameOfListObjects)!=0){
        Utils.prtObErrMess(this.getClass(),"className returned not equal to class of generic objects");

    }else{
        String listString = result.get("list").toString();
        if(listString==null)return null;
        @SuppressWarnings("unchecked")
        List<StringMap<M>> stringMapList = (List<StringMap<M>>)gson.fromJson(listString, List.class);
        ret = new ArrayList<MeteorCsvListItem>();
        for(StringMap<M> sm : stringMapList){
            MeteorCsvListItem m=null;
            m = getMeteorObject(gson,MeteorCsvListItem.class,sm.toString());
            if(m!=null){
                ret.add(m);
            }
        }
    }
    return ret;
}
项目:javaListsInMeteor    文件:MeteorListSendReceive.java   
private List<M> getListFromDdpMsg(JSONObject result) {
        // check to see if there is an error field
        if(result.has("error")){
            // throw error
            String error = result.getString("error");
            throw Utils.IllState(this.getClass(),error);
        }
        String className = result.getString("className");
        String classNameOfListObjects = classOFM.getName();
        List<M> ret=null;
        if(className.compareTo(classNameOfListObjects)!=0){
            Utils.prtObErrMess(this.getClass(),"className returned not equal to class of generic objects");

        }else{
            String listString = result.get("list").toString();
            if(listString==null)return null;
            @SuppressWarnings("unchecked")
            List<StringMap<M>> stringMapList = (List<StringMap<M>>)gson.fromJson(listString, List.class);
            ret = new ArrayList<M>();
            for(StringMap<M> sm : stringMapList){
                M m=null;
//              Utils.prtObMess(this.getClass(), sm.toString());
                m = getObject(sm.toString());
                if(m!=null){
                    ret.add(m);
                }
            }
        }
        return ret;
    }
项目:cloud-odata-java    文件:FilterToJsonTest.java   
@SuppressWarnings("unchecked")
@Test
public void testToJsonBinaryAdd() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "1d add 2d add 3d add 4d");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkBinary(jsonMap, "add", "Edm.Double");

  StringMap<Object> left1 = (StringMap<Object>) jsonMap.get(LEFT);
  checkBinary(left1, "add", "Edm.Double");

  StringMap<Object> left2 = (StringMap<Object>) left1.get(LEFT);
  checkBinary(left2, "add", "Edm.Double");

  StringMap<Object> literal1 = (StringMap<Object>) left2.get(LEFT);
  checkLiteral(literal1, "Edm.Double", "1");

  StringMap<Object> literal2 = (StringMap<Object>) left2.get(RIGHT);
  checkLiteral(literal2, "Edm.Double", "2");

  StringMap<Object> literal3 = (StringMap<Object>) left1.get(RIGHT);
  checkLiteral(literal3, "Edm.Double", "3");

  StringMap<Object> right1 = (StringMap<Object>) jsonMap.get(RIGHT);
  checkLiteral(right1, "Edm.Double", "4");
}
项目:cloud-odata-java    文件:FilterToJsonTest.java   
@SuppressWarnings("unchecked")
@Test
public void testToJsonMethod() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "concat('aa','b')");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkMethod(jsonMap, MethodOperator.CONCAT, "Edm.String");

  List<Object> parameter = (List<Object>) jsonMap.get(PARAMETERS);
  checkLiteral((StringMap<Object>) parameter.get(0), "Edm.String", "aa");
  checkLiteral((StringMap<Object>) parameter.get(1), "Edm.String", "b");
}
项目:cloud-odata-java    文件:FilterToJsonTest.java   
@SuppressWarnings("unchecked")
@Test
public void testToJsonUnary() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "not 'a'");
  String jsonString = toJson(expression);

  StringMap<Object> jsonMap = new Gson().fromJson(jsonString, StringMap.class);
  checkUnary(jsonMap, UnaryOperator.NOT, null);

  StringMap<Object> operand = (StringMap<Object>) jsonMap.get(OPERAND);
  checkLiteral(operand, "Edm.String", "a");
}
项目:cloud-odata-java    文件:FilterToJsonTest.java   
private void checkBinary(final StringMap<Object> binary, final String expectedOperator, final String expectedType) throws Exception {
  assertEquals(ExpressionKind.BINARY.toString(), binary.get(NODETYPE));
  assertEquals(expectedOperator, binary.get(OPERATOR));
  assertEquals(expectedType, binary.get(TYPE));
  assertNotNull(binary.get(LEFT));
  assertNotNull(binary.get(RIGHT));
}
项目:cloud-odata-java    文件:AbstractRefJsonTest.java   
public StringMap<?> getStringMap(final String body) {
  Gson gson = new Gson();
  final StringMap<?> map = gson.fromJson(body, new TypeToken<StringMap<?>>() {}.getType());
  if (map.get("d") instanceof StringMap<?>) {
    return (StringMap<?>) map.get("d");
  } else {
    return map;
  }
}
项目:cloud-odata-java    文件:EntryJsonCreateInlineTest.java   
@Test
public void createEntryRoomWithInlineFeedEmployee() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":{\"results\":[{"
      + "\"__metadata\":{"
      + "\"id\":\"" + getEndpoint() + "Employees('1')\","
      + "\"type\":\"RefScenario.Employee\","
      + "\"content_type\":\"image/jpeg\","
      + "\"media_src\":\"" + getEndpoint() + "Employees('1')/$value\","
      + "\"edit_media\":\"" + getEndpoint() + "Employees('1')/$value\"},"
      + " \"EmployeeName\": \"Walter Winter\","
      + "\"ManagerId\": \"1\","
      + "\"RoomId\": \"1\","
      + "\"TeamId\": \"1\","
      + "\"Age\": 52,"
      + "\"Location\":{\"City\":{\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"},"
      + "              \"Country\":\"Germany\"},"
      + "\"ImageUrl\": \"" + getEndpoint() + "Employees('1')/$value\"}]},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";

  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));

  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));
}
项目:cloud-odata-java    文件:EntryJsonCreateTest.java   
@Test
public void createEntryRoom() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Employees\"}},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  assertNotNull(content);
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));
  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));

  response = callUri("Rooms('104')/Seats/$value");
  body = getBody(response);
  assertEquals("4", body);
}
项目:wordpress_app_android    文件:NotificationsUtils.java   
public static void setPushNotificationSettings(Context context) {
    if (!WordPress.hasDotComToken(context)) {
        return;
    }

    String gcmToken = GCMRegistrar.getRegistrationId(context);
    if (TextUtils.isEmpty(gcmToken)) {
        return;
    }

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    String deviceID = settings.getString(WPCOM_PUSH_DEVICE_SERVER_ID, null);
    if (TextUtils.isEmpty(deviceID)) {
        AppLog.e(T.NOTIFS, "device_ID is null in preferences. Set device settings skipped.");
        return;
    }

    String settingsJson = settings.getString(WPCOM_PUSH_DEVICE_NOTIFICATION_SETTINGS, null);
    if (settingsJson == null)
        return;

    Gson gson = new Gson();
    Map<String, StringMap<String>> notificationSettings = gson.fromJson(settingsJson, HashMap.class);
    Map<String, Object> updatedSettings = new HashMap<String, Object>();
    if (notificationSettings == null)
        return;


    // Build the settings object to send back to WP.com
    StringMap<?> mutedBlogsMap = notificationSettings.get("muted_blogs");
    StringMap<?> muteUntilMap = notificationSettings.get("mute_until");
    ArrayList<StringMap<Double>> blogsList = (ArrayList<StringMap<Double>>) mutedBlogsMap.get("value");
    notificationSettings.remove("muted_blogs");
    notificationSettings.remove("mute_until");

    for (Map.Entry<String, StringMap<String>> entry : notificationSettings.entrySet())
    {
        StringMap<String> setting = entry.getValue();
        updatedSettings.put(entry.getKey(), setting.get("value"));
    }

    if (muteUntilMap != null && muteUntilMap.get("value") != null) {
        updatedSettings.put("mute_until", muteUntilMap.get("value"));
    }

    ArrayList<StringMap<Double>> mutedBlogsList = new ArrayList<StringMap<Double>>();
    for (StringMap<Double> userBlog : blogsList) {
        if (MapUtils.getMapBool(userBlog, "value")) {
            mutedBlogsList.add(userBlog);
        }
    }

    if (updatedSettings.size() == 0 && mutedBlogsList.size() == 0)
        return;

    updatedSettings.put("muted_blogs", mutedBlogsList); //If muted blogs list is unchanged we can even skip this assignment.

    Map<String, String> contentStruct = new HashMap<String, String>();
    contentStruct.put("device_token", gcmToken);
    contentStruct.put("device_family", "android");
    contentStruct.put("app_secret_key", NotificationsUtils.getAppPushNotificationsName());
    contentStruct.put("settings", gson.toJson(updatedSettings));
    WordPress.getRestClientUtils().post("/device/"+deviceID, contentStruct, null, null, null);
}
项目:biblio    文件:BulkBookLoad.java   
public Map<String, List<StringMap>> getResults() {
    return results;
}
项目:SeleniumBestPracticesBook    文件:TestData.java   
public static List<StringMap> getProductsFromApi(){
  return JSONFixtures.parseJsonFixtures();
}
项目:SeleniumBestPracticesBook    文件:JSONFixtures.java   
public static List<StringMap> parseJsonFixtures(){
  return ((List<StringMap>) new Gson().fromJson(json, LinkedList.class));
}