javax.json.stream.JsonParserFactory Java Examples

The following examples show how to use javax.json.stream.JsonParserFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoapFidoClient.java    From fido2 with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void printJson(String Input) {
    JsonParserFactory factory = Json.createParserFactory(null);
    JsonParser parser = factory.createParser(new StringReader(Input));

    System.out.println("\t{");
    while (parser.hasNext()) {
        Event event = parser.next();

        switch (event) {
            case KEY_NAME: {
                System.out.print("\t\"" + parser.getString() + "\" : \"");
                break;
            }
            case VALUE_STRING: {
                System.out.println(parser.getString() + "\",");
                break;
            }
        }
    }
    System.out.println("\t}");

}
 
Example #2
Source File: DefaultServices.java    From component-runtime with Apache License 2.0 6 votes vote down vote up
public static Object lookup(final String type) {
    if (type.equals(JsonBuilderFactory.class.getName())) {
        return ComponentManager.instance().getJsonpBuilderFactory();
    }
    if (type.equals(JsonReaderFactory.class.getName())) {
        return ComponentManager.instance().getJsonpReaderFactory();
    }
    if (type.equals(JsonGeneratorFactory.class.getName())) {
        return ComponentManager.instance().getJsonpGeneratorFactory();
    }
    if (type.equals(JsonParserFactory.class.getName())) {
        return ComponentManager.instance().getJsonpParserFactory();
    }
    if (type.equals(JsonWriterFactory.class.getName())) {
        return ComponentManager.instance().getJsonpWriterFactory();
    }
    if (type.equals(RecordBuilderFactory.class.getName())) {
        final Function<String, RecordBuilderFactory> provider =
                ComponentManager.instance().getRecordBuilderFactoryProvider();
        return provider.apply(null);
    }
    throw new IllegalArgumentException(type + " can't be a global service, didn't you pass a null plugin?");
}
 
Example #3
Source File: FEreturn.java    From fido2 with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns a pretty Json
 * @param Input
 * @return
 */
public String returnJSON(String Input) {
    String JSON_FORMAT_STRING = "%-10s";
    JsonParserFactory factory = Json.createParserFactory(null);

    StringBuilder sb;
    try (JsonParser parser = factory.createParser(new StringReader(Input))) {
        sb = new StringBuilder();
        sb.append("\n\t{\n");
        while (parser.hasNext()) {
            JsonParser.Event event = parser.next();

            switch (event) {
                case KEY_NAME: {
                    sb.append("\t\t\"");
                    sb.append(String.format(JSON_FORMAT_STRING, parser.getString()));
                    sb.append("\" : \"");
                    break;
                }
                case VALUE_STRING: {
                    sb.append(parser.getString()).append("\",\n");
                    break;
                }
            }
        }   sb.append("\t}");
    }

    return sb.toString();
}
 
Example #4
Source File: PreComputedJsonpProvider.java    From component-runtime with Apache License 2.0 4 votes vote down vote up
@Override
public JsonParserFactory createParserFactory(final Map<String, ?> config) {
    return parserFactory;
}
 
