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


Java RDFList类代码示例

本文整理汇总了Java中org.apache.jena.rdf.model.RDFList的典型用法代码示例。如果您正苦于以下问题:Java RDFList类的具体用法?Java RDFList怎么用?Java RDFList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RDFList类属于org.apache.jena.rdf.model包,在下文中一共展示了RDFList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: orderBy

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
public SelectBuilder orderBy(Resource condition)
   {
if (condition == null) throw new IllegalArgumentException("ORDER BY condition cannot be null");
Variable var = SPINFactory.asVariable(condition);
if (var != null && !isWhereVariable(var))
{
    if (log.isErrorEnabled()) log.error("Variable var: {} not in the WHERE pattern", var);
    throw new IllegalArgumentException("Cannot ORDER BY variable '" + var + "' that is not specified in the WHERE pattern");
}
if (condition.hasProperty(SP.expression))
{
    Variable exprVar = SPINFactory.asVariable(condition.getPropertyResourceValue(SP.expression));
    if (exprVar != null && !isWhereVariable(exprVar)) throw new IllegalArgumentException("Cannot ORDER BY variable that is not specified in the WHERE pattern");
}
if (log.isTraceEnabled()) log.trace("Setting ORDER BY condition: {}", condition);

if (hasProperty(SP.orderBy))
    getPropertyResourceValue(SP.orderBy).as(RDFList.class).add(condition);
else
    addProperty(SP.orderBy, getModel().createList(new RDFNode[]{condition}));

return this;
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:24,代码来源:SelectBuilder.java

示例2: exportLogicalTypeInfo

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
protected void exportLogicalTypeInfo(IfcLogicalTypeInfo typeInfo) {

		String typeUri = formatExpressOntologyName(typeInfo.getName());
		Resource typeResource = createUriResource(typeUri);
		jenaModel.add(typeResource, RDF.type, OWL.Class);

		List<LogicalEnum> enumValues = typeInfo.getValues();
		List<RDFNode> enumValueNodes = new ArrayList<>();

		for (LogicalEnum value : enumValues) {
			enumValueNodes.add(createUriResource(formatExpressOntologyName(value.toString())));
		}

		final boolean enumerationIsSupported = owlProfileList.supportsStatement(OWL.oneOf, RdfVocabulary.DUMP_URI_LIST);

		if (enumerationIsSupported) {
			RDFList rdfList = createList(enumValueNodes);
			jenaModel.add(typeResource, OWL.oneOf, rdfList);
		} else { // if
					// (!context.isEnabledOption(Ifc2RdfConversionParamsEnum.ForceConvertLogicalValuesToString))
					// {
			enumValueNodes.stream().forEach(
					node -> jenaModel.add((Resource) node, RDF.type,
							typeResource));
		}
	}
 
开发者ID:Web-of-Building-Data,项目名称:drumbeat-ifc2ld,代码行数:27,代码来源:Ifc2RdfExporterBase.java

示例3: toXML

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
public boolean toXML(Element e, RDFNode rdf, Context ctx) {
	boolean ok =true;
	try {
		schema xsd = (schema) this.get_owner();
		simpleType t = get_type(ctx);
		String type = null;
		if (t==null) type = expandQName(ctx.getDefaultNS(),itemType, ctx.getModel());

		RDFList list = (RDFList) rdf.as(RDFList.class);
		String pack = null;
		for (ExtendedIterator i = list.iterator(); ok && i.hasNext(); ) {
			RDFNode n = (RDFNode) i.next();	
			if (t!=null) ok=t.toXML(e,n,pack,ctx);
			else ok=xsd.toXMLText(e,n,type,pack,ctx);
			pack = " "; // whitespace separator
		}
	} catch (Exception ex) { // non-fatal
		Gloze.logger.warn("failed to list value");
	}
	return ok;
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:22,代码来源:list.java

示例4: toRDFList

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
public RDFList toRDFList(Node node, String value, RDFList list, Set<restriction> restrictions, Context ctx) 
throws Exception {
	schema xs = (schema) this.get_owner();
	
	// record restrictions if not already doing so
	if (restrictions==null) restrictions = new HashSet<restriction>();
	
	// get (resolved) member types
	Vector<MemberType> v = get_memberTypes(ctx);
	for (int i=0; i<v.size(); i++) {
		// isolate restrictions on each member
		Set<restriction> r = new HashSet<restriction>();
		r.addAll(restrictions);
		MemberType m = v.elementAt(i);
		simpleType s = m.getSimpleType();
		RDFList l;
		if (s!=null && (l=s.toRDFList(node,value,list,r,ctx))!=null) return l;
		else if (s==null && (l=schema.toRDFList(node,value,m.getType(),list,r,ctx))!=null) return l;
	}
	return null;
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:22,代码来源:union.java

示例5: toXMLText

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
public boolean toXMLText(Element element, RDFNode rdf, String type, String pack, Context ctx) {
	String v;
	Document doc = element.getOwnerDocument();
	
	simpleType s = ctx.getSimpleType(type);
	if (s!=null) return s.toXML(element,rdf,pack,ctx);

	if (type!=null && type.equals(XSD_URI+"#IDREFS") && rdf instanceof Resource
			&& ((Resource)rdf).hasProperty(RDF.first)
			&& rdf.canAs(RDFList.class)) {
		RDFList l = (RDFList) rdf.as(RDFList.class);
		for (ExtendedIterator i=l.iterator(); i.hasNext();) {
			v = toXMLValue(element, (RDFNode) i.next(), XSD.IDREF.getURI(), ctx);
			if (v==null) return false; // failed for this type
			element.appendChild(doc.createTextNode(pack==null?v:pack+v));
			pack = " ";
		}
		return true;
	}
	String val = toXMLValue(element, rdf, type, ctx);
	if (val!=null) {
		element.appendChild(doc.createTextNode(pack==null?val:pack+val));
		return true;
	}
	return false;
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:27,代码来源:schema.java

示例6: toXML

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
private void toXML(Element e, Context ctx, attribute def, String type, RDFNode object) 
throws Exception {
	Document doc = e.getOwnerDocument();
	schema xs = (schema) this.get_owner();
	Attr a;
	if (isQualified()) {
		String ns = xs.getTargetNamespace();
		a = doc.createAttributeNS(ns, def.getName());
		//if (Character.isLetterOrDigit(ns.charAt(ns.length()-1))) ns += "#";
		a.setPrefix(ctx.getModel().getNsURIPrefix(ns));
		e.setAttributeNodeNS(a);
	}
	else e.setAttributeNode(a = doc.createAttribute(def.getName()));

	XMLBean t = get_type(ctx);
	if (t instanceof simpleType) ((simpleType) t).toXML(a,object,ctx);
	else if (type != null && type.endsWith("IDREFS"))
		xs.listToXML(a,(RDFList) object.as(RDFList.class),XSD.IDREF.getURI(),ctx);
	else a.setValue(xs.toXMLValue(e,object,type,ctx));
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:21,代码来源:attribute.java

示例7: toRDFList

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
public RDFList toRDFList(Node node, String value, RDFList list, Set<restriction> restrictions, Context ctx) 
throws Exception {	
	schema xs = (schema) this.get_owner();
	Model m = ctx.getModel();
	// only add restriction if required
	if (restrictions!=null) restrictions.add(this);

	// user-defined simple base
	simpleType s = (simpleType) get_baseType(m,ctx);
	if (s!=null) return s.toRDFList(node,value,list,restrictions,ctx);
	else {
		if (restrictions!=null)
			for (restriction r: restrictions) 
				if (!r.isValid(value,expandQName(ctx.getDefaultNS(),base, m),ctx)) return null;
		
		String type = expandQName(ctx.getDefaultNS(),base, m);
		if (whiteSpace!=null) whiteSpace.toRDFList(node,value,type,list,ctx);
		else return schema.toRDFList(node,value,type,list,restrictions,ctx);
		return list;
	}
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:22,代码来源:restriction.java

示例8: isValid

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
public boolean isValid(String value, String type, RDFList list, Context ctx) {
	if (value==null) return false;
	// ensure value is enumerated
	boolean valid = _enumeration==null && pattern==null;
	for (int i = 0;  !valid && _enumeration!=null && i < _enumeration.length; i++)
		valid=_enumeration[i].isValid(value,type);
	for (int i = 0;  !valid && pattern!=null && i < pattern.length; i++)
		valid=pattern[i].isValid(value,type);

	// these may relate to the length of the sequence
	if (length!=null && !length.isValid(value,type,list)) return false;
	if (minLength!=null && !minLength.isValid(value,type,list)) return false;
	if (maxLength!=null && !maxLength.isValid(value,type,list)) return false;	
	if (minInclusive!=null && !minInclusive.isValid(value,type)) return false;
	if (maxInclusive!=null && !maxInclusive.isValid(value,type)) return false;
	if (minExclusive!=null && !minExclusive.isValid(value,type)) return false;
	if (maxExclusive!=null && !maxExclusive.isValid(value,type)) return false;
	if (totalDigits!=null && !totalDigits.isValid(value,type)) return false;
	if (fractionDigits!=null && !fractionDigits.isValid(value,type)) return false;
	return valid;
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:22,代码来源:restriction.java

示例9: isValid

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
public boolean isValid(String value, String type, RDFList list) {
	if (list!=null) return Integer.parseInt(this.value)==list.size();

	// if the type is QName or Notation then any length is valid
	if (type.equals(schema.XSD_URI+"#QName")) return true;
	if (type.equals(schema.XSD_URI+"#NOTATION")) return true;
	if (type.equals(schema.XSD_URI+"#base64Binary")
	 || type.equals(schema.XSD_URI+"#hexBinary")) {
		byte[] b = (byte[]) getDatatype(type).parse(value);
		return b.length == Integer.parseInt(this.value);
	}
	if (type.equals(schema.XSD_URI+"#normalizedString")) {
		return Integer.parseInt(this.value)==schema.normalizeString(value).length();
	}
	return Integer.parseInt(this.value)==value.length();
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:17,代码来源:length.java

示例10: doCheckNumericNotations

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
/**
 * Check use of numeric literals as notation values, both that
 * they survive processing and that register page listing orders
 * numerically instead of lexically in that case.
 */
private void doCheckNumericNotations() {
    assertEquals(201, postFileStatus("test/codes.ttl", BASE_URL));
    assertEquals(201, postFileStatus("test/jmt/runway-numeric.ttl", BASE_URL + "codes"));
    Model m = getModelResponse(BASE_URL + "codes?_view=with_metadata&firstPage");
    Resource page = findOneOf(m, ROOT_REGISTER + "codes", "_view=with_metadata&firstPage=",  "firstPage=&_view=with_metadata");
    Resource items = page.getPropertyResourceValue(API.items);
    assertNotNull(items);
    List<RDFNode> itemList = items.as(RDFList.class).asJavaList();
    int[] expected = new int[]{7, 8, 9, 15};
    for (int i = 0; i < expected.length; i++) {
        int e = expected[i];
        Resource item = itemList.get(i).asResource();
        assertTrue(item.getURI().endsWith("/" + e));
        Resource meta = m.getResource(ROOT_REGISTER + "codes/_" + e);
        Object value = meta.getProperty(RegistryVocab.notation).getObject().asLiteral().getValue();
        assert(value instanceof Number);
        assertEquals(e, ((Number)value).intValue());
    }
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:25,代码来源:TestAPI.java

示例11: getLabel

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
/**
 * Gets the label for a given Resource.
 * @param resource  the Resource to get the label of
 * @return the label (never null)
 */
public String getLabel(Resource resource) {
	if(resource.isURIResource() && resource.getModel() != null) {
		String qname = resource.getModel().qnameFor(resource.getURI());
		if(qname != null) {
			return qname;
		}
		else {
			return "<" + resource.getURI() + ">";
		}
	}
	else if(resource.isAnon() && resource.getModel() != null && resource.hasProperty(RDF.first)) {
		StringBuffer buffer = new StringBuffer("[");
		Iterator<RDFNode> members = resource.as(RDFList.class).iterator();
		while(members.hasNext()) {
			RDFNode member = members.next();
			buffer.append(RDFLabels.get().getNodeLabel(member));
			if(members.hasNext()) {
				buffer.append(", ");
			}
		}
		buffer.append("]");
		return buffer.toString();
	}
	else {
		return resource.toString();
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:33,代码来源:RDFLabels.java

示例12: getListProperty

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
public static RDFList getListProperty(Resource subject, Property predicate) {
	Statement s = subject.getProperty(predicate);
	if(s != null && s.getObject().canAs(RDFList.class)) {
		return s.getResource().as(RDFList.class);
	}
	else {
		return null;
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:10,代码来源:JenaUtil.java

示例13: collectItems

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
private void collectItems(File manifestFile, String baseURI) throws IOException {
	
	String filePath = manifestFile.getAbsolutePath().replaceAll("\\\\", "/");
	int coreIndex = filePath.indexOf("core/");
	if(coreIndex > 0 && !filePath.contains("sparql/core")) {
		filePath = filePath.substring(coreIndex);
	}
	else {
		int sindex = filePath.indexOf("sparql/");
		if(sindex > 0) {
			filePath = filePath.substring(sindex);
		}
	}
	
	Model model = JenaUtil.createMemoryModel();
	model.read(new FileInputStream(manifestFile), baseURI, FileUtils.langTurtle);
	
	for(Resource manifest : model.listSubjectsWithProperty(RDF.type, MF.Manifest).toList()) {
		for(Resource include : JenaUtil.getResourceProperties(manifest, MF.include)) {
			String path = include.getURI().substring(baseURI.length());
			File includeFile = new File(manifestFile.getParentFile(), path);
			if(path.contains("/")) {
				String addURI = path.substring(0, path.indexOf('/'));
				collectItems(includeFile, baseURI + addURI + "/");
			}
			else {
				collectItems(includeFile, baseURI + path);
			}
		}
		for(Resource entries : JenaUtil.getResourceProperties(manifest, MF.entries)) {
			for(RDFNode entry : entries.as(RDFList.class).iterator().toList()) {
				items.add(new Item(entry.asResource(), filePath, manifestFile));
			}
		}
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:37,代码来源:W3CTestRunner.java

示例14: appendPathBlankNode

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
private static void appendPathBlankNode(StringBuffer sb, Resource path, String separator) {
	if(path.hasProperty(RDF.first)) {
		Iterator<RDFNode> it = path.as(RDFList.class).iterator();
		while(it.hasNext()) {
			Resource item = (Resource) it.next();
			appendNestedPath(sb, item, SEQUENCE_PATH_SEPARATOR);
			if(it.hasNext()) {
				sb.append(" ");
				sb.append(separator);
				sb.append(" ");
			}
		}
	}
	else if(path.hasProperty(SH.inversePath)) {
		sb.append("^");
		if(path.getProperty(SH.inversePath).getObject().isAnon()) {
			sb.append("(");
			appendPath(sb, JenaUtil.getResourceProperty(path, SH.inversePath));
			sb.append(")");
		}
		else {
			appendPath(sb, JenaUtil.getResourceProperty(path, SH.inversePath));
		}
	}
	else if(path.hasProperty(SH.alternativePath)) {
		appendNestedPath(sb, JenaUtil.getResourceProperty(path, SH.alternativePath), ALTERNATIVE_PATH_SEPARATOR);
	}
	else if(path.hasProperty(SH.zeroOrMorePath)) {
		appendNestedPath(sb, JenaUtil.getResourceProperty(path, SH.zeroOrMorePath), SEQUENCE_PATH_SEPARATOR);
		sb.append("*");
	}
	else if(path.hasProperty(SH.oneOrMorePath)) {
		appendNestedPath(sb, JenaUtil.getResourceProperty(path, SH.oneOrMorePath), SEQUENCE_PATH_SEPARATOR);
		sb.append("+");
	}
	else if(path.hasProperty(SH.zeroOrOnePath)) {
		appendNestedPath(sb, JenaUtil.getResourceProperty(path, SH.zeroOrOnePath), SEQUENCE_PATH_SEPARATOR);
		sb.append("?");
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:41,代码来源:SHACLPaths.java

示例15: replaceOrderBy

import org.apache.jena.rdf.model.RDFList; //导入依赖的package包/类
public SelectBuilder replaceOrderBy(RDFList conditions)
   {
if (log.isTraceEnabled()) log.trace("Removing all ORDER BY conditions");
removeAll(SP.orderBy);

if (conditions != null)
{
    if (log.isTraceEnabled()) log.trace("Setting ORDER BY conditions: {}", conditions);
    addProperty(SP.orderBy, conditions);
}

return this;
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:14,代码来源:SelectBuilder.java


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