本文整理汇总了Java中org.apache.jena.atlas.json.JsonValue类的典型用法代码示例。如果您正苦于以下问题:Java JsonValue类的具体用法?Java JsonValue怎么用?Java JsonValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonValue类属于org.apache.jena.atlas.json包,在下文中一共展示了JsonValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ConceptScheme
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
public ConceptScheme(OEClientReadOnly oeClient, JsonObject jsonObject) {
logger.debug("Concept - entry: {}", jsonObject);
this.uri = jsonObject.get("@id").getAsString().value();
JsonValue jsonValue = jsonObject.get("@type");
if (jsonValue != null) {
JsonArray jsonTypes = jsonValue.getAsArray();
for (int i = 0; i < jsonTypes.size(); i++) {
this.types.add(jsonTypes.get(i).getAsString().value());
}
}
JsonArray jsonPrefLabels = jsonObject.get("skosxl:prefLabel").getAsArray();
for (int i = 0; i < jsonPrefLabels.size(); i++) {
JsonObject jsonPrefLabel = jsonPrefLabels.get(i).getAsObject();
String prefLabelUri = jsonPrefLabel.get("@id").getAsString().value();
JsonObject jsonLiteral = jsonPrefLabel.get("meta:displayName").getAsObject();
String prefLabelValue = jsonLiteral.get("@value").getAsString().value();
String prefLabelLangCode = jsonLiteral.get("@language").getAsString().value();
prefLabels.add(new Label(prefLabelUri, prefLabelLangCode, prefLabelValue));
}
logger.info("Concept - exit: {}", this.uri);
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:27,代码来源:ConceptScheme.java
示例2: json
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
public static void json(HttpServletRequest req, HttpServletResponse resp, JsonValue responseContent) {
try {
resp.setHeader(HttpNames.hCacheControl, "no-cache");
resp.setHeader(HttpNames.hContentType, WebContent.contentTypeJSON);
resp.setStatus(HttpSC.OK_200);
try(ServletOutputStream out = resp.getOutputStream(); IndentedWriter b = new IndentedWriter(out); ) {
b.setFlatMode(true);
JSON.write(b, responseContent);
b.ensureStartOfLine();
b.flush();
out.write('\n');
}
} catch (IOException ex) {
LOG.warn("json: IOException", ex);
try {
resp.sendError(HttpSC.INTERNAL_SERVER_ERROR_500, "Internal server error");
} catch (IOException ex2) {}
}
}
开发者ID:afs,项目名称:rdf-delta,代码行数:20,代码来源:S_JSON.java
示例3: describePatchLog
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
private JsonValue describePatchLog(DeltaAction action) {
// If Id or URI.
// String uri = getFieldAsString(action, F_URI, false);
// String dataSourceId = getFieldAsString(action, F_DATASOURCE, false);
// if ( uri == null && dataSourceId == null )
// throw new DeltaBadRequestException(format("No field: '%s' nor '%s'", F_DATASOURCE, F_URI));
// if ( uri != null && dataSourceId != null )
// throw new DeltaBadRequestException(format("Only one of fields '%s' nor '%s' allowed", F_DATASOURCE, F_URI));
// Must be by Id.
String dataSourceId = getFieldAsString(action, F_DATASOURCE, false);
if ( dataSourceId == null )
throw new DeltaBadRequestException(format("No field: '%s' ", F_DATASOURCE));
Id dsRef = Id.fromString(dataSourceId);
PatchLogInfo logInfo = action.dLink.getPatchLogInfo(dsRef);
if ( logInfo == null )
return noResults;
return logInfo.asJson();
}
开发者ID:afs,项目名称:rdf-delta,代码行数:19,代码来源:S_DRPC.java
示例4: getFieldAsObject
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
private static JsonObject getFieldAsObject(JsonObject arg, String field) {
try {
if ( ! arg.hasKey(field) ) {
LOG.warn("Bad request: Missing Field: "+field+" Arg: "+JSON.toStringFlat(arg)) ;
throw new DeltaBadRequestException("Missing field: "+field) ;
}
JsonValue jv = arg.get(field) ;
if ( ! jv.isObject() ) {
}
return jv.getAsObject();
} catch (JsonException ex) {
LOG.warn("Bad request: Field: "+field+" Arg: "+JSON.toStringFlat(arg)) ;
throw new DeltaBadRequestException("Bad field '"+field+"' : "+arg.get(field)) ;
}
}
开发者ID:afs,项目名称:rdf-delta,代码行数:17,代码来源:S_DRPC.java
示例5: ResourceMapTemplate
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
public ResourceMapTemplate(JsonObject spec, DataContext dc) {
super(spec);
root = new Pattern( getRequiredField(JSONConstants.ID), dc );
for (Entry<String, JsonValue> entry : spec.entrySet()) {
Pattern prop = new Pattern(entry.getKey(), dc);
if (prop.isURI()) {
JsonValue vals = entry.getValue();
if (vals.isString()) {
patterns.put( prop, new Pattern(vals.getAsString().value(), dc) );
} else if (vals.isArray()) {
for (Iterator<JsonValue> i =vals.getAsArray().iterator(); i.hasNext();) {
JsonValue val = i.next();
if (val.isString()) {
patterns.put( prop, new Pattern(val.getAsString().value(), dc) );
} else {
throw new EpiException("Resource map found non-string value pattern: " + val);
}
}
}
}
}
}
开发者ID:epimorphics,项目名称:dclib,代码行数:23,代码来源:ResourceMapTemplate.java
示例6: getTypeConstraints
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
protected List<Resource> getTypeConstraints(JsonObject spec, ConverterProcess proc) {
JsonValue jv = spec.get(JSONConstants.TYPE);
if (jv == null) {
return null;
} else {
List<Resource> constraints = new ArrayList<>();
if (jv.isString()) {
constraints.add( asResource(jv.getAsString().value(), proc) );
} else if (jv.isArray()) {
for (Iterator<JsonValue> i = jv.getAsArray().iterator(); i.hasNext();) {
JsonValue v = i.next();
if (v.isString()) {
constraints.add( asResource(v.getAsString().value(), proc) );
} else {
throw new EpiException("Bad source configuration, type constraint can only be a string or array of strings");
}
}
}
return constraints;
}
}
开发者ID:epimorphics,项目名称:dclib,代码行数:23,代码来源:RDFMapSource.java
示例7: processEnrichSpec
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
protected void processEnrichSpec(JsonObject spec, ConverterProcess proc) {
JsonValue enrichSpec = spec.get(JSONConstants.ENRICH);
if (enrichSpec != null) {
if (enrichSpec.isString()) {
String enrichStr = enrichSpec.getAsString().value();
if (enrichStr.equals("*")) {
enrichDescribe = true;
} else {
enrich.add( asProperty(enrichStr, proc) );
}
} else if (enrichSpec.isArray()) {
for (Iterator<JsonValue> i = enrichSpec.getAsArray().iterator(); i.hasNext();) {
JsonValue v = i.next();
if (v.isString()) {
enrich.add( asProperty(v.getAsString().value(), proc) );
} else {
throw new EpiException("Bad source configuration, enrich can only be a string or array of strings");
}
}
} else {
throw new EpiException("Bad source configuration, enrich can only be a string or array of strings");
}
}
}
开发者ID:epimorphics,项目名称:dclib,代码行数:25,代码来源:RDFMapSource.java
示例8: getAllModels
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
public Collection<Model> getAllModels() throws OEClientException {
logger.info("getAllModels entry");
String url = getApiURL() + "/sys/sys:Model/rdf:instance";
logger.info("getAllModels URL: {}", url);
Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("properties", "meta:displayName,meta:graphUri");
Invocation.Builder invocationBuilder = getInvocationBuilder(url, queryParameters);
Date startDate = new Date();
logger.info("getAllModels making call : {}", startDate.getTime());
Response response = invocationBuilder.get();
logger.info("getAllModels call complete: {}", startDate.getTime());
logger.info("getAllModels - status: {}", response.getStatus());
if (response.getStatus() == 200) {
String stringResponse = response.readEntity(String.class);
if (logger.isInfoEnabled()) logger.info("getAllModels: jsonResponse {}", stringResponse);
JsonObject jsonResponse = JSON.parse(stringResponse);
JsonArray jsonArray = jsonResponse.get("@graph").getAsArray();
Collection<Model> models = new ArrayList<Model>();
Iterator<JsonValue> jsonValueIterator = jsonArray.iterator();
while (jsonValueIterator.hasNext()) {
JsonObject modelObject = jsonValueIterator.next().getAsObject();
models.add(new Model(modelObject));
}
return models;
} else {
throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
}
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:34,代码来源:OEClientReadOnly.java
示例9: getRelationshipTypes
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
private Collection<RelationshipType> getRelationshipTypes(String parentType) throws OEClientException {
logger.info("getRelationshipTypes entry: {}", parentType);
Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("properties", "rdfs:label,owl:inverseOf,rdfs:subPropertyOf,owl:inverseOf/rdfs:label,owl:inverseOf/rdfs:subPropertyOf");
Invocation.Builder invocationBuilder = getInvocationBuilder(getModelURL() + "/" + parentType +"/meta:transitiveSubProperty", queryParameters);
Date startDate = new Date();
logger.info("getRelationshipTypes making call : {}", startDate.getTime());
Response response = invocationBuilder.get();
logger.info("getRelationshipTypes call complete: {}", startDate.getTime());
logger.info("getRelationshipTypes - status: {}", response.getStatus());
if (response.getStatus() == 200) {
String stringResponse = response.readEntity(String.class);
if (logger.isInfoEnabled()) logger.info("getConceptClasses: jsonResponse {}", stringResponse);
JsonObject jsonResponse = JSON.parse(stringResponse);
JsonArray jsonArray = jsonResponse.get("@graph").getAsArray();
Collection<RelationshipType> relationshipTypes = new HashSet<RelationshipType>();
Iterator<JsonValue> jsonValueIterator = jsonArray.iterator();
while (jsonValueIterator.hasNext()) {
relationshipTypes.add(new RelationshipType(this, jsonValueIterator.next().getAsObject()));
}
return relationshipTypes;
} else {
throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
}
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:29,代码来源:OEClientReadOnly.java
示例10: getConceptClasses
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
/**
* Return all concept classes
* @return - a collection containing all concept classes
* @throws OEClientException - an error has occurred contacting the server
*/
public Collection<ConceptClass> getConceptClasses(int limit) throws OEClientException {
logger.info("getConceptClasses entry");
Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("properties", "rdfs:label,rdfs:subClassOf");
queryParameters.put("limit", Integer.toString(limit));
Invocation.Builder invocationBuilder = getInvocationBuilder(getModelURL() + "/skos:Concept/meta:transitiveSubClass", queryParameters);
Date startDate = new Date();
logger.info("getConceptClasses making call : {}", startDate.getTime());
Response response = invocationBuilder.get();
logger.info("getConceptClasses call complete: {}", startDate.getTime());
logger.info("getConceptClasses - status: {}", response.getStatus());
if (response.getStatus() == 200) {
String stringResponse = response.readEntity(String.class);
if (logger.isInfoEnabled()) logger.info("getConceptClasses: jsonResponse {}", stringResponse);
JsonObject jsonResponse = JSON.parse(stringResponse);
JsonArray jsonArray = jsonResponse.get("@graph").getAsArray();
Collection<ConceptClass> conceptClasses = new HashSet<ConceptClass>();
Iterator<JsonValue> jsonValueIterator = jsonArray.iterator();
while (jsonValueIterator.hasNext()) {
conceptClasses.add(new ConceptClass(this, jsonValueIterator.next().getAsObject()));
}
return conceptClasses;
} else {
throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
}
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:35,代码来源:OEClientReadOnly.java
示例11: ChangeRecord
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
public ChangeRecord(OEClientReadOnly oeClient, JsonObject jsonObject) {
logger.debug("ChangeRecord - entry: {}", jsonObject);
this.oeClient = oeClient;
this.uri = getAsString(jsonObject, "@id");
this.added = new ChangeSet(jsonObject.get("teamwork:added"));
this.deleted = new ChangeSet(jsonObject.get("teamwork:deleted"));
JsonValue jsonCommitted = jsonObject.get("sem:committed");
if (jsonCommitted != null) {
logger.debug("jsonCommitted: {}", jsonCommitted);
this.committed = Instant.parse(jsonCommitted.getAsArray().get(0).getAsObject().get("@value").getAsString().value());
}
else this.committed = null;
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:16,代码来源:ChangeRecord.java
示例12: Concept
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
public Concept(OEClientReadOnly oeClient, JsonObject jsonObject) {
logger.debug("Concept - entry: {}", jsonObject);
this.uri = getAsString(jsonObject, "@id");
JsonValue jsonValue = jsonObject.get("@type");
if (jsonValue != null) {
JsonArray jsonTypes = jsonValue.getAsArray();
for (int i = 0; i < jsonTypes.size(); i++) {
this.types.add(jsonTypes.get(i).getAsString().value());
}
}
JsonArray jsonPrefLabels = getAsArray(jsonObject, "skosxl:prefLabel");
if (jsonPrefLabels != null) {
for (int i = 0; i < jsonPrefLabels.size(); i++) {
JsonObject jsonPrefLabel = jsonPrefLabels.get(i).getAsObject();
String prefLabelUri = getAsString(jsonPrefLabel, "@id");
JsonArray jsonLiteralForms = getAsArray(jsonPrefLabel, "skosxl:literalForm");
if (jsonLiteralForms != null) {
for (int j = 0; j < jsonLiteralForms.size(); j++) {
JsonObject jsonLiteralForm = jsonLiteralForms.get(j).getAsObject();
String prefLabelValue = getAsString(jsonLiteralForm, "@value");
String prefLabelLangCode = getAsString(jsonLiteralForm, "@language");
Label label = new Label(prefLabelUri, prefLabelLangCode, prefLabelValue);
prefLabels.add(label);
addByLanguageAndValue(prefLabelsByLanguageAndValue, label.getLanguageCode(), label.getValue(), label);
}
}
}
}
logger.info("Concept - exit: {}", this.uri);
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:35,代码来源:Concept.java
示例13: ChangeSet
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
public ChangeSet(JsonValue jsonValue) {
logger.debug("ChangeSet - entry: {}", jsonValue);
if (jsonValue == null) return;
JsonArray jsonArray = jsonValue.getAsArray();
for (int i = 0; i < jsonArray.size(); i++) {
triples.add(new Triple(jsonArray.get(i).getAsObject()));
}
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:9,代码来源:ChangeSet.java
示例14: testVocabularyManagement
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
@Test
public void testVocabularyManagement() throws Exception {
RESTResource resource;
String ontoId;
Map<String,String> parameters = new HashMap<String,String>();
// POST vocabulary
String ontoUri = "http://purl.oclc.org/NET/ssnx/qu/qu-rec20";
InputStream uriStream = new ByteArrayInputStream(ontoUri.getBytes("UTF-8"));
resource = vch.post(new URI(baseUri + "/vocab"), parameters, uriStream);
ontoId = resource.path;
Assert.assertTrue("QU ontology not registered", VocabularyUtils.containsVocabulary(ontoUri));
// GET vocabulary by SPARQL query
parameters.clear();
parameters.put("query", "?s ?p ?o");
resource = vch.get(new URI(baseUri + "/vocab"), parameters);
JsonValue ontoIds = JSON.parseAny(resource.content);
Assert.assertTrue("Vocabulary collection is not an array", ontoIds.isArray());
Assert.assertTrue("Vocabulary imports were not added", ontoIds.getAsArray().size() > 1);
Assert.assertTrue("QU ontology not found", ontoIds.getAsArray().contains(new JsonString(ontoId)));
// GET vocabulary by id
VocabularyHandler vh = new VocabularyHandler(ontoId, ThingDirectory.servers);
resource = vh.get(new URI(baseUri + ontoId), null);
ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.content.getBytes());
Model m = ModelFactory.createDefaultModel();
m.read(byteStream, "", "Turtle");
Assert.assertFalse("QU ontology definition is not valid", m.isEmpty());
// DELETE vocabulary
vh.delete(new URI(baseUri + ontoId), null, null);
Assert.assertFalse("QU ontology not deleted", VocabularyUtils.containsVocabulary(ontoUri));
}
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:39,代码来源:ThingWebRepoTest.java
示例15: getStrOrNull
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
/** Access a field of a JSON object : return a string or null */
public static String getStrOrNull(JsonObject obj, String field) {
JsonValue jv = obj.get(field);
if ( jv == null )
return null;
if ( jv.isString() )
return jv.getAsString().value();
return null ;
}
开发者ID:afs,项目名称:rdf-delta,代码行数:10,代码来源:JSONX.java
示例16: getLong
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
/** Access a field of a JSON object : return a {@code long}, or the default value. */
public static long getLong(JsonObject obj, String field, long dftValue) {
JsonValue jv = obj.get(field);
if ( jv == null )
return dftValue;
if ( jv.isNumber() ) {
Number num = jv.getAsNumber().value();
if ( num.doubleValue() < Long.MIN_VALUE || num.doubleValue() > Long.MAX_VALUE )
throw new NumberFormatException("Number out of range: "+jv);
return num.longValue();
}
return dftValue ;
}
开发者ID:afs,项目名称:rdf-delta,代码行数:14,代码来源:JSONX.java
示例17: getInt
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
/** Access a field of a JSON object, return an {@code int} or a default value. */
public static int getInt(JsonObject obj, String field, int dftValue) {
JsonValue jv = obj.get(field);
if ( jv == null )
return dftValue;
if ( jv.isNumber() ) {
long z = jv.getAsNumber().value().longValue();
if ( z < Integer.MIN_VALUE || z > Integer.MAX_VALUE )
throw new NumberFormatException("Number out of range: "+jv);
return (int)z;
}
return dftValue ;
}
开发者ID:afs,项目名称:rdf-delta,代码行数:14,代码来源:JSONX.java
示例18: register
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
private JsonValue register(DeltaAction action) {
Id client = getFieldAsId(action, F_CLIENT);
// XXX Proper Registration - hook to policy here.
RegToken token = new RegToken();
register(client, token);
JsonValue jv = JSONX.buildObject((x)-> {
x.key(F_TOKEN).value(token.getUUID().toString());
});
return jv;
}
开发者ID:afs,项目名称:rdf-delta,代码行数:11,代码来源:S_DRPC.java
示例19: isRegistered
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
private JsonValue isRegistered(DeltaAction action) {
// Registation not checked (it would be a "bad request" - this is done in validateAction)
if ( action.regToken == null )
return resultFalse;
if ( !isRegistered(action.regToken) )
return resultFalse;
return resultTrue;
}
开发者ID:afs,项目名称:rdf-delta,代码行数:9,代码来源:S_DRPC.java
示例20: listDataSources
import org.apache.jena.atlas.json.JsonValue; //导入依赖的package包/类
private JsonValue listDataSources(DeltaAction action) {
List<Id> ids = action.dLink.listDatasets();
return JSONX.buildObject(b->{
b.key(F_ARRAY);
b.startArray();
ids.forEach(id->b.value(id.asPlainString()));
b.finishArray();
});
}
开发者ID:afs,项目名称:rdf-delta,代码行数:10,代码来源:S_DRPC.java
注:本文中的org.apache.jena.atlas.json.JsonValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论