public Schema compile(String schema) { return compile(schema, null); }
private void compileGlobalSchemas() { SchemaCompiler compiler = SchemaCompiler.getInstance(); Raml raml = getDocumentObject(); Map<String, Object> compiledSchemas = new HashMap<String, Object>(); List<Map<String, String>> schemas = raml.getSchemas(); for (Map<String, String> schemaMap : schemas) { compiledSchemas.putAll(compiler.compile(schemaMap)); } raml.setCompiledSchemas(compiledSchemas); }
public NodeVisitor(NodeHandler nodeHandler, ResourceLoader resourceLoader, TagResolver... tagResolvers) { super(); this.nodeHandler = nodeHandler; this.resourceLoader = resourceLoader; this.tagResolvers = tagResolvers; initializeContextPathAware(tagResolvers); initializeResourceLoaderAware(); SchemaCompiler.getInstance().init(contextPath, resourceLoader); }
public Map<String, Object> compile(Map<String, String> encodedSchemas) { Map<String, Object> compiledSchemas = new HashMap<String, Object>(); for (Map.Entry<String, String> encodedSchema : encodedSchemas.entrySet()) { String[] pathAndSchema = decodeIncludePath(encodedSchema.getValue()); Schema compiledSchema = compile(pathAndSchema[1], pathAndSchema[0]); if (compiledSchema != null) { compiledSchemas.put(encodedSchema.getKey(), compiledSchema); } else if (StringUtils.isNotBlank(pathAndSchema[0])) { compiledSchemas.put(encodedSchema.getKey(), pathAndSchema[0]); } encodedSchema.setValue(pathAndSchema[1]); } return compiledSchemas; }
@Override public Object buildValue(Object parent, ScalarNode node) { String value = SchemaCompiler.encodeIncludePath(node); ReflectionUtils.setProperty(parent, key, value); return parent; }
private Object compileSchema(ScalarNode node) { String value = node.getValue(); if (value == null || NodeUtils.isNonStringTag(node.getTag())) { return null; } Object schema = null; String mimeType = getParent() instanceof PojoTupleBuilder ? ((PojoTupleBuilder) getParent()).getFieldName() : null; if (mimeType != null && mimeType.contains("xml")) { schema = SchemaCompiler.getInstance().compile(value); } else if (mimeType != null && mimeType.contains("json") && (node instanceof IncludeScalarNode)) { //in case of json schemas store include path schema = ((IncludeScalarNode) node).getIncludeName(); } return schema; }