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


Java JsonGenerator.writeBooleanField方法代码示例

本文整理汇总了Java中org.codehaus.jackson.JsonGenerator.writeBooleanField方法的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerator.writeBooleanField方法的具体用法?Java JsonGenerator.writeBooleanField怎么用?Java JsonGenerator.writeBooleanField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.jackson.JsonGenerator的用法示例。


在下文中一共展示了JsonGenerator.writeBooleanField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dumpConfiguration

import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
 *  Writes out all the parameters and their properties (final and resource) to
 *  the given {@link Writer}
 *  The format of the output would be 
 *  { "properties" : [ {key1,value1,key1.isFinal,key1.resource}, {key2,value2,
 *  key2.isFinal,key2.resource}... ] } 
 *  It does not output the parameters of the configuration object which is 
 *  loaded from an input stream.
 * @param out the Writer to write to
 * @throws IOException
 */
public static void dumpConfiguration(Configuration config,
    Writer out) throws IOException {
  JsonFactory dumpFactory = new JsonFactory();
  JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
  dumpGenerator.writeStartObject();
  dumpGenerator.writeFieldName("properties");
  dumpGenerator.writeStartArray();
  dumpGenerator.flush();
  synchronized (config) {
    for (Map.Entry<Object,Object> item: config.getProps().entrySet()) {
      dumpGenerator.writeStartObject();
      dumpGenerator.writeStringField("key", (String) item.getKey());
      dumpGenerator.writeStringField("value",
                                     config.get((String) item.getKey()));
      dumpGenerator.writeBooleanField("isFinal",
                                      config.finalParameters.contains(item.getKey()));
      dumpGenerator.writeStringField("resource",
                                     config.updatingResource.get(item.getKey()));
      dumpGenerator.writeEndObject();
    }
  }
  dumpGenerator.writeEndArray();
  dumpGenerator.writeEndObject();
  dumpGenerator.flush();
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:37,代码来源:Configuration.java

示例2: dumpConfiguration

import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
 *  Writes out all the parameters and their properties (final and resource) to
 *  the given {@link Writer}
 *  The format of the output would be 
 *  { "properties" : [ {key1,value1,key1.isFinal,key1.resource}, {key2,value2,
 *  key2.isFinal,key2.resource}... ] } 
 *  It does not output the parameters of the configuration object which is 
 *  loaded from an input stream.
 * @param out the Writer to write to
 * @throws IOException
 */
public static void dumpConfiguration(Configuration config,
    Writer out) throws IOException {
  JsonFactory dumpFactory = new JsonFactory();
  JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
  dumpGenerator.writeStartObject();
  dumpGenerator.writeFieldName("properties");
  dumpGenerator.writeStartArray();
  dumpGenerator.flush();
  synchronized (config) {
    for (Map.Entry<Object,Object> item: config.getProps().entrySet()) {
      dumpGenerator.writeStartObject();
      dumpGenerator.writeStringField("key", (String) item.getKey());
      dumpGenerator.writeStringField("value", 
                                     config.get((String) item.getKey()));
      dumpGenerator.writeBooleanField("isFinal",
                                      config.finalParameters.contains(item.getKey()));
      String[] resources = config.updatingResource.get(item.getKey());
      String resource = UNKNOWN_RESOURCE;
      if(resources != null && resources.length > 0) {
        resource = resources[0];
      }
      dumpGenerator.writeStringField("resource", resource);
      dumpGenerator.writeEndObject();
    }
  }
  dumpGenerator.writeEndArray();
  dumpGenerator.writeEndObject();
  dumpGenerator.flush();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:41,代码来源:Configuration.java

示例3: encodeColumn

import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
 * Encode the column properly in Json.
 *
 * @param col the column data we are encoding
 * @param jdbcType the column type
 * @param jg handle to the JsonGenerator
 * @throws IOException if a JSON encodng error occurs
 */
private void encodeColumn(DownstreamColumnData col, int jdbcType, JsonGenerator jg) throws IOException {
    if (col.checkForNULL()) {
        jg.writeNullField(col.getBDName());
    } else {
        switch (jdbcType) {

        case java.sql.Types.BOOLEAN:
        case java.sql.Types.BIT:
            jg.writeBooleanField(col.getBDName(), col.asBoolean());
            break;
        case java.sql.Types.SMALLINT:
        case java.sql.Types.TINYINT:
        case java.sql.Types.INTEGER:
            jg.writeNumberField(col.getBDName(), col.asInteger());
            break;
        case java.sql.Types.BIGINT:
            jg.writeNumberField(col.getBDName(), col.asLong());
            break;
        case java.sql.Types.CHAR:
        case java.sql.Types.VARCHAR:
        case java.sql.Types.LONGVARCHAR:
        case java.sql.Types.CLOB:
            jg.writeStringField(col.getBDName(), col.asString());
            break;
        case java.sql.Types.NCHAR:
        case java.sql.Types.NVARCHAR:
        case java.sql.Types.LONGNVARCHAR:
        case java.sql.Types.NCLOB:
            jg.writeStringField(col.getBDName(), col.asString());
            break;
        case java.sql.Types.BLOB:
        case java.sql.Types.BINARY:
        case java.sql.Types.LONGVARBINARY:
        case java.sql.Types.VARBINARY:
            jg.writeBinaryField(col.getBDName(), col.asBytes());
            break;
        case java.sql.Types.REAL: // JDBC says 7 digits of mantisa
            jg.writeNumberField(col.getBDName(), col.asFloat());
            break;
        case java.sql.Types.FLOAT: // JDBC says 15 digits of mantisa
        case java.sql.Types.DOUBLE:
            jg.writeNumberField(col.getBDName(), col.asDouble());
            break;
        case java.sql.Types.NUMERIC:
        case java.sql.Types.DECIMAL:
            jg.writeNumberField(col.getBDName(), col.asBigDecimal());
            break;
        case java.sql.Types.DATE:
        case java.sql.Types.TIME:
        case java.sql.Types.TIMESTAMP:
            jg.writeStringField(col.getBDName(), col.asString());
            break;
        case java.sql.Types.DATALINK:
        case java.sql.Types.DISTINCT:
        case java.sql.Types.JAVA_OBJECT:
        case java.sql.Types.NULL:
        case java.sql.Types.ROWID:
        case java.sql.Types.SQLXML:
        case java.sql.Types.STRUCT:
        case java.sql.Types.ARRAY:
        case java.sql.Types.OTHER:
        case java.sql.Types.REF:
        default:
            jg.writeStringField(col.getBDName(), "unsupported");
            break;
        }
    }
}
 
开发者ID:oracle,项目名称:bdglue,代码行数:77,代码来源:JsonEncoder.java


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