当前位置: 首页>>代码示例>>Java>>正文


Java JsonValue.isArray方法代码示例

本文整理汇总了Java中org.apache.jena.atlas.json.JsonValue.isArray方法的典型用法代码示例。如果您正苦于以下问题:Java JsonValue.isArray方法的具体用法?Java JsonValue.isArray怎么用?Java JsonValue.isArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.atlas.json.JsonValue的用法示例。


在下文中一共展示了JsonValue.isArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
                    }
                }
            }
        }
    }
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:23,代码来源:ResourceMapTemplate.java

示例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;
    }
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:23,代码来源:RDFMapSource.java

示例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");
        }
    }
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:25,代码来源:RDFMapSource.java

示例4: preamble

import org.apache.jena.atlas.json.JsonValue; //导入方法依赖的package包/类
/**
 * Execute any one-off parts of the template
 */
public void preamble(ConverterProcess config, BindingEnv env) {
    if (spec.hasKey(JSONConstants.SOURCES)) {
        JsonValue sspec = spec.get(JSONConstants.SOURCES);
        if (sspec != null) {
            if (sspec.isObject()) {
                processSourceSpec(sspec, config);
            } else if (sspec.isArray()) {
                for (Iterator<JsonValue> i = sspec.getAsArray().iterator(); i.hasNext();) {
                    processSourceSpec(i.next(), config);
                }
            }
        }
    }
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:18,代码来源:TemplateBase.java

示例5: 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;
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:16,代码来源:TemplateBase.java

示例6: 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");
    }
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:38,代码来源:TemplateFactory.java

示例7: parseBindings

import org.apache.jena.atlas.json.JsonValue; //导入方法依赖的package包/类
protected void parseBindings(JsonValue jv) {
    if (jv.isObject()) {
        parameters.add( getBindingSet( jv.getAsObject() ) );
    } else if (jv.isArray()) {
        Iterator<JsonValue> i = jv.getAsArray().iterator();
        while (i.hasNext()) {
            parseBindings(i.next());
        }
    } else {
        throw new EpiException("Illegal value for bind, bindings must be objects or arrays of objects");
    }
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:13,代码来源:ParameterizedTemplate.java

示例8: setParameters

import org.apache.jena.atlas.json.JsonValue; //导入方法依赖的package包/类
/**
 * Set the parameters to show in the configuration window, and create UI elements for the user to set them.
 *
 * @param jsonParamDescriptions Parameters as specified by the JedAI library
 */
public void setParameters(JsonArray jsonParamDescriptions, ListProperty<JPair<String, Object>> parametersProperty) {
    this.jsonParamDescriptions = jsonParamDescriptions;
    this.parametersProperty = parametersProperty;

    // Determine if there are, and we should use previously set values for the parameters
    ObservableList<JPair<String, Object>> prevParams = parametersProperty.get();

    boolean usePrevParams = false;
    if (prevParams != null && !prevParams.isEmpty() && prevParams.size() == jsonParamDescriptions.size()) {
        // We can use the previously set parameters for this
        usePrevParams = true;
    }

    // If the method is parameter-free, display it
    if (this.jsonParamDescriptions.isEmpty()) {
        configureParamsLabel.setText("This is a parameter-free method!");
    } else {
        // Generate the form to configure the method
        int gridRows = 0;
        for (JsonValue jsonParam : this.jsonParamDescriptions) {
            if (jsonParam.isObject()) {
                JsonObject jsonParamObj = jsonParam.getAsObject();

                // If we have previous values for the parameters, modify the JSON object's default value
                if (usePrevParams) {
                    // Save original default value to another parameter, in order to be able to display it
                    JsonValue originalDefault = jsonParamObj.get("defaultValue");
                    if (originalDefault != null) {
                        jsonParamObj.put("defaultValueOriginal", originalDefault);
                    }

                    // Put as the new defaultValue the previous one
                    jsonParamObj.put("defaultValue", prevParams.get(gridRows).getRight().toString());
                }

                // Create controls for setting this parameter
                addParameterControls(jsonParamObj, gridRows++);
            } else if (jsonParam.isArray()) {
                throw new UnsupportedOperationException("Cannot handle JSON array yet (?)");
            }
        }
    }
}
 
开发者ID:scify,项目名称:jedai-ui,代码行数:49,代码来源:DynamicConfigurationController.java


注:本文中的org.apache.jena.atlas.json.JsonValue.isArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。