本文整理匯總了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();
}
示例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();
}
示例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;
}
}
}