Java 类javax.json.stream.JsonParserFactory 实例源码

项目:cookjson    文件:JsonParserFactoryTest.java   
void testReader (String fileName, HashMap<String, Object> config) throws IOException
{
    File file = new File (fileName.replace ('/', File.separatorChar));

    JsonProvider provider1 = new CookJsonProvider ();

    JsonParserFactory f1 = provider1.createParserFactory (config);

    StringWriter out1 = new StringWriter ();
    JsonParser p1 = f1.createParser (new InputStreamReader (new FileInputStream (file), BOM.utf8));
    JsonGenerator g1 = new TextJsonGenerator (out1);
    Utils.convert (p1, g1);
    p1.close ();
    g1.close ();

    StringWriter out2 = new StringWriter ();
    JsonProvider provider2 = new org.glassfish.json.JsonProviderImpl ();
    JsonParserFactory f2 = provider2.createParserFactory (config);
    JsonParser p2 = f2.createParser (new InputStreamReader (new FileInputStream (file), BOM.utf8));
    JsonGenerator g2 = new TextJsonGenerator (out2);
    Utils.convert (p2, g2);
    p2.close ();
    g2.close ();

    Assert.assertEquals (out1.toString (), out2.toString ());
}
项目:cookjson    文件:JsonParserFactoryTest.java   
void testInputStream (String fileName, HashMap<String, Object> config) throws IOException
{
    File file = new File (fileName.replace ('/', File.separatorChar));

    JsonProvider provider1 = new CookJsonProvider ();

    JsonParserFactory f1 = provider1.createParserFactory (config);

    StringWriter out1 = new StringWriter ();
    JsonParser p1 = f1.createParser (new FileInputStream (file));
    JsonGenerator g1 = new TextJsonGenerator (out1);
    Utils.convert (p1, g1);
    p1.close ();
    g1.close ();

    StringWriter out2 = new StringWriter ();
    JsonProvider provider2 = new org.glassfish.json.JsonProviderImpl ();
    JsonParserFactory f2 = provider2.createParserFactory (config);
    JsonParser p2 = f2.createParser (new FileInputStream (file));
    JsonGenerator g2 = new TextJsonGenerator (out2);
    Utils.convert (p2, g2);
    p2.close ();
    g2.close ();

    Assert.assertEquals (out1.toString (), out2.toString ());
}
项目:cookjson    文件:JsonParserFactoryTest.java   
void testCharset (String fileName, HashMap<String, Object> config) throws IOException
{
    File file = new File (fileName.replace ('/', File.separatorChar));

    JsonProvider provider1 = new CookJsonProvider ();

    JsonParserFactory f1 = provider1.createParserFactory (config);

    StringWriter out1 = new StringWriter ();
    JsonParser p1 = f1.createParser (new FileInputStream (file), BOM.utf8);
    JsonGenerator g1 = new TextJsonGenerator (out1);
    Utils.convert (p1, g1);
    p1.close ();
    g1.close ();

    StringWriter out2 = new StringWriter ();
    JsonProvider provider2 = new org.glassfish.json.JsonProviderImpl ();
    JsonParserFactory f2 = provider2.createParserFactory (config);
    JsonParser p2 = f2.createParser (new FileInputStream (file), BOM.utf8);
    JsonGenerator g2 = new TextJsonGenerator (out2);
    Utils.convert (p2, g2);
    p2.close ();
    g2.close ();

    Assert.assertEquals (out1.toString (), out2.toString ());
}
项目:johnzon    文件:BrokenDefaultTest.java   
@Test
@Ignore("buggy but pushing to share the use case")
public void run() throws NoSuchFieldException, IllegalAccessException { // shouldnt fail by default
    final JsonParserFactory factory = Json.createParserFactory(emptyMap());
    final int length = 1024 * 1024;
    assertEquals(0, get(Queue.class, get(
            BufferStrategy.BufferProvider.class, factory, "bufferProvider"), "queue").size());
    try (final JsonParser parser = factory.createParser(newDynamicInput(length))) {
        int eventCount = 0;
        while (parser.hasNext()) {
            eventCount++;
            final JsonParser.Event next = parser.next();
            if (eventCount == 2 && next == JsonParser.Event.VALUE_STRING) {
                assertEquals(length, parser.getString().length());
            }
        }
    }
    assertEquals(1, get(Queue.class, get(
            BufferStrategy.BufferProvider.class, factory, "bufferProvider"), "queue").size());
}
项目:johnzon    文件:JohnzonBuilder.java   
private Supplier<JsonParserFactory> createJsonParserFactory() {
    return new Supplier<JsonParserFactory>() { // thread safety is not mandatory
        private final AtomicReference<JsonParserFactory> ref = new AtomicReference<>();

        @Override
        public JsonParserFactory get() {
            JsonParserFactory factory = ref.get();
            if (factory == null) {
                factory = doCreate();
                if (!ref.compareAndSet(null, factory)) {
                    factory = ref.get();
                }
            }
            return factory;
        }

        private JsonParserFactory doCreate() {
            return (jsonp == null ? JsonProvider.provider() : jsonp).createParserFactory(emptyMap());
        }
    };
}
项目:cookjson    文件:JsonStructureParserTest.java   
private JsonParser createParser (JsonProvider provider, JsonValue value)
{
    HashMap<String, Object> config = new HashMap<String, Object> ();
    JsonParserFactory f = provider.createParserFactory (config);
    if (value instanceof JsonArray)
        return f.createParser ((JsonArray)value);
    else if (value instanceof JsonObject)
        return f.createParser ((JsonObject)value);
    throw new IllegalArgumentException ("Invalid value type.");
}
项目:cookjson    文件:JsonParserFactoryTest.java   
private JsonParser createParser (JsonProvider provider, JsonValue value)
{
    HashMap<String, Object> config = new HashMap<String, Object> ();
    JsonParserFactory f = provider.createParserFactory (config);
    if (value instanceof JsonArray)
        return f.createParser ((JsonArray)value);
    else if (value instanceof JsonObject)
        return f.createParser ((JsonObject)value);
    throw new IllegalArgumentException ("Invalid value type.");
}
项目:johnzon    文件:JsonbAccessMode.java   
public JsonbAccessMode(final PropertyNamingStrategy propertyNamingStrategy, final String orderValue,
                       final PropertyVisibilityStrategy visibilityStrategy, final boolean caseSensitive,
                       final Map<AdapterKey, Adapter<?, ?>> defaultConverters, final JohnzonAdapterFactory factory,
                       final Supplier<JsonParserFactory> parserFactory, final AccessMode delegate) {
    this.naming = propertyNamingStrategy;
    this.order = orderValue;
    this.visibility = visibilityStrategy;
    this.caseSensitive = caseSensitive;
    this.delegate = delegate;
    this.defaultConverters = defaultConverters;
    this.factory = factory;
    this.parserFactory = parserFactory;
}
项目:baratine    文件:Json.java   
public static JsonParserFactory createParserFactory()
{
  return getProvider().createParserFactory();
}
项目:baratine    文件:Json.java   
public static JsonParserFactory createParserFactory(JsonConfiguration config)
{
  return getProvider().createParserFactory(config);
}
项目:baratine    文件:JsonProvider.java   
public abstract JsonParserFactory
createParserFactory(JsonConfiguration config);
项目:cookjson    文件:CookJsonProvider.java   
@Override
public JsonParserFactory createParserFactory (Map<String, ?> config)
{
    return new JsonParserFactoryImpl (config, getHandler (config));
}
项目:polygene-java    文件:JavaxJsonFactories.java   
@Override
public JsonParserFactory parserFactory()
{
    return parserFactory;
}
项目:activemq-artemis    文件:JsonLoader.java   
public static JsonParserFactory createParserFactory(Map<String, ?> config) {
   return provider.createParserFactory(config);
}
项目:johnzon    文件:JsonProviderImpl.java   
@Override
public JsonParserFactory createParserFactory(final Map<String, ?> stringMap) {
    return DELEGATE.createParserFactory(stringMap);
}
项目:johnzon    文件:JsonProviderImpl.java   
@Override
public JsonParserFactory createParserFactory(final Map<String, ?> config) {
    return (config == null || config.isEmpty()) ? parserFactory : new JsonParserFactoryImpl(config);
}
项目:jsr353-benchmark    文件:JsonpRiParser.java   
@Override
public JsonParserFactory getParserFactory() {
    return parserFactory;
}
项目:jsr353-benchmark    文件:JohnzonParser.java   
@Override
public JsonParserFactory getParserFactory() {
    return parserFactory;
}
项目:jsr353-benchmark    文件:GensonParser.java   
@Override
public JsonParserFactory getParserFactory() {
    return parserFactory;
}
项目:jsr353-benchmark    文件:JacksonPgelinasJSR353.java   
@Override
public JsonParserFactory getParserFactory() {
    return parserFactory;
}
项目:schematica    文件:SchematicaJsonProvider.java   
@Override
public JsonParserFactory createParserFactory( Map<String, ?> config ) {
    return defaultProvider.createParserFactory(config);
}
项目:hibiscus    文件:BasicJsonValidator.java   
/**
 * Creates and configures {@link JsonParserFactory} object which implements Java API for JSON Processing.
 * @return created {@link JsonParserFactory} object to be used in the process of the validation.
 * @see JsonParserFactory
 * @see <a href="http://json-processing-spec.java.net/">JSR 353: Java API for JSON Processing</a>
 */
protected JsonParserFactory createParserFactory() {
    Map<String, ?> config = new HashMap<>();
    return Json.createParserFactory(config);
}
项目:schematica    文件:Json.java   
/**
 * Creates a parser factory for creating {@link JsonParser} 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.
 *
 * @param config a map of provider specific properties to configure the
 *               JSON parsers. The map may be empty or null
 * @return JSON parser factory
 */
public static JsonParserFactory createParserFactory(Map<String, ?> config) {
    return PROVIDER_INSTANCE.createParserFactory(config);
}
项目:baratine    文件:JsonProvider.java   
public abstract JsonParserFactory createParserFactory();
项目:polygene-java    文件:JavaxJsonFactories.java   
JsonParserFactory parserFactory();
项目:jsr353-benchmark    文件:Jsr353Parser.java   
public abstract JsonParserFactory getParserFactory();