javax.json.Json.createGeneratorFactory()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中javax.json.Json.createGeneratorFactory()方法的一些代码示例,展示了Json.createGeneratorFactory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.createGeneratorFactory()方法的具体详情如下:
包路径:javax.json.Json
类名称:Json
方法名:createGeneratorFactory

Json.createGeneratorFactory介绍

[英]Creates a generator factory for creating JsonGenerator objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.
[中]创建用于创建JsonGenerator对象的生成器工厂。工厂使用特定于提供程序的配置属性的指定映射进行配置。提供程序实现应忽略映射中指定的任何不受支持的配置属性。

代码示例

代码示例来源:origin: org.jboss.logmanager/jboss-logmanager

/**
 * Creates a new JSON formatter.
 *
 * @param keyOverrides a string representation of a map to override keys
 *
 * @see PropertyValues#stringToEnumMap(Class, String)
 */
public JsonFormatter(final String keyOverrides) {
  super(keyOverrides);
  config = new HashMap<>();
  factory = Json.createGeneratorFactory(config);
}

代码示例来源:origin: org.jboss.logmanager/jboss-logmanager

/**
 * Creates a new JSON formatter.
 *
 * @param keyOverrides a map of overrides for the default keys
 */
public JsonFormatter(final Map<Key, String> keyOverrides) {
  super(keyOverrides);
  config = new HashMap<>();
  factory = Json.createGeneratorFactory(config);
}

代码示例来源:origin: org.jboss.logmanager/jboss-logmanager

/**
 * Creates a new JSON formatter.
 */
public JsonFormatter() {
  config = new HashMap<>();
  factory = Json.createGeneratorFactory(config);
}

代码示例来源:origin: net.iot-solutions.graphdb/jcypher

public static JsonGeneratorFactory getPrettyGeneratorFactory() {
  if (prettyGeneratorFactory == null) {
    HashMap<String, Object> prettyConfigMap = new HashMap<String, Object>();
    prettyConfigMap.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
    prettyGeneratorFactory = Json.createGeneratorFactory(prettyConfigMap);
  }
  return prettyGeneratorFactory;
}

代码示例来源:origin: Wolfgang-Schuetzelhofer/jcypher

public static JsonGeneratorFactory getPrettyGeneratorFactory() {
  if (prettyGeneratorFactory == null) {
    HashMap<String, Object> prettyConfigMap = new HashMap<String, Object>();
    prettyConfigMap.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
    prettyGeneratorFactory = Json.createGeneratorFactory(prettyConfigMap);
  }
  return prettyGeneratorFactory;
}

代码示例来源:origin: org.jboss.logmanager/jboss-logmanager

/**
 * Turns on or off pretty printing.
 *
 * @param prettyPrint {@code true} to turn on pretty printing or {@code false} to turn it off
 */
public void setPrettyPrint(final boolean prettyPrint) {
  synchronized (config) {
    if (prettyPrint) {
      config.put(JsonGenerator.PRETTY_PRINTING, true);
    } else {
      config.remove(JsonGenerator.PRETTY_PRINTING);
    }
    factory = Json.createGeneratorFactory(config);
  }
}

代码示例来源:origin: org.realityforge.replicant/replicant-server

public void postConstruct()
{
 final HashMap<String, Object> config = new HashMap<>();
 config.put( JsonGenerator.PRETTY_PRINTING, true );
 _factory = Json.createGeneratorFactory( config );
 try
 {
  _datatypeFactory = DatatypeFactory.newInstance();
 }
 catch ( final DatatypeConfigurationException dtce )
 {
  throw new IllegalStateException( "Unable to initialize DatatypeFactory", dtce );
 }
}

代码示例来源:origin: org.realityforge.replicant/replicant-shared-ee

public void postConstruct()
{
 final HashMap<String, Object> config = new HashMap<>();
 config.put( JsonGenerator.PRETTY_PRINTING, true );
 _factory = Json.createGeneratorFactory( config );
 try
 {
  _datatypeFactory = DatatypeFactory.newInstance();
 }
 catch ( final DatatypeConfigurationException dtce )
 {
  throw new IllegalStateException( "Unable to initialize DatatypeFactory", dtce );
 }
}

代码示例来源:origin: dsukhoroslov/bagri

/**
 * {@inheritDoc}
 */
public void init(Properties properties) {
  logger.trace("init; got properties: {}", properties);
  if (properties != null) {
    Map<String, Object> params = new HashMap<>(properties.size());
    for (Map.Entry e: properties.entrySet()) {
      params.put(e.getKey().toString(), e.getValue());
    }
    factory = Json.createGeneratorFactory(params);
  }
}

代码示例来源:origin: dcm4che/dcm4che

