Skip to content

Commit 015704b

Browse files
committed
rename to JsonUtils for consistency
1 parent c48be11 commit 015704b

15 files changed

Lines changed: 47 additions & 47 deletions

File tree

core/src/main/java/com/github/jsonldjava/core/DocumentLoader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.fasterxml.jackson.core.JsonParser;
55
import com.fasterxml.jackson.core.JsonToken;
66
import com.fasterxml.jackson.databind.MappingJsonFactory;
7-
import com.github.jsonldjava.utils.JSONUtils;
7+
import com.github.jsonldjava.utils.JsonUtils;
88
import org.apache.http.HttpResponse;
99
import org.apache.http.client.HttpClient;
1010
import org.apache.http.client.methods.HttpGet;
@@ -113,7 +113,7 @@ public static InputStream openStreamFromURL(java.net.URL url) throws IOException
113113
public static HttpClient getHttpClient() {
114114
HttpClient result = httpClient;
115115
if (result == null) {
116-
synchronized (JSONUtils.class) {
116+
synchronized (JsonUtils.class) {
117117
result = httpClient;
118118
if (result == null) {
119119
// Uses Apache SystemDefaultHttpClient rather than
@@ -138,7 +138,7 @@ public static HttpClient getHttpClient() {
138138
}
139139

140140
public static void setHttpClient(HttpClient nextHttpClient) {
141-
synchronized (JSONUtils.class) {
141+
synchronized (JsonUtils.class) {
142142
httpClient = nextHttpClient;
143143
}
144144
}

core/src/main/java/com/github/jsonldjava/utils/JSONUtils.java renamed to core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* @author tristan
4040
*
4141
*/
42-
public class JSONUtils {
42+
public class JsonUtils {
4343
/**
4444
* An HTTP Accept header that prefers JSONLD.
4545
*/
@@ -186,7 +186,7 @@ public static Object fromURL(java.net.URL url) throws JsonParseException, IOExce
186186
*/
187187
protected static HttpClient getHttpClient() {
188188
if (httpClient == null) {
189-
synchronized (JSONUtils.class) {
189+
synchronized (JsonUtils.class) {
190190
if (httpClient == null) {
191191
// Uses Apache SystemDefaultHttpClient rather than
192192
// DefaultHttpClient, thus the normal proxy settings for the
@@ -241,7 +241,7 @@ protected static InputStream openStreamFromURL(java.net.URL url) throws IOExcept
241241
}
242242

243243
protected static void setHttpClient(HttpClient nextHttpClient) {
244-
synchronized (JSONUtils.class) {
244+
synchronized (JsonUtils.class) {
245245
httpClient = nextHttpClient;
246246
}
247247
}

core/src/test/java/com/github/jsonldjava/core/JsonLdProcessorTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import com.fasterxml.jackson.core.JsonGenerationException;
4040
import com.fasterxml.jackson.databind.JsonMappingException;
4141
import com.github.jsonldjava.impl.TurtleTripleCallback;
42-
import com.github.jsonldjava.utils.JSONUtils;
42+
import com.github.jsonldjava.utils.JsonUtils;
4343
import com.github.jsonldjava.utils.Obj;
4444
import com.github.jsonldjava.utils.TestUtils;
4545

@@ -170,7 +170,7 @@ public static void writeReport() throws JsonGenerationException, JsonMappingExce
170170
if ("application/ld+json".equals(reportFormat) || "jsonld".equals(reportFormat)
171171
|| "*".equals(reportFormat)) {
172172
System.out.println("Generating JSON-LD Report");
173-
JSONUtils.writePrettyPrint(new OutputStreamWriter(new FileOutputStream(reportOutputFile
173+
JsonUtils.writePrettyPrint(new OutputStreamWriter(new FileOutputStream(reportOutputFile
174174
+ ".jsonld")), REPORT);
175175
}
176176

@@ -242,7 +242,7 @@ public boolean accept(File dir, String name) {
242242
// System.out.println("Reading: " + in.getCanonicalPath());
243243
final FileInputStream manifestfile = new FileInputStream(in);
244244

245-
final Map<String, Object> manifest = (Map<String, Object>) JSONUtils
245+
final Map<String, Object> manifest = (Map<String, Object>) JsonUtils
246246
.fromInputStream(manifestfile);
247247

248248
for (final Map<String, Object> test : (List<Map<String, Object>>) manifest
@@ -287,7 +287,7 @@ public RemoteDocument loadDocument(String url) throws JsonLdError {
287287
final InputStream inputStream = cl.getResourceAsStream(TEST_DIR + "/"
288288
+ classpath);
289289
try {
290-
return new RemoteDocument(url, JSONUtils.fromInputStream(inputStream));
290+
return new RemoteDocument(url, JsonUtils.fromInputStream(inputStream));
291291
} catch (final IOException e) {
292292
throw new JsonLdError(JsonLdError.Error.LOADING_DOCUMENT_FAILED);
293293
}
@@ -354,7 +354,7 @@ public void runTest() throws URISyntaxException, IOException, JsonLdError {
354354

355355
Object input = null;
356356
if (inputType.equals("jsonld")) {
357-
input = JSONUtils.fromInputStream(inputStream);
357+
input = JsonUtils.fromInputStream(inputStream);
358358
} else if (inputType.equals("nt") || inputType.equals("nq")) {
359359
final List<String> inputLines = new ArrayList<String>();
360360
final BufferedReader buf = new BufferedReader(new InputStreamReader(inputStream,
@@ -387,7 +387,7 @@ public void runTest() throws URISyntaxException, IOException, JsonLdError {
387387
} else {
388388
final String expectType = expectFile.substring(expectFile.lastIndexOf(".") + 1);
389389
if (expectType.equals("jsonld")) {
390-
expect = JSONUtils.fromInputStream(expectStream);
390+
expect = JsonUtils.fromInputStream(expectStream);
391391
} else if (expectType.equals("nt") || expectType.equals("nq")) {
392392
final List<String> expectLines = new ArrayList<String>();
393393
final BufferedReader buf = new BufferedReader(new InputStreamReader(
@@ -438,7 +438,7 @@ public void runTest() throws URISyntaxException, IOException, JsonLdError {
438438
if (test_opts.containsKey("expandContext")) {
439439
final InputStream contextStream = cl.getResourceAsStream(TEST_DIR + "/"
440440
+ test_opts.get("expandContext"));
441-
options.setExpandContext(JSONUtils.fromInputStream(contextStream));
441+
options.setExpandContext(JsonUtils.fromInputStream(contextStream));
442442
}
443443
if (test_opts.containsKey("compactArrays")) {
444444
options.setCompactArrays((Boolean) test_opts.get("compactArrays"));
@@ -479,21 +479,21 @@ public void runTest() throws URISyntaxException, IOException, JsonLdError {
479479
} else if (testType.contains("jld:CompactTest")) {
480480
final InputStream contextStream = cl.getResourceAsStream(TEST_DIR + "/"
481481
+ test.get("context"));
482-
final Object contextJson = JSONUtils.fromInputStream(contextStream);
482+
final Object contextJson = JsonUtils.fromInputStream(contextStream);
483483
result = JsonLdProcessor.compact(input, contextJson, options);
484484
} else if (testType.contains("jld:FlattenTest")) {
485485
if (test.containsKey("context")) {
486486
final InputStream contextStream = cl.getResourceAsStream(TEST_DIR + "/"
487487
+ test.get("context"));
488-
final Object contextJson = JSONUtils.fromInputStream(contextStream);
488+
final Object contextJson = JsonUtils.fromInputStream(contextStream);
489489
result = JsonLdProcessor.flatten(input, contextJson, options);
490490
} else {
491491
result = JsonLdProcessor.flatten(input, options);
492492
}
493493
} else if (testType.contains("jld:FrameTest")) {
494494
final InputStream frameStream = cl.getResourceAsStream(TEST_DIR + "/"
495495
+ test.get("frame"));
496-
final Map<String, Object> frameJson = (Map<String, Object>) JSONUtils
496+
final Map<String, Object> frameJson = (Map<String, Object>) JsonUtils
497497
.fromInputStream(frameStream);
498498
result = JsonLdProcessor.frame(input, frameJson, options);
499499
} else if (testType.contains("jld:FromRDFTest")) {
@@ -600,10 +600,10 @@ public void runTest() throws URISyntaxException, IOException, JsonLdError {
600600
+ test.get("expect")
601601
+ ")\n"
602602
+ "expected: "
603-
+ JSONUtils.toPrettyString(expect)
603+
+ JsonUtils.toPrettyString(expect)
604604
+ "\nresult: "
605605
+ (result instanceof JsonLdError ? ((JsonLdError) result).toString()
606-
: JSONUtils.toPrettyString(result)), testpassed);
606+
: JsonUtils.toPrettyString(result)), testpassed);
607607
}
608608

609609
}

core/src/test/java/com/github/jsonldjava/utils/EarlTestSuite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ manifestFile, new JsonLdOptions(manifestURL) {
8888
throw new RuntimeException(e);
8989
}
9090
} else if (manifestURL.endsWith(".jsonld") || manifestURL.endsWith(".json")) {
91-
final Object rval = JSONUtils.fromString(manifestFile);
91+
final Object rval = JsonUtils.fromString(manifestFile);
9292
if (rval instanceof Map) {
9393
this.manifest = (Map<String, Object>) rval;
9494
this.tests = (List<Map<String, Object>>) Obj.get(this.manifest, "sequence");

core/src/test/java/com/github/jsonldjava/utils/JSONUtilsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void fromStringTest() {
4444
Object obj = null;
4545

4646
try {
47-
obj = JSONUtils.fromString(testString);
47+
obj = JsonUtils.fromString(testString);
4848
} catch (final Exception e) {
4949
assertTrue(false);
5050
}
@@ -53,7 +53,7 @@ public void fromStringTest() {
5353
assertTrue(((Map<String, Object>) obj).get("seq") instanceof Number);
5454

5555
try {
56-
obj = JSONUtils.fromString(testFailure);
56+
obj = JsonUtils.fromString(testFailure);
5757
assertTrue(false);
5858
} catch (final Exception e) {
5959
assertTrue(true);

integration/clerezza/src/test/java/com/github/jsonldjava/clerezza/ClerezzaTripleCallbackTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212

1313
import com.github.jsonldjava.core.JsonLdError;
1414
import com.github.jsonldjava.core.JsonLdProcessor;
15-
import com.github.jsonldjava.utils.JSONUtils;
15+
import com.github.jsonldjava.utils.JsonUtils;
1616

1717
public class ClerezzaTripleCallbackTest {
1818

1919
@Test
2020
public void triplesTest() throws IOException, JsonLdError {
2121
final InputStream in = getClass().getClassLoader().getResourceAsStream(
2222
"testfiles/product.jsonld");
23-
final Object input = JSONUtils.fromInputStream(in);
23+
final Object input = JsonUtils.fromInputStream(in);
2424

2525
final ClerezzaTripleCallback callback = new ClerezzaTripleCallback();
2626

@@ -37,7 +37,7 @@ public void triplesTest() throws IOException, JsonLdError {
3737
public void curiesInContextTest() throws IOException, JsonLdError {
3838
final InputStream in = getClass().getClassLoader().getResourceAsStream(
3939
"testfiles/curies-in-context.jsonld");
40-
final Object input = JSONUtils.fromInputStream(in);
40+
final Object input = JsonUtils.fromInputStream(in);
4141

4242
final ClerezzaTripleCallback callback = new ClerezzaTripleCallback();
4343

integration/jena/src/main/java/com/github/jsonldjava/jena/JsonLDReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import com.github.jsonldjava.core.JsonLdOptions;
3838
import com.github.jsonldjava.core.JsonLdProcessor;
3939
import com.github.jsonldjava.core.RDFDataset;
40-
import com.github.jsonldjava.utils.JSONUtils;
40+
import com.github.jsonldjava.utils.JsonUtils;
4141
import com.hp.hpl.jena.datatypes.RDFDatatype;
4242
import com.hp.hpl.jena.graph.Node;
4343
import com.hp.hpl.jena.graph.NodeFactory;
@@ -86,7 +86,7 @@ public Object call(RDFDataset dataset) {
8686
};
8787
JsonLdOptions options = new JsonLdOptions(baseURI);
8888
options.useNamespaces = true;
89-
JsonLdProcessor.toRDF(JSONUtils.fromInputStream(in), callback, options);
89+
JsonLdProcessor.toRDF(JsonUtils.fromInputStream(in), callback, options);
9090
} catch (final IOException e) {
9191
throw new RiotException("Could not read JSONLD: " + e, e);
9292
} catch (final JsonLdError e) {

integration/jena/src/main/java/com/github/jsonldjava/jena/JsonLDWriter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import com.github.jsonldjava.core.JsonLdOptions;
4646
import com.github.jsonldjava.core.JsonLdProcessor;
4747
import com.github.jsonldjava.core.RDFDataset;
48-
import com.github.jsonldjava.utils.JSONUtils;
48+
import com.github.jsonldjava.utils.JsonUtils;
4949
import com.hp.hpl.jena.graph.Graph;
5050
import com.hp.hpl.jena.graph.Node;
5151
import com.hp.hpl.jena.graph.Triple;
@@ -112,9 +112,9 @@ private void serialize(Writer writer, DatasetGraph dataset, PrefixMap prefixMap,
112112
obj = JsonLdProcessor.compact(obj, localCtx, opts);
113113

114114
if (isPretty()) {
115-
JSONUtils.writePrettyPrint(writer, obj);
115+
JsonUtils.writePrettyPrint(writer, obj);
116116
} else {
117-
JSONUtils.write(writer, obj);
117+
JsonUtils.write(writer, obj);
118118
}
119119
} catch (final IOException e) {
120120
throw new RiotException("Could not write JSONLD: " + e, e);

integration/jena/src/test/java/com/github/jsonldjava/jena/ExampleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import com.github.jsonldjava.core.JsonLdApi;
1212
import com.github.jsonldjava.core.JsonLdOptions;
1313
import com.github.jsonldjava.core.RDFDataset;
14-
import com.github.jsonldjava.utils.JSONUtils;
14+
import com.github.jsonldjava.utils.JsonUtils;
1515
import com.hp.hpl.jena.query.Dataset;
1616
import com.hp.hpl.jena.query.DatasetFactory;
1717
import com.hp.hpl.jena.rdf.model.Model;
@@ -152,7 +152,7 @@ public void modelToJsonLD() throws Exception {
152152
final JsonLdApi api = new JsonLdApi(options);
153153
final RDFDataset dataset = new RDFDataset(api);
154154
final Object json = api.fromRDF(dataset);
155-
final String jsonStr = JSONUtils.toPrettyString(json);
155+
final String jsonStr = JsonUtils.toPrettyString(json);
156156
System.out.println(jsonStr);
157157
// [ {
158158
// "@id" : "http://example.com/test",

integration/jena/src/test/java/com/github/jsonldjava/jena/JSONLDToRDFTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.github.jsonldjava.core.JsonLdApi;
99
import com.github.jsonldjava.core.JsonLdOptions;
1010
import com.github.jsonldjava.core.RDFDataset;
11-
import com.github.jsonldjava.utils.JSONUtils;
11+
import com.github.jsonldjava.utils.JsonUtils;
1212
import com.hp.hpl.jena.rdf.model.Model;
1313
import com.hp.hpl.jena.rdf.model.ModelFactory;
1414
import com.hp.hpl.jena.rdf.model.Property;
@@ -33,7 +33,7 @@ public void write() throws Exception {
3333
final JenaRDFParser parser = new JenaRDFParser();
3434
final RDFDataset dataset = parser.parse(model);
3535
final Object json = new JsonLdApi(options).fromRDF(dataset);
36-
final String jsonStr = JSONUtils.toPrettyString(json);
36+
final String jsonStr = JsonUtils.toPrettyString(json);
3737
// System.out.println(jsonStr);
3838
assertTrue(jsonStr.contains("@id"));
3939
assertTrue(jsonStr.contains("http://example.com/test"));

0 commit comments

Comments
 (0)