Java Code Examples for javax.json.spi.JsonProvider#createBuilderFactory()

The following examples show how to use javax.json.spi.JsonProvider#createBuilderFactory() . 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: JsonSchemaModulesGenerator.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void generate(JsonStructureWriter<T, C> writer) {
	final JsonProvider provider = JsonProvider.provider();
	final JsonBuilderFactory builderFactory = provider.createBuilderFactory(null);
	for (final Module<T, C> module : this.modules.getModules()) {
		if (!module.isEmpty()) {
			for (JsonSchema jsonSchema : module.getJsonSchemas()) {
				final JsonSchemaModuleCompiler<T, C> moduleCompiler = new JsonSchemaModuleCompiler<T, C>(
						builderFactory, modules, module, jsonSchema);
				final JsonSchemaBuilder moduleSchema = moduleCompiler.compile();
				final JsonObject moduleSchemaJsonObject = moduleSchema.build(builderFactory);
				writer.writeJsonStructure(module, moduleSchemaJsonObject, jsonSchema.getFileName());
			}
		}
	}
}
 
Example 2
Source File: JsonBuilderUtilsTest.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void addsProperty() {
	final JsonProvider provider = JsonProvider.provider();
	final JsonBuilderFactory builderFactory = provider
			.createBuilderFactory(null);
	final JsonObjectBuilder builder = builderFactory.createObjectBuilder();
	JsonBuilderUtils.add(builderFactory, builder, "null", null);
	JsonBuilderUtils.add(builderFactory, builder, "true", true);
	JsonBuilderUtils.add(builderFactory, builder, "string", "string");
	JsonBuilderUtils.add(builderFactory, builder, "char", 'c');
	JsonBuilderUtils.add(builderFactory, builder, "bigInteger",
			BigInteger.TEN);
	JsonBuilderUtils.add(builderFactory, builder, "bigDecimal",
			BigDecimal.valueOf(1111, 2));
	JsonBuilderUtils.add(builderFactory, builder, "float", 22f);
	JsonBuilderUtils.add(builderFactory, builder, "double", 22d);
	JsonBuilderUtils.add(builderFactory, builder, "byte", (byte) 33);
	JsonBuilderUtils.add(builderFactory, builder, "int", (int) 44);
	JsonBuilderUtils.add(builderFactory, builder, "short", (int) 55);
	JsonBuilderUtils.add(builderFactory, builder, "list",
			Arrays.<Object> asList("a", 0xbc, "d"));
	JsonBuilderUtils.add(builderFactory, builder, "array", new Object[] {
			1, "2", 3, false });

	JsonBuilderUtils.add(builderFactory, builder, "map",
			Collections.singletonMap("foo", "bar"));
	// provider.createWriter(System.out).write(builder.build());
}
 
Example 3
Source File: JsonBuilderUtilsTest.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void addsItem() {
	final JsonProvider provider = JsonProvider.provider();
	final JsonBuilderFactory builderFactory = provider
			.createBuilderFactory(null);
	final JsonArrayBuilder builder = builderFactory.createArrayBuilder();
	JsonBuilderUtils.add(builderFactory, builder, null);
	JsonBuilderUtils.add(builderFactory, builder, true);
	JsonBuilderUtils.add(builderFactory, builder, "string");
	JsonBuilderUtils.add(builderFactory, builder, 'c');
	JsonBuilderUtils.add(builderFactory, builder, BigInteger.TEN);
	JsonBuilderUtils.add(builderFactory, builder,
			BigDecimal.valueOf(1111, 2));
	JsonBuilderUtils.add(builderFactory, builder, 22f);
	JsonBuilderUtils.add(builderFactory, builder, 22d);
	JsonBuilderUtils.add(builderFactory, builder, (byte) 33);
	JsonBuilderUtils.add(builderFactory, builder, (int) 44);
	JsonBuilderUtils.add(builderFactory, builder, (int) 55);
	JsonBuilderUtils.add(builderFactory, builder,
			Arrays.<Object> asList("a", 0xbc, "d"));
	JsonBuilderUtils.add(builderFactory, builder, new Object[] { 1, "2", 3,
			false });

	JsonBuilderUtils.add(builderFactory, builder,
			Collections.singletonMap("foo", "bar"));
	// provider.createWriter(System.out).write(builder.build());
}