本文整理汇总了Java中org.apache.jena.atlas.json.JsonValue.isString方法的典型用法代码示例。如果您正苦于以下问题:Java JsonValue.isString方法的具体用法?Java JsonValue.isString怎么用?Java JsonValue.isString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.atlas.json.JsonValue
的用法示例。
在下文中一共展示了JsonValue.isString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
}
}
}
示例2: 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;
}
}
示例3: 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");
}
}
}
示例4: 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 ;
}
示例5: getJsonString
import org.apache.jena.atlas.json.JsonValue; //导入方法依赖的package包/类
protected String getJsonString(String key) {
JsonValue v = spec.get(key);
if (v == null) {
return null;
} else if (v.isString()) {
return v.getAsString().value();
} else {
throw new EpiException("Expected json property to be a string but found: " + v);
}
}
示例6: getTemplateRef
import org.apache.jena.atlas.json.JsonValue; //导入方法依赖的package包/类
protected Template getTemplateRef(JsonValue ref, DataContext dc) {
if (ref.isString()) {
return new TemplateRef(ref.getAsString().value(), dc);
} else if (ref.isObject()) {
return TemplateFactory.templateFrom(ref.getAsObject(), dc);
} else {
throw new EpiException("Template must be specified as a name or an embedded object: " + ref);
}
}
示例7: getTemplates
import org.apache.jena.atlas.json.JsonValue; //导入方法依赖的package包/类
protected List<Template> getTemplates(JsonValue tspec, DataContext dc) {
List<Template> templates = new ArrayList<>();
if (tspec != null) {
if (tspec.isObject()) {
templates.add( TemplateFactory.templateFrom(tspec.getAsObject(), dc) );
} else if (tspec.isArray()) {
for (Iterator<JsonValue> i = tspec.getAsArray().iterator(); i.hasNext();) {
templates.add( TemplateFactory.templateFrom(i.next(), dc) );
}
} else if (tspec.isString()) {
templates.add( new TemplateRef(tspec.getAsString().value(), dc) );
}
}
return templates;
}
示例8: templateFrom
import org.apache.jena.atlas.json.JsonValue; //导入方法依赖的package包/类
public static Template templateFrom(JsonValue json, DataContext dc) {
if (json.isArray()) {
JsonArray templates = json.getAsArray();
Template firstTemplate = null;
for (Iterator<JsonValue> i = templates.iterator(); i.hasNext();) {
JsonValue j = i.next();
if (j.isObject()) {
Template t = templateFrom(j.getAsObject(), dc);
if (firstTemplate == null) {
firstTemplate = t;
}
if (t.getName() != null) {
dc.registerTemplate(t);
}
}
}
return firstTemplate;
} else if (json.isObject()) {
JsonObject jo = json.getAsObject();
if (ResourceMapTemplate.isSpec(jo)) {
return new ResourceMapTemplate(jo, dc);
} else if (ParameterizedTemplate.isSpec(jo)) {
return new ParameterizedTemplate(jo, dc);
} else if (HierarchyTemplate.isSpec(jo)) {
return new HierarchyTemplate(jo, dc);
} else if (CompositeTemplate.isSpec(jo)) {
return new CompositeTemplate(jo, dc);
} else {
return null;
}
} else if (json.isString()) {
return new TemplateRef( json.getAsString().value(), dc);
} else {
throw new EpiException("Templates must be specified as a JSON object or an array of objects");
}
}
示例9: getBindingSet
import org.apache.jena.atlas.json.JsonValue; //导入方法依赖的package包/类
protected Map<String, Pattern> getBindingSet(JsonObject binding) {
Map<String, Pattern> map = new HashMap<>();
for (Entry<String, JsonValue> ent : binding.entrySet()) {
JsonValue jv = ent.getValue();
if (jv.isString()) {
Pattern p = new Pattern(jv.getAsString().value(), dc);
map.put(ent.getKey(), p);
} else {
throw new EpiException("Expected binding value to be a string but found: " + jv);
}
}
return map;
}
示例10: getField
import org.apache.jena.atlas.json.JsonValue; //导入方法依赖的package包/类
protected String getField(String name) {
JsonValue field = spec.get(name);
if (field != null) {
JsonValue value = spec.get(name);
if (value.isString()) {
return value.getAsString().value();
}
throw new EpiException("Expected a string value for " + name + " on " + spec);
}
return null;
}