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


Java Feature类代码示例

本文整理汇总了Java中com.fasterxml.jackson.core.JsonGenerator.Feature的典型用法代码示例。如果您正苦于以下问题:Java Feature类的具体用法?Java Feature怎么用?Java Feature使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: serialize

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
@Override
public void serialize(Map<FlowEntryTuple, SwitchPortStatistics> portStats, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
    jsonGenerator.configure(Feature.WRITE_NUMBERS_AS_STRINGS,true);

    jsonGenerator.writeStartObject();


    for(Map.Entry<FlowEntryTuple,SwitchPortStatistics> portStatsEntry : portStats.entrySet()){
        jsonGenerator.writeStringField("srcAddr",portStatsEntry.getKey().getSrcAddr().toString());
        jsonGenerator.writeStringField("dstAddr",portStatsEntry.getKey().getDstAddr().toString());
        jsonGenerator.writeStringField("srcOFPort",portStatsEntry.getKey().getSrcPort().toString());
        jsonGenerator.writeStringField("dstOFPort",portStatsEntry.getKey().getDstPort().toString());
        jsonGenerator.writeStringField("prot", String.valueOf(portStatsEntry.getKey().getProt()));
        jsonGenerator.writeStringField("tos", String.valueOf(portStatsEntry.getKey().getTos()));
        jsonGenerator.writeStringField("input",String.valueOf(portStatsEntry.getKey().getInput()));
        jsonGenerator.writeStringField("pkts", String.valueOf(portStatsEntry.getValue().getPkts()));
        jsonGenerator.writeStringField("octs", String.valueOf(portStatsEntry.getValue().getOcts()));
        jsonGenerator.writeStringField("first", String.valueOf(portStatsEntry.getValue().getFirst()));
        jsonGenerator.writeStringField("last", String.valueOf(portStatsEntry.getValue().getLast()));
        jsonGenerator.writeStringField("tcpFlags", String.valueOf(portStatsEntry.getValue().getTcpflags()));
        jsonGenerator.writeStringField("drops", String.valueOf(portStatsEntry.getValue().getDrops()));
    }
    jsonGenerator.writeEndObject();
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:25,代码来源:FlowStatisticsSerializer.java

示例2: init

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
private void init() throws IOException {
	JsonFactory factory = new JsonFactory();
	factory.configure(Feature.AUTO_CLOSE_TARGET, false);
	generator = factory.createGenerator(writer);

	if (prettyPrint) {
		if (prettyPrinter == null) {
			prettyPrinter = new JCalPrettyPrinter();
		}
		generator.setPrettyPrinter(prettyPrinter);
	}

	if (wrapInArray) {
		generator.writeStartArray();
	}
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:17,代码来源:JCalRawWriter.java

示例3: _writePPFieldName

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
protected final void _writePPFieldName(SerializableString paramSerializableString, boolean paramBoolean)
{
  if (paramBoolean)
    this._cfgPrettyPrinter.writeObjectEntrySeparator(this);
  else
    this._cfgPrettyPrinter.beforeObjectEntries(this);
  char[] arrayOfChar1 = paramSerializableString.asQuotedChars();
  if (isEnabled(JsonGenerator.Feature.QUOTE_FIELD_NAMES))
  {
    if (this._outputTail >= this._outputEnd)
      _flushBuffer();
    char[] arrayOfChar2 = this._outputBuffer;
    int i = this._outputTail;
    this._outputTail = (i + 1);
    arrayOfChar2[i] = '"';
    writeRaw(arrayOfChar1, 0, arrayOfChar1.length);
    if (this._outputTail >= this._outputEnd)
      _flushBuffer();
    char[] arrayOfChar3 = this._outputBuffer;
    int j = this._outputTail;
    this._outputTail = (j + 1);
    arrayOfChar3[j] = '"';
    return;
  }
  writeRaw(arrayOfChar1, 0, arrayOfChar1.length);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:27,代码来源:WriterBasedJsonGenerator.java

示例4: close

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
public final void close()
{
  super.close();
  if ((this._outputBuffer != null) && (isEnabled(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT)))
    while (true)
    {
      JsonWriteContext localJsonWriteContext = getOutputContext();
      if (localJsonWriteContext.inArray())
      {
        writeEndArray();
      }
      else
      {
        if (!localJsonWriteContext.inObject())
          break;
        writeEndObject();
      }
    }
  _flushBuffer();
  if (this._writer != null)
    if ((this._ioContext.isResourceManaged()) || (isEnabled(JsonGenerator.Feature.AUTO_CLOSE_TARGET)))
      this._writer.close();
    else if (isEnabled(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM))
      this._writer.flush();
  _releaseBuffers();
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:27,代码来源:WriterBasedJsonGenerator.java

示例5: close

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
public void close()
{
  super.close();
  if ((this._outputBuffer != null) && (isEnabled(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT)))
    while (true)
    {
      JsonWriteContext localJsonWriteContext = getOutputContext();
      if (localJsonWriteContext.inArray())
      {
        writeEndArray();
      }
      else
      {
        if (!localJsonWriteContext.inObject())
          break;
        writeEndObject();
      }
    }
  _flushBuffer();
  if (this._outputStream != null)
    if ((this._ioContext.isResourceManaged()) || (isEnabled(JsonGenerator.Feature.AUTO_CLOSE_TARGET)))
      this._outputStream.close();
    else if (isEnabled(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM))
      this._outputStream.flush();
  _releaseBuffers();
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:27,代码来源:UTF8JsonGenerator.java

示例6: generateJson

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
private static String generateJson(Object o, boolean prettyPrint, boolean escapeNonASCII) {
    try {
        StringWriter sw = new StringWriter();
        JsonGenerator jgen = new JsonFactory(mapper()).createGenerator(sw);
        if (prettyPrint) {
            jgen.setPrettyPrinter(new DefaultPrettyPrinter());
        }
        if (escapeNonASCII) {
            jgen.enable(Feature.ESCAPE_NON_ASCII);
        }
        mapper().writeValue(jgen, o);
        sw.flush();
        return sw.toString();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:hunatika615,项目名称:egg-android,代码行数:18,代码来源:Json.java

示例7: writeFile

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
/**
 * Serialize parquet metadata to json and write to a file
 * @param parquetTableMetadata
 * @param p
 * @throws IOException
 */
private void writeFile(ParquetTableMetadata_v1 parquetTableMetadata, Path p) throws IOException {
  JsonFactory jsonFactory = new JsonFactory();
  jsonFactory.configure(Feature.AUTO_CLOSE_TARGET, false);
  jsonFactory.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false);
  ObjectMapper mapper = new ObjectMapper(jsonFactory);
  FSDataOutputStream os = fs.create(p);
  mapper.writerWithDefaultPrettyPrinter().writeValue(os, parquetTableMetadata);
  os.flush();
  os.close();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:Metadata.java

示例8: testJson

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
@Test
public void testJson() throws Exception {
    JsonDataSource.Builder builder = JsonDataSource.builder();
    builder.getFactory().enable(Feature.WRITE_NUMBERS_AS_STRINGS);
    DataSource dataSource = builder.setSink(sink).setSource(source).build();
    fileSerializeComprehensive(dataSource);
    fileSerializeKComprehensive(dataSource);
    //fileSerializeCommonTypes(dataSource);
}
 
开发者ID:dumptruckman,项目名称:dtmlibs,代码行数:10,代码来源:SerializableConfigTest.java

示例9: enableDisableJSONGeneratorFeature

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的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);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:8,代码来源:PdxToJSON.java

示例10: serialize

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
@Override
public void serialize(OFFlowModMap fmm, JsonGenerator jGen, SerializerProvider serializer)
		throws IOException, JsonProcessingException {
	
       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

	if (fmm == null) {
		jGen.writeStartObject();
		jGen.writeString("No flows have been added to the Static Flow Pusher.");
		jGen.writeEndObject();
		return;
	}

	Map<String, Map<String, OFFlowMod>> theMap = fmm.getMap();

	jGen.writeStartObject();
	if (theMap.keySet() != null) {
		for (String dpid : theMap.keySet()) {
			if (theMap.get(dpid) != null) {
				jGen.writeArrayFieldStart(dpid);
				for (String name : theMap.get(dpid).keySet()) {
					jGen.writeStartObject();
					jGen.writeFieldName(name);
					OFFlowModSerializer.serializeFlowMod(jGen, theMap.get(dpid).get(name));
					jGen.writeEndObject();
				}    
				jGen.writeEndArray();
			}
		}
	}
	jGen.writeEndObject();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:33,代码来源:OFFlowModMapSerializer.java

示例11: serialize

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
@Override
public void serialize(SwitchPortBandwidth spb, JsonGenerator jGen, SerializerProvider serializer) throws IOException, JsonProcessingException {
	jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true);

	jGen.writeStartObject();
	jGen.writeStringField("dpid", spb.getSwitchId().toString());
	jGen.writeStringField("port", spb.getSwitchPort().toString());
	jGen.writeStringField("updated", new Date(spb.getUpdateTime()).toString());
	jGen.writeStringField("bits-per-second-rx", spb.getBitsPerSecondRx().getBigInteger().toString());
	jGen.writeStringField("bits-per-second-tx", spb.getBitsPerSecondTx().getBigInteger().toString());
	jGen.writeEndObject();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:13,代码来源:SwitchPortBandwidthSerializer.java

示例12: serialize

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
@Override
public void serialize(OFFlowModMap fmm, JsonGenerator jGen, SerializerProvider serializer)
		throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

	if (fmm == null) {
		jGen.writeStartObject();
		jGen.writeString("No flows have been added to the Static Flow Pusher.");
		jGen.writeEndObject();
		return;
	}

	Map<String, Map<String, OFFlowMod>> theMap = fmm.getMap();

	jGen.writeStartObject();
	if (theMap.keySet() != null) {
		for (String dpid : theMap.keySet()) {
			if (theMap.get(dpid) != null) {
				jGen.writeArrayFieldStart(dpid);
				for (String name : theMap.get(dpid).keySet()) {
					jGen.writeStartObject();
					jGen.writeFieldName(name);
					OFFlowModSerializer.serializeFlowMod(jGen, theMap.get(dpid).get(name));
					jGen.writeEndObject();
				}
				jGen.writeEndArray();
			}
		}
	}
	jGen.writeEndObject();
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:33,代码来源:OFFlowModMapSerializer.java

示例13: writeFile

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
/**
 * Serialize parquet metadata to json and write to a file
 *
 * @param parquetTableMetadata
 * @param p
 * @throws IOException
 */
private void writeFile(ParquetTableMetadata_v3 parquetTableMetadata, Path p) throws IOException {
  JsonFactory jsonFactory = new JsonFactory();
  jsonFactory.configure(Feature.AUTO_CLOSE_TARGET, false);
  jsonFactory.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false);
  ObjectMapper mapper = new ObjectMapper(jsonFactory);
  SimpleModule module = new SimpleModule();
  module.addSerializer(ColumnMetadata_v3.class, new ColumnMetadata_v3.Serializer());
  mapper.registerModule(module);
  FSDataOutputStream os = fs.create(p);
  mapper.writerWithDefaultPrettyPrinter().writeValue(os, parquetTableMetadata);
  os.flush();
  os.close();
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:21,代码来源:Metadata.java

示例14: ReactScriptEngine

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
protected ReactScriptEngine(ScriptEngineFactory scriptEngineFactory, ObjectPool<JavascriptEngine> enginePool, boolean reloadScripts, OsgiServiceFinder finder,
    DynamicClassLoaderManager dynamicClassLoaderManager) {
  super(scriptEngineFactory);

  this.mapper = new ObjectMapper();
  mapper.configure(Feature.IGNORE_UNKNOWN, true);

  this.enginePool = enginePool;
  this.reloadScripts = reloadScripts;
  this.finder = finder;
  this.dynamicClassLoaderManager = dynamicClassLoaderManager;
}
 
开发者ID:sinnerschrader,项目名称:aem-react,代码行数:13,代码来源:ReactScriptEngine.java

示例15: createJsonGenerator

import com.fasterxml.jackson.core.JsonGenerator.Feature; //导入依赖的package包/类
private JsonGenerator createJsonGenerator(OutputStream baos) throws IOException {
    JsonGenerator result = JSON_FACTORY.createGenerator(baos, UTF8);

    result.configure(Feature.QUOTE_NON_NUMERIC_NUMBERS, false);
    result.configure(Feature.AUTO_CLOSE_TARGET, false);

    if (this.logger.isDebugEnabled()) {
        result.setPrettyPrinter(new DefaultPrettyPrinter());
    }

    return result;
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:13,代码来源:AbstractJsonSerializer.java


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