本文整理汇总了Java中com.google.gson.stream.JsonWriter.value方法的典型用法代码示例。如果您正苦于以下问题:Java JsonWriter.value方法的具体用法?Java JsonWriter.value怎么用?Java JsonWriter.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gson.stream.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.value方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writePrimitiveOrItsBox
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public static void writePrimitiveOrItsBox(JsonWriter writer, Class<?> type, Object value) throws IOException {
if (type == void.class || type == Void.class) {
writer.value("\"\"");
} else if (type == boolean.class || type == Boolean.class) {
writer.value(((Boolean) value).booleanValue());
} else if (type == byte.class || type == Byte.class) {
writer.value(((Byte) value).byteValue());
} else if (type == short.class || type == Short.class) {
writer.value(((Short) value).shortValue());
} else if (type == int.class || type == Integer.class) {
writer.value(((Integer) value).intValue());
} else if (type == long.class || type == Long.class) {
writer.value(((Long) value).longValue());
} else if (type == char.class || type == Character.class) {
writer.value((Character) value);
} else if (type == float.class || type == Float.class) {
writer.value(((Float) value).floatValue());
} else if (type == double.class || type == Double.class) {
writer.value(((Double) value).doubleValue());
} else {
throw new IllegalStateException();
}
}
示例2: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, Binary value) throws IOException {
if (out instanceof BsonWriter) {
BINARY_ADAPTER.write(out, value.value());
} else {
out.value(value.toString());
}
}
示例3: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter writer, File value) throws IOException {
if (value == null) {
writer.nullValue();
return;
}
writer.value(value.getAbsolutePath());
}
示例4: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public synchronized void write(JsonWriter out, Date value) throws IOException {
if (value == null) {
out.nullValue();
} else {
out.value(this.enUsFormat.format(value));
}
}
示例5: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, T value) throws IOException {
out.beginObject();
out.name("class");
out.value(value.getClass().getName());
out.name("value");
delegate.write(out, value);
out.endObject();
}
示例6: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, LocalDate date) throws IOException {
if (date == null) {
out.nullValue();
} else {
out.value(formatter.print(date));
}
}
示例7: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, Instant value) throws IOException {
if (value!=null) {
out.value(ISO_FORMATTER.format(value));
} else {
out.nullValue();
}
}
示例8: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override public synchronized void write(JsonWriter out, Date value) throws IOException {
if (value == null) {
out.nullValue();
return;
}
String dateFormatAsString = enUsFormat.format(value);
out.value(dateFormatAsString);
}
示例9: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, StringBuilder value) throws IOException {
out.value(value == null ? null : value.toString());
}
示例10: processCosts
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
private static void processCosts(Connection connection, JsonWriter writer)
throws IOException, SQLException {
writer.name("costs").beginObject();
PreparedStatement stmt = connection.prepareStatement(
"select year, type, sum(cost) from "
+ "(SELECT c.cost, YEAR(DATEADD('SECOND', e.start/ 1000 , DATE '1970-01-01')) as year, "
+ "e.type FROM ENCOUNTER e, CLAIM c where e.id = c.encounter_id) group by year, type "
+ "order by year asc");
ResultSet rs = stmt.executeQuery();
Table<Integer, String, BigDecimal> table = HashBasedTable.create();
int firstYear = 0;
int lastYear = 0;
while (rs.next()) {
int year = rs.getInt(1);
String type = rs.getString(2);
BigDecimal total = rs.getBigDecimal(3);
if (firstYear == 0) {
firstYear = year;
}
lastYear = year;
table.put(year, type, total);
}
writer.name("first_year").value(firstYear);
for (String encType : table.columnKeySet()) {
writer.name(encType).beginArray();
for (int y = firstYear; y <= lastYear; y++) {
BigDecimal count = table.get(y, encType);
if (count == null) {
count = BigDecimal.ZERO;
}
writer.value(count);
}
writer.endArray(); // encType
}
writer.endObject(); // costs
}
示例11: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, Number value) throws IOException {
out.value(value);
}
示例12: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, UserId value) throws IOException {
out.value(value.toString());
}
示例13: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override public void write(JsonWriter out, Boolean value) throws IOException {
out.value(value == null ? "null" : value.toString());
}
示例14: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public synchronized void write(JsonWriter out, java.sql.Date value) throws IOException {
out.value(value == null ? null : format.format(value));
}