@Test public void createWithRelativeSegmentsInPath() throws URISyntaxException { Path basePath = Paths.get(getClass().getResource("/schema/person.json").toURI()).getParent().getParent().getParent().getParent(); File relativePath = new File(Paths.get(basePath.toString(),"target", "..", "src", "test", "resources", "schema", "person.json").toString()); File nonRelativePath = new File(Paths.get(basePath.toString(), "src", "test", "resources", "schema", "person.json").toString()); SchemaStore schemaStore = new SchemaStore(); Schema schemaWithRelativeSegment = schemaStore.create(relativePath.toURI(), "#/."); Schema schemaWithoutRelativeSegment = schemaStore.create(nonRelativePath.toURI(), "#/."); assertThat(schemaWithoutRelativeSegment.getId(), is(schemaWithRelativeSegment.getId())); assertThat(schemaWithoutRelativeSegment, sameInstance(schemaWithRelativeSegment)); }
public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); }
SchemaStore { public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); } }
SchemaStore { public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); } SchemaStore();  SchemaStore(ContentResolver contentResolver); }
SchemaStore { public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); } SchemaStore();  SchemaStore(ContentResolver contentResolver); synchronized Schema create(URI id, String refFragmentPathDelimiters); @SuppressWarnings("PMD.UselessParentheses") Schema create(Schema parent, String path, String refFragmentPathDelimiters); synchronized void clearCache(); }
SchemaStore { public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); } SchemaStore();  SchemaStore(ContentResolver contentResolver); synchronized Schema create(URI id, String refFragmentPathDelimiters); @SuppressWarnings("PMD.UselessParentheses") Schema create(Schema parent, String path, String refFragmentPathDelimiters); synchronized void clearCache();  }