本文整理汇总了Java中org.codehaus.jackson.impl.DefaultPrettyPrinter类的典型用法代码示例。如果您正苦于以下问题:Java DefaultPrettyPrinter类的具体用法?Java DefaultPrettyPrinter怎么用?Java DefaultPrettyPrinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultPrettyPrinter类属于org.codehaus.jackson.impl包,在下文中一共展示了DefaultPrettyPrinter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createJsonGenerator
import org.codehaus.jackson.impl.DefaultPrettyPrinter; //导入依赖的package包/类
/**
* This is a helper method which creates a JsonGenerator instance, for writing
* the state of the ClusterManager to the state file. The JsonGenerator
* instance writes to a compressed file if we have the compression flag
* turned on.
*
* @param conf The CoronaConf instance to be used
* @return The JsonGenerator instance to be used
* @throws IOException
*/
public static JsonGenerator createJsonGenerator(CoronaConf conf)
throws IOException {
OutputStream outputStream = new FileOutputStream(conf.getCMStateFile());
if (conf.getCMCompressStateFlag()) {
outputStream = new GZIPOutputStream(outputStream);
}
ObjectMapper mapper = new ObjectMapper();
JsonGenerator jsonGenerator =
new JsonFactory().createJsonGenerator(outputStream, JsonEncoding.UTF8);
jsonGenerator.setCodec(mapper);
if (!conf.getCMCompressStateFlag()) {
jsonGenerator.setPrettyPrinter(new DefaultPrettyPrinter());
}
return jsonGenerator;
}
示例2: enableDisableJSONGeneratorFeature
import org.codehaus.jackson.impl.DefaultPrettyPrinter; //导入依赖的package包/类
private void enableDisableJSONGeneratorFeature(JsonGenerator jg) {
jg.enable(Feature.ESCAPE_NON_ASCII);
jg.disable(Feature.AUTO_CLOSE_TARGET);
jg.setPrettyPrinter(new DefaultPrettyPrinter());
if(PDXTOJJSON_UNQUOTEFIELDNAMES)
jg.disable(Feature.QUOTE_FIELD_NAMES);
}
示例3: JSONMeasurementsExporter
import org.codehaus.jackson.impl.DefaultPrettyPrinter; //导入依赖的package包/类
public JSONMeasurementsExporter(OutputStream os) throws IOException
{
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
g = factory.createJsonGenerator(bw);
g.setPrettyPrinter(new DefaultPrettyPrinter());
}
示例4: serialize
import org.codehaus.jackson.impl.DefaultPrettyPrinter; //导入依赖的package包/类
public void serialize(Object obj, Writer out)
{
try
{
JsonGenerator gen = this.factory.createJsonGenerator(out);
gen.setPrettyPrinter(new DefaultPrettyPrinter());
gen.writeObject(obj);
gen.flush();
out.flush();
}
catch (IOException e)
{
throw new JsonException(e);
}
}