private JsonGenerator createGenerator(OutputStream out) {
  Map<String, ?> conf = new HashMap<String, Object>(2);
  if (indent)
    conf.put(JsonGenerator.PRETTY_PRINTING, null);
  return Json.createGeneratorFactory(conf).createGenerator(out);
}

代码示例来源:origin: org.ovirt.engine.api/metamodel-runtime

private void init(Writer writer, boolean indent) {
  Map<String, Object> configuration = new HashMap<>();
  if (indent) {
    configuration.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
  }
  JsonGeneratorFactory factory = Json.createGeneratorFactory(configuration);
  generator = factory.createGenerator(writer);
}

代码示例来源:origin: net.shibboleth.idp/idp-consent

/** Constructor. */
public CollectionSerializer() {
  generatorFactory = Json.createGeneratorFactory(null);
  readerFactory = Json.createReaderFactory(null);
}

代码示例来源:origin: org.dcm4che.tool/dcm4che-tool-dcm2json

private JsonGenerator createGenerator(OutputStream out) {
  Map<String, ?> conf = new HashMap<String, Object>(2);
  if (indent)
    conf.put(JsonGenerator.PRETTY_PRINTING, null);
  return Json.createGeneratorFactory(conf).createGenerator(out);
}

代码示例来源:origin: org.opendaylight.aaa/aaa-authn-idpmapping

public String dumpJson(Object obj) {
  Map<String, Object> properties = new HashMap<String, Object>(1);
  properties.put(JsonGenerator.PRETTY_PRINTING, true);
  JsonGeneratorFactory generatorFactory = Json.createGeneratorFactory(properties);
  StringWriter stringWriter = new StringWriter();
  JsonGenerator generator = generatorFactory.createGenerator(stringWriter);
  dumpJsonItem(generator, obj);
  generator.close();
  return stringWriter.toString();
}

代码示例来源:origin: cambecc/grib2json

private JsonGenerator newJsonGenerator(Options options) throws IOException {
  JsonGeneratorFactory jgf =
    Json.createGeneratorFactory(
      options.isCompactFormat() ?
        null :
        singletonMap(JsonGenerator.PRETTY_PRINTING, true));
  OutputStream output = options.getOutput() != null ?
    new BufferedOutputStream(new FileOutputStream(options.getOutput(), false)) :
    System.out;
  return jgf.createGenerator(output);
}

代码示例来源:origin: net.shibboleth.idp/idp-consent

/** Constructor. */
public ConsentSerializer() {
  generatorFactory = Json.createGeneratorFactory(null);
  readerFactory = Json.createReaderFactory(null);
  symbolics = ImmutableBiMap.of();
}

代码示例来源:origin: net.shibboleth.idp/idp-authn-impl

/** Constructor. */
public DefaultAuthenticationResultSerializer() {
  generatorFactory = Json.createGeneratorFactory(null);
  readerFactory = Json.createReaderFactory(null);
  
  principalSerializers = Collections.emptyList();
  authnResultPrincipalSerializer = new AuthenticationResultPrincipalSerializer(this);
  genericSerializer = new GenericPrincipalSerializer();
}

代码示例来源:origin: SynBioDex/libSBOLj

private static void writeJSON(Writer stream, DocumentRoot<QName> document) throws CoreIoException
{
  HashMap<String, Object> config = new HashMap<>();
  config.put(JsonGenerator.PRETTY_PRINTING, true);
  JsonGenerator writer = Json.createGeneratorFactory(config).createGenerator(stream);
  JsonIo jsonIo = new JsonIo();
  jsonIo.createIoWriter(writer).write(StringifyQName.qname2string.mapDR(document));
  writer.flush();
  writer.close();
}

代码示例来源:origin: uk.ac.ncl.intbio/sbol-data-examples

private static void write(Writer stream, DocumentRoot<QName> document) throws Exception
{
  Map<String, Object> config = new HashMap<>();
  config.put(JsonGenerator.PRETTY_PRINTING, true);
  JsonGenerator writer = Json.createGeneratorFactory(config).createGenerator(stream);
  JsonIo jsonIo = new JsonIo();
  jsonIo.createIoWriter(writer).write(StringifyQName.qname2string.mapDR(document));
  writer.flush();
  writer.close();
}

代码示例来源:origin: org.sbolstandard/libSBOLj

private static void writeJSON(Writer stream, DocumentRoot<QName> document) throws CoreIoException
{
  HashMap<String, Object> config = new HashMap<>();
  config.put(JsonGenerator.PRETTY_PRINTING, true);
  JsonGenerator writer = Json.createGeneratorFactory(config).createGenerator(stream);
  JsonIo jsonIo = new JsonIo();
  jsonIo.createIoWriter(writer).write(StringifyQName.qname2string.mapDR(document));
  writer.flush();
  writer.close();
}

相关文章