本文整理汇总了Java中com.google.gson.internal.StringMap类的典型用法代码示例。如果您正苦于以下问题:Java StringMap类的具体用法?Java StringMap怎么用?Java StringMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringMap类属于com.google.gson.internal包,在下文中一共展示了StringMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPreferenceChange
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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;
}
示例2: enabledButtonClick
import com.google.gson.internal.StringMap; //导入依赖的package包/类
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;
}
}
示例3: fetchRemoteControlData
import com.google.gson.internal.StringMap; //导入依赖的package包/类
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);
}
}
示例4: castIt
import com.google.gson.internal.StringMap; //导入依赖的package包/类
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;
}
示例5: testGetAllEnabledPackageInfo
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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");
}
示例6: testEnableDisablePackage
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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);
}
示例7: main
import com.google.gson.internal.StringMap; //导入依赖的package包/类
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);
}
}
示例8: testToJsonBinaryProperty
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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");
}
示例9: testToJsonBinaryLiteral
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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");
}
示例10: testToJsonMember
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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");
}
示例11: testToJsonMember2
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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");
}
示例12: createThreeLevelsDeepInsert
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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());
}
示例13: createEntryRoomWithInlineEmptyFeedArray
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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"));
}
示例14: createEntryRoomWithInlineEmptyFeedObject
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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"));
}
示例15: createEntryRoomWithLink
import com.google.gson.internal.StringMap; //导入依赖的package包/类
@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"));
}