当前位置: 首页>>代码示例>>Java>>正文


Java JsonWriter.value方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:24,代码来源:SupportUtils.java

示例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());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:TypeAdapters.java

示例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());
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:9,代码来源:FileAdapter.java

示例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));
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:DateTypeAdapter.java

示例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();
}
 
开发者ID:sap-nocops,项目名称:Jerkoff,代码行数:9,代码来源:ObjectTypeAdapterFactory.java

示例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));
  }
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:9,代码来源:ApiClient.java

示例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();
  }
}
 
开发者ID:rockscript,项目名称:rockscript,代码行数:9,代码来源:Engine.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:DateTypeAdapter.java

示例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());
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:TypeAdapters.java

示例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
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:47,代码来源:ReportExporter.java

示例11: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, Number value) throws IOException {
  out.value(value);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:TypeAdapters.java

示例12: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, UserId value) throws IOException {
    out.value(value.toString());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:5,代码来源:UserIdTypeAdapter.java

示例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());
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:4,代码来源:TypeAdapters.java

示例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));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:SqlDateTypeAdapter.java


注:本文中的com.google.gson.stream.JsonWriter.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。