Example #5
Source File: DefaultServiceProvider.java    From component-runtime with Apache License 2.0 4 votes vote down vote up
private Object doLookup(final String id, final ClassLoader loader,
        final Supplier<List<InputStream>> localConfigLookup, final Function<String, Path> resolver,
        final Class<?> api, final AtomicReference<Map<Class<?>, Object>> services) {
    if (JsonProvider.class == api) {
        return new PreComputedJsonpProvider(id, jsonpProvider, jsonpParserFactory, jsonpWriterFactory,
                jsonpBuilderFactory, jsonpGeneratorFactory, jsonpReaderFactory);
    }
    if (JsonBuilderFactory.class == api) {
        return javaProxyEnricherFactory
                .asSerializable(loader, id, JsonBuilderFactory.class.getName(), jsonpBuilderFactory);
    }
    if (JsonParserFactory.class == api) {
        return javaProxyEnricherFactory
                .asSerializable(loader, id, JsonParserFactory.class.getName(), jsonpParserFactory);
    }
    if (JsonReaderFactory.class == api) {
        return javaProxyEnricherFactory
                .asSerializable(loader, id, JsonReaderFactory.class.getName(), jsonpReaderFactory);
    }
    if (JsonWriterFactory.class == api) {
        return javaProxyEnricherFactory
                .asSerializable(loader, id, JsonWriterFactory.class.getName(), jsonpWriterFactory);
    }
    if (JsonGeneratorFactory.class == api) {
        return javaProxyEnricherFactory
                .asSerializable(loader, id, JsonGeneratorFactory.class.getName(), jsonpGeneratorFactory);
    }
    if (Jsonb.class == api) {
        final JsonbBuilder jsonbBuilder = createPojoJsonbBuilder(id,
                Lazy
                        .lazy(() -> Jsonb.class
                                .cast(doLookup(id, loader, localConfigLookup, resolver, Jsonb.class, services))));
        return new GenericOrPojoJsonb(id, jsonbProvider
                .create()
                .withProvider(jsonpProvider) // reuses the same memory buffering
                .withConfig(jsonbConfig)
                .build(), jsonbBuilder.build());
    }
    if (LocalConfiguration.class == api) {
        final List<LocalConfiguration> containerConfigurations = new ArrayList<>(localConfigurations);
        if (!Boolean.getBoolean("talend.component.configuration." + id + ".ignoreLocalConfiguration")) {
            final Stream<InputStream> localConfigs = localConfigLookup.get().stream();
            final Properties aggregatedLocalConfigs = aggregateConfigurations(localConfigs);
            if (!aggregatedLocalConfigs.isEmpty()) {
                containerConfigurations.add(new PropertiesConfiguration(aggregatedLocalConfigs));
            }
        }
        return new LocalConfigurationService(containerConfigurations, id);
    }
    if (RecordBuilderFactory.class == api) {
        return recordBuilderFactoryProvider.apply(id);
    }
    if (ProxyGenerator.class == api) {
        return proxyGenerator;
    }
    if (LocalCache.class == api) {
        final LocalCacheService service =
                new LocalCacheService(id, System::currentTimeMillis, this.executorService);
        Injector.class.cast(services.get().get(Injector.class)).inject(service);
        return service;
    }
    if (Injector.class == api) {
        return new InjectorImpl(id, reflections, proxyGenerator, services.get());
    }
    if (HttpClientFactory.class == api) {
        return new HttpClientFactoryImpl(id, reflections, Jsonb.class.cast(services.get().get(Jsonb.class)),
                services.get());
    }
    if (Resolver.class == api) {
        return new ResolverImpl(id, resolver);
    }
    if (ObjectFactory.class == api) {
        return new ObjectFactoryImpl(id, propertyEditorRegistry);
    }
    if (RecordPointerFactory.class == api) {
        return new RecordPointerFactoryImpl(id);
    }
    if (ContainerInfo.class == api) {
        return new ContainerInfo(id);
    }
    if (RecordService.class == api) {
        return new RecordServiceImpl(id, recordBuilderFactoryProvider.apply(id), () -> jsonpBuilderFactory,
                () -> jsonpProvider,
                Lazy
                        .lazy(() -> Jsonb.class
                                .cast(doLookup(id, loader, localConfigLookup, resolver, Jsonb.class, services))));
    }
    return null;
}
 
Example #6
Source File: Json.java    From baratine with GNU General Public License v2.0 4 votes vote down vote up
public static JsonParserFactory createParserFactory()
{
  return getProvider().createParserFactory();
}
 
Example #7
Source File: Json.java    From baratine with GNU General Public License v2.0 4 votes vote down vote up
public static JsonParserFactory createParserFactory(JsonConfiguration config)
{
  return getProvider().createParserFactory(config);
}
 
Example #8
Source File: JsonProvider.java    From baratine with GNU General Public License v2.0 4 votes vote down vote up
public abstract JsonParserFactory
createParserFactory(JsonConfiguration config);
 
Example #9
Source File: ConfigurableBus.java    From openwebbeans-meecrowave with Apache License 2.0 4 votes vote down vote up
@Override
public JsonParserFactory createParserFactory(final Map<String, ?> config) {
    return provider.createParserFactory(config);
}
 
Example #10
Source File: JavaxJsonFactories.java    From attic-polygene-java with Apache License 2.0 4 votes vote down vote up
@Override
public JsonParserFactory parserFactory()
{
    return parserFactory;
}
 
Example #11
Source File: JsonLoader.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public static JsonParserFactory createParserFactory(Map<String, ?> config) {
   return provider.createParserFactory(config);
}
 
Example #12
Source File: JsonProvider.java    From baratine with GNU General Public License v2.0 votes vote down vote up
public abstract JsonParserFactory createParserFactory(); 
Example #13
Source File: JavaxJsonFactories.java    From attic-polygene-java with Apache License 2.0 votes vote down vote up
JsonParserFactory parserFactory();