Skip to content

Method: getTermMapping(String)

1: /*
2: * JB4JSON-LD
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jsonld.serialization.context;
19:
20: import cz.cvut.kbss.jsonld.JsonLd;
21: import cz.cvut.kbss.jsonld.serialization.model.JsonNode;
22: import cz.cvut.kbss.jsonld.serialization.model.ObjectNode;
23:
24: import java.util.Optional;
25:
26: /**
27: * JSON-LD that does nothing.
28: * <p>
29: * It can be used in serialization that does not create a JSON-LD context (e.g., expanded, context-less compacted).
30: */
31: public class DummyJsonLdContext implements JsonLdContext, JsonLdContextFactory {
32:
33: public static final DummyJsonLdContext INSTANCE = new DummyJsonLdContext();
34:
35: @Override
36: public void registerTermMapping(String term, String iri) {
37: // Do nothing
38: }
39:
40: @Override
41: public void registerTermMapping(String term, ObjectNode mappedNode) {
42: // Do nothing
43: }
44:
45: @Override
46: public Optional<JsonNode> getTermMapping(String term) {
47: return Optional.empty();
48: }
49:
50: @Override
51: public boolean hasTermMapping(String term) {
52: return false;
53: }
54:
55: @Override
56: public Optional<String> getMappedTerm(String iri) {
57: return Optional.empty();
58: }
59:
60: @Override
61: public boolean isCurrentEmpty() {
62: return true;
63: }
64:
65: @Override
66: public ObjectNode getContextNode() {
67: return new ObjectNode(JsonLd.CONTEXT);
68: }
69:
70: @Override
71: public JsonLdContext createJsonLdContext() {
72: return INSTANCE;
73: }
74:
75: @Override
76: public JsonLdContext createJsonLdContext(JsonLdContext parent) {
77: return INSTANCE;
78: }
79: }