本文整理汇总了Java中com.hp.hpl.jena.vocabulary.OWL2类的典型用法代码示例。如果您正苦于以下问题:Java OWL2类的具体用法?Java OWL2怎么用?Java OWL2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OWL2类属于com.hp.hpl.jena.vocabulary包,在下文中一共展示了OWL2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCardinalityRestriction
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private CardinalityRestriction createCardinalityRestriction(
ConceptName prop, OntProperty p, int i,
ClassRestrictionCondition rCond, int j) {
if (p == null) {
addError(2,
"Cardinality restriction can't tell if property '" + prop + "' is object or data property.");
return null;
} else {
int card = rCond.getRestrictedToCardinality();
CardinalityRestriction cr = getJenaModel()
.createCardinalityRestriction(null, p, card);
if (cr != null && rCond.getRestrictedToObject() != null) {
cr.removeAll(OWL.cardinality);
cr.addLiteral(OWL2.qualifiedCardinality, new Integer(rCond.getRestrictedToCardinality()));
OntClass qualifiedCls = conceptIdentifierToOntClass(i, j, (ConceptIdentifier) rCond.getRestrictedToObject());
cr.addProperty(OWL2.onClass, qualifiedCls);
}
return cr;
}
}
示例2: createMaxCardinalityRestriction
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private MaxCardinalityRestriction createMaxCardinalityRestriction(
ConceptName prop, OntProperty p, int i,
ClassRestrictionCondition rCond, int j) {
if (p == null) {
addError(2,
"Max cardinality restriction can't tell if property '" + prop + "' is object or data property.");
return null;
} else {
int card = rCond.getRestrictedToCardinality();
MaxCardinalityRestriction cr = getJenaModel()
.createMaxCardinalityRestriction(null, p, card);
if (cr != null && rCond.getRestrictedToObject() != null) {
cr.removeAll(OWL.maxCardinality);
cr.addLiteral(OWL2.maxQualifiedCardinality, new Integer(rCond.getRestrictedToCardinality()));
OntClass qualifiedCls = conceptIdentifierToOntClass(i, j, (ConceptIdentifier) rCond.getRestrictedToObject());
cr.addProperty(OWL2.onClass, qualifiedCls);
}
return cr;
}
}
示例3: createMinCardinalityRestriction
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private MinCardinalityRestriction createMinCardinalityRestriction(
ConceptName prop, OntProperty p, int i,
ClassRestrictionCondition rCond, int j) {
if (p == null) {
addError(2,
"Min cardinality restriction can't tell if property '" + prop + "' is object or data property.");
return null;
} else {
int card = rCond.getRestrictedToCardinality();
MinCardinalityRestriction cr = getJenaModel()
.createMinCardinalityRestriction(null, p, card);
if (cr != null && rCond.getRestrictedToObject() != null) {
cr.removeAll(OWL.minCardinality);
cr.addLiteral(OWL2.minQualifiedCardinality, new Integer(rCond.getRestrictedToCardinality()));
OntClass qualifiedCls = conceptIdentifierToOntClass(i, j, (ConceptIdentifier) rCond.getRestrictedToObject());
cr.addProperty(OWL2.onClass, qualifiedCls);
}
return cr;
}
}
示例4: isDeprecationDeclaration
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
/**
* Checks if a given statement is a deprecation declaration. If so, the
* statement is not a violation w.r.t. this metric, since the deprecation
* declaration of a resource is not considered as resource usage. Thus,
* if a resource is just declared to be deprecated, this is not a violation.
* Only if the so declared resource is actually used, this a violation will
* be reported.
*
* @param statement A statement to check
* @return is the checked statement a deprecation declaration
*/
private boolean isDeprecationDeclaration(Statement statement) {
Resource subj = statement.getSubject();
Property pred = statement.getPredicate();
RDFNode obj = statement.getObject();
// owl:deprecated "true"^^xsd:boolean
if (pred.equals(OWL2.deprecated) && obj.equals(trueLiteral)) {
return true;
}
// <class> rdf:type owl:DeprecetedClass
if (pred.equals(RDF.type) && obj.equals(OWL.DeprecatedClass)) {
return true;
}
// owl:DeprecatedClass owl:equivalentClass <class>
if (subj.equals(OWL.DeprecatedClass) && pred.equals(OWL.equivalentClass)) {
return true;
}
// <class> owl:equivalentClass owl:DeprecatedClass
if (pred.equals(OWL.equivalentClass) && obj.equals(OWL.DeprecatedClass)) {
return true;
}
// <prop> rdf:type owl:DeprecatedProperty
if (pred.equals(RDF.type) && obj.equals(OWL.DeprecatedProperty)) {
return true;
}
// <prop> owl:equivalentProperty owl:DeprecatedProperty
if (pred.equals(OWL.equivalentProperty) && obj.equals(OWL.DeprecatedProperty)) {
return true;
}
// owl:DeprecatedProperty owl:equivalentProperty <prop>
if (subj.equals(OWL.DeprecatedProperty) && pred.equals(OWL.equivalentProperty)) {
return true;
}
return false;
}
示例5: dataset23
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private SparqlifyDataset dataset23() {
String content =
"<http://ex.org/Cls01> <" + RDF.type.getURI() + "> <" + RDFS.Class.getURI() + "> . " +
"<http://ex.org/pred01> <" + RDF.type.getURI() + "> <" + RDF.Property.getURI() + "> . " +
"<http://ex.org/pred01> <" + RDFS.range.getURI() + "> <" + XSD.xstring.getURI() + "> . " +
"<http://ex.org/res/01> <" + OWL2.deprecated.getURI() + "> \"true\"^^<" + XSD.xboolean.getURI() + "> ." +
"<http://ex.org/pred02> <" + RDFS.subPropertyOf.getURI() + "> <http://ex.org/pred01> . ";
SparqlifyDataset dataset = new SparqlifyDataset();
Reader reader = new StringReader(content);
dataset.read(reader, null, "TTL");
return dataset;
}
示例6: dataset24
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private SparqlifyDataset dataset24() {
String content =
"<http://ex.org/Cls01> <" + RDF.type.getURI() + "> <" + RDFS.Class.getURI() + "> . " +
"<http://ex.org/pred01> <" + RDF.type.getURI() + "> <" + RDF.Property.getURI() + "> . " +
"<http://ex.org/pred01> <" + RDFS.range.getURI() + "> <" + XSD.xstring.getURI() + "> . " +
"<http://ex.org/res/01> <" + OWL2.deprecated.getURI() + "> \"true\"^^<" + XSD.xboolean.getURI() + "> ." +
"<http://ex.org/res/01> <http://ex.org/pred02> \"Sth\" . " +
"<http://ex.org/pred02> <" + RDFS.subPropertyOf.getURI() + "> <http://ex.org/pred01> . ";
SparqlifyDataset dataset = new SparqlifyDataset();
Reader reader = new StringReader(content);
dataset.read(reader, null, "TTL");
return dataset;
}
示例7: dataset25
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private SparqlifyDataset dataset25() {
String content =
"<http://ex.org/Cls01> <" + RDF.type.getURI() + "> <" + RDFS.Class.getURI() + "> . " +
"<http://ex.org/res/01> <" + RDF.type.getURI() + "> <http://ex.org/Cls01> ." +
"<http://ex.org/res/01> <http://ex.org/pred01> \"Sth\" . " +
"<http://ex.org/pred01> <" + OWL2.deprecated.getURI() + "> \"true\"^^<" + XSD.xboolean.getURI() + "> .";
SparqlifyDataset dataset = new SparqlifyDataset();
Reader reader = new StringReader(content);
dataset.read(reader, null, "TTL");
return dataset;
}
示例8: dataset26
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private SparqlifyDataset dataset26() {
String content =
"<http://ex.org/Cls01> <" + RDF.type.getURI() + "> <" + RDFS.Class.getURI() + "> . " +
"<http://ex.org/pred01> <" + RDF.type.getURI() + "> <" + RDF.Property.getURI() + "> . " +
"<http://ex.org/pred01> <" + RDFS.range.getURI() + "> <" + XSD.xstring.getURI() + "> . " +
"<http://ex.org/res/02> <http://ex.org/pred02> <http://ex.org/res/01> . " +
"<http://ex.org/res/01> <" + OWL2.deprecated.getURI() + "> \"true\"^^<" + XSD.xboolean.getURI() + "> ." +
"<http://ex.org/pred02> <" + RDFS.subPropertyOf.getURI() + "> <http://ex.org/pred01> . ";
SparqlifyDataset dataset = new SparqlifyDataset();
Reader reader = new StringReader(content);
dataset.read(reader, null, "TTL");
return dataset;
}
示例9: createRdfsDatatype
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private OntClass createRdfsDatatype(String newDatatypeUri, List<RDFNode> unionOfTypes,
com.hp.hpl.jena.rdf.model.Resource onDatatype, SadlDataTypeFacet facet) throws JenaProcessorException {
OntClass datatype = getTheJenaModel().createOntResource(OntClass.class, RDFS.Datatype, newDatatypeUri);
OntClass equivClass = getTheJenaModel().createOntResource(OntClass.class, RDFS.Datatype, null);
if (onDatatype != null) {
equivClass.addProperty(OWL2.onDatatype, onDatatype);
if (facet != null) {
com.hp.hpl.jena.rdf.model.Resource restrictions = facetsToRestrictionNode(newDatatypeUri, facet);
// Create a list containing the restrictions
RDFList list = getTheJenaModel().createList(new RDFNode[] { restrictions });
equivClass.addProperty(OWL2.withRestrictions, list);
}
} else if (unionOfTypes != null) {
Iterator<RDFNode> iter = unionOfTypes.iterator();
RDFList collection = getTheJenaModel().createList();
while (iter.hasNext()) {
RDFNode dt = iter.next();
collection = collection.with(dt);
}
equivClass.addProperty(OWL.unionOf, collection);
} else {
throw new JenaProcessorException("Invalid arguments to createRdfsDatatype");
}
datatype.addEquivalentClass(equivClass);
TypeMapper.getInstance().getSafeTypeByName(newDatatypeUri);
return datatype;
}
示例10: isSingleValued
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
public static boolean isSingleValued(OntClass cls, OntProperty prop, String rngString) {
if (prop.isFunctionalProperty()) {
return true;
}
if (cls != null) {
ExtendedIterator<OntClass> eitr = cls.listSuperClasses(false);
while (eitr.hasNext()) {
OntClass supercls = eitr.next();
if (supercls.isRestriction()) {
Restriction rstrct = supercls.asRestriction();
if (rstrct.isMaxCardinalityRestriction()) {
MaxCardinalityRestriction mxcr = rstrct.asMaxCardinalityRestriction();
if (mxcr.getOnProperty().equals(prop) && mxcr.getMaxCardinality() == 1) {
return true;
}
}
else if (rstrct.isCardinalityRestriction()) {
if (rstrct.isCardinalityRestriction()) {
CardinalityRestriction cr = rstrct.asCardinalityRestriction();
if (cr.getOnProperty().equals(prop) && cr.getCardinality() == 1) {
return true;
}
}
}
else {
if (rstrct.hasProperty(OWL2.maxQualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.maxQualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
else if (rstrct.hasProperty(OWL2.qualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.qualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
// StmtIterator siter = rstrct.listProperties();
// while (siter.hasNext()) {
// System.out.println(siter.nextStatement().toString());
// }
}
}
}
}
return false;
}
示例11: isSingleValued
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
public static synchronized boolean isSingleValued(OntClass cls, OntProperty prop, String rngString) {
if (prop.isFunctionalProperty()) {
return true;
}
if (cls != null) {
ExtendedIterator<OntClass> eitr = cls.listSuperClasses(false);
while (eitr.hasNext()) {
OntClass supercls = eitr.next();
if (supercls.isRestriction()) {
Restriction rstrct = supercls.asRestriction();
if (rstrct.isMaxCardinalityRestriction()) {
MaxCardinalityRestriction mxcr = rstrct.asMaxCardinalityRestriction();
if (mxcr.getOnProperty().equals(prop) && mxcr.getMaxCardinality() == 1) {
return true;
}
}
else if (rstrct.isCardinalityRestriction()) {
if (rstrct.isCardinalityRestriction()) {
CardinalityRestriction cr = rstrct.asCardinalityRestriction();
if (cr.getOnProperty().equals(prop) && cr.getCardinality() == 1) {
return true;
}
}
}
else {
if (rstrct.hasProperty(OWL2.maxQualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.maxQualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
else if (rstrct.hasProperty(OWL2.qualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.qualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
}
}
}
}
return false;
}
示例12: createTypeCheckInfoForPropertyRange
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private TypeCheckInfo createTypeCheckInfoForPropertyRange(RDFNode first, ConceptName propConceptName,
EObject expression, ConceptType propertyType) throws InvalidTypeException, TranslationException, InvalidNameException {
TypeCheckInfo tci = null;
NamedNode rangeNamedNode = getModelProcessor().validateNamedNode(new NamedNode(first.asResource().getURI(), NodeType.DataTypeNode));
// ConceptName rangeConceptName = new ConceptName(first.asResource().getURI());
if (propertyType.equals(ConceptType.DATATYPEPROPERTY)) {
// rangeConceptName.setType(ConceptType.RDFDATATYPE);
OntResource range;
range = theJenaModel.getOntResource(rangeNamedNode.toFullyQualifiedString());
if (theJenaModel.listStatements(range, RDF.type, RDFS.Datatype).hasNext()) {
// this is a user-defined datatype
RDFNode rngEC = range.listPropertyValues(OWL.equivalentClass).next();
if (rngEC != null && rngEC.canAs(OntResource.class)) {
RDFNode baseType = rngEC.as(OntResource.class).listPropertyValues(OWL2.onDatatype).next();
if (baseType != null && baseType.isURIResource()) {
NamedNode tctype = getModelProcessor().validateNamedNode(new NamedNode(baseType.asResource().getURI(), NodeType.DataTypeNode));
tci = new TypeCheckInfo(propConceptName, tctype, this, expression);
}
}
}
else {
// rangeConceptName.setRangeValueType(propConceptName.getRangeValueType());
if (propConceptName.getRangeValueType().equals(RangeValueType.LIST)) {
rangeNamedNode.setNodeType(NodeType.DataTypeListNode);
}
}
}
else {
rangeNamedNode.setNodeType(NodeType.ClassNode);
}
List<ConceptName> impliedProperties = getImpliedProperties(first.asResource());
if (tci == null) {
tci = new TypeCheckInfo(propConceptName, rangeNamedNode, impliedProperties, this, expression);
}
else if (impliedProperties != null){
tci.addImplicitProperties(impliedProperties);
}
if (isTypedListSubclass(first)) {
tci.setRangeValueType(RangeValueType.LIST);
if (first.isURIResource()) {
// looks like a named list in which case we probably have the wrong type
if (!first.asResource().canAs(OntClass.class)){
issueAcceptor.addError("Unexpected non-OntClass named list, please report." , expression);
}
return getSadlTypedListTypeCheckInfo(first.asResource().as(OntClass.class), propConceptName, expression, propertyType);
}
}
return tci;
}
示例13: isSingleValued
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
public static synchronized boolean isSingleValued(OntClass cls, OntProperty prop, String rngString) {
if (prop.isFunctionalProperty()) {
return true;
}
if (cls != null) {
ExtendedIterator<OntClass> eitr = cls.listSuperClasses(false);
while (eitr.hasNext()) {
OntClass supercls = eitr.next();
if (supercls.isRestriction()) {
Restriction rstrct = supercls.asRestriction();
if (rstrct.isMaxCardinalityRestriction()) {
MaxCardinalityRestriction mxcr = rstrct.asMaxCardinalityRestriction();
if (mxcr.getOnProperty().equals(prop) && mxcr.getMaxCardinality() == 1) {
return true;
}
}
else if (rstrct.isCardinalityRestriction()) {
if (rstrct.isCardinalityRestriction()) {
CardinalityRestriction cr = rstrct.asCardinalityRestriction();
if (cr.getOnProperty().equals(prop) && cr.getCardinality() == 1) {
return true;
}
}
}
else {
if (rstrct.hasProperty(OWL2.maxQualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.maxQualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
else if (rstrct.hasProperty(OWL2.qualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.qualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
// StmtIterator siter = rstrct.listProperties();
// while (siter.hasNext()) {
// System.out.println(siter.nextStatement().toString());
// }
}
}
}
}
return false;
}
示例14: addResourceMetadata
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private void addResourceMetadata(Model model, Resource basicResource) {
// Exit early if null
if (basicResource == null)
return;
com.hp.hpl.jena.rdf.model.Resource current = model.createResource(basicResource.getUri().toASCIIString());
// Label
String label = basicResource.getLabel();
if (label != null) {
current.addProperty(RDFS.label, label);
}
// Comment
String comment = basicResource.getComment();
if (comment != null) {
current.addProperty(RDFS.comment, comment);
}
// Creator
URI creator = basicResource.getCreator();
if (creator != null) {
current.addProperty(DCTerms.creator,
model.createResource(creator.toASCIIString()));
}
// seeAlso
if (basicResource.getSeeAlsos() != null) {
for (URI seeAlso : basicResource.getSeeAlsos()) {
current.addProperty(RDFS.seeAlso,
model.createResource(seeAlso.toASCIIString()));
}
}
// Source
URI source = basicResource.getSource();
if (source != null) {
current.addProperty(DCTerms.source,
model.createResource(source.toASCIIString()));
}
// Created
Date created = basicResource.getCreated();
Literal createdLiteral = createDateLiteral(created);
if (createdLiteral != null) {
current.addProperty(DCTerms.created, createdLiteral);
}
// Issued
Date issued = basicResource.getIssued();
Literal issuedLiteral = createDateLiteral(issued);
if (issuedLiteral != null) {
current.addProperty(DCTerms.issued, issuedLiteral);
}
// Licenses
if (basicResource.getLicenses() != null) {
for (URI license : basicResource.getLicenses()) {
current.addProperty(DCTerms.license, model.createResource(license.toASCIIString()));
}
}
// owl:sameAs
if (basicResource.getSameAsIndividuals() != null) {
for (URI sameAs : basicResource.getSameAsIndividuals()) {
current.addProperty(OWL2.sameAs, model.createResource(sameAs.toASCIIString()));
}
}
}
示例15: setResourceProperties
import com.hp.hpl.jena.vocabulary.OWL2; //导入依赖的package包/类
private void setResourceProperties(Individual individual, uk.ac.open.kmi.msm4j.Resource result) throws URISyntaxException {
Resource res;
result.setComment(individual.getComment(null));
result.setLabel(individual.getLabel(null));
// seeAlso
NodeIterator seeAlsoIterator = individual.listPropertyValues(RDFS.seeAlso);
for (RDFNode seeAlsoValue : seeAlsoIterator.toList()) {
result.addSeeAlso(new URI(seeAlsoValue.asResource().getURI()));
}
// source
res = individual.getPropertyResourceValue(DCTerms.source);
if (res != null) {
result.setSource(new URI(res.getURI()));
}
// creator
res = individual.getPropertyResourceValue(DCTerms.creator);
if (res != null) {
result.setCreator(new URI(res.getURI()));
}
// created
Date created = getDate(individual, DCTerms.created);
if (created != null) {
result.setCreated(created);
}
// issued
Date issued = getDate(individual, DCTerms.issued);
if (issued != null) {
result.setIssued(issued);
}
//licenses
NodeIterator licenseIterator = individual.listPropertyValues(DCTerms.license);
for (RDFNode licenseValue : licenseIterator.toList()) {
result.addLicense(new URI(licenseValue.asResource().getURI()));
}
//owl:sameAs
NodeIterator sameAsIterator = individual.listPropertyValues(OWL2.sameAs);
for (RDFNode sameAsValue : sameAsIterator.toList()) {
result.addSameAs(new URI(sameAsValue.asResource().getURI()));
}
}