本文整理汇总了Java中com.hp.hpl.jena.ontology.Individual类的典型用法代码示例。如果您正苦于以下问题:Java Individual类的具体用法?Java Individual怎么用?Java Individual使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Individual类属于com.hp.hpl.jena.ontology包,在下文中一共展示了Individual类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseConfiguration
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
private void parseConfiguration() {
Iterator<Individual> it = this.model.listIndividuals(D2RQ.Configuration);
if (it.hasNext()) {
Resource configResource = it.next();
Configuration configuration = new Configuration(configResource);
StmtIterator stmts = configResource.listProperties(D2RQ.serveVocabulary);
while (stmts.hasNext()) {
configuration.setServeVocabulary(stmts.nextStatement().getBoolean());
}
stmts = configResource.listProperties(D2RQ.useAllOptimizations);
while (stmts.hasNext()) {
configuration.setUseAllOptimizations(stmts.nextStatement().getBoolean());
}
this.mapping.setConfiguration(configuration);
if (it.hasNext())
throw new D2RQException("Only one configuration block is allowed");
}
}
示例2: handleAttributes
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
private void handleAttributes(HashMap<String, Object> tboxMap, Individual ind, NamedNodeMap mapAttr) {
for (int i = 0; i < mapAttr.getLength(); i++) {
Node nodeattr = mapAttr.item(i);
String attrname = nodeattr.getNodeName();
String attrns = nodeattr.getNamespaceURI();
String attrvalue = nodeattr.getNodeValue();
if (StringUtils.isBlank(attrvalue)) {
continue;
}
if (attrns == null) {
attrns = nstBox;
} else if (!(attrns.endsWith("/") || attrns.endsWith("#"))) {
attrns += "#";
}
OntProperty ontProp = getDatatypeOntProperty(tboxMap, attrns + attrname);
// Add literal
ind.addLiteral(ontProp, attrvalue.trim());
}
}
示例3: triplifyChildNodes
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
private void triplifyChildNodes(OntModel modelAbox, Individual ind, NodeList nlist) {
// Elements order may be relevant. Keep track of index within same tag name group
String currentTagName = "";
int elemTagIndex = 0;
for (int j = 0; nlist != null && j < nlist.getLength(); j++) {
Node node = nlist.item(j);
if (node.getNodeType() != Node.ELEMENT_NODE)
continue;
Element elem = (Element) nlist.item(j);
if (elem.getNodeName().equals(currentTagName)) {
elemTagIndex++;
} else {
elemTagIndex = 0;
currentTagName = elem.getNodeName();
}
triplifyElement(elem, elemTagIndex, ind, modelAbox);
}
}
示例4: getIndividual
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
private Individual getIndividual(ConceptName instName) {
Resource ir;
try {
ir = getOntResourceInExistingModel(instName);
if (ir != null) {
ConceptType it = getOntResourceConceptType(ir);
if (it.equals(ConceptType.INDIVIDUAL)) {
return ir.as(Individual.class);
}
}
} catch (ConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例5: addDifferentInstances
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
/**
* Call this method to declare the listed Individuals to be known to be
* different
*
* @param instances
* @return
*/
public List<ModelError> addDifferentInstances(List<ConceptName> instances) {
RDFNode[] nodeArray = new RDFNode[instances.size()];
int idx = 0;
Iterator<ConceptName> itr = instances.iterator();
while (itr.hasNext()) {
ConceptName nme = itr.next();
if (nme == null) {
addError(0, "Instance " + (idx + 1)
+ " is not specified; can't set all different.");
return getErrorsFinal();
}
Individual inst = getOrCreateIndividual(0, idx + 1, nme);
if (inst == null) {
addError(0, "Instance " + (idx + 1)
+ " is not specified; can't set all different.");
return getErrorsFinal();
}
nodeArray[idx++] = inst;
}
RDFList differentMembers = getJenaModel().createList(nodeArray);
getJenaModel().createAllDifferent(differentMembers);
return getErrorsFinal();
}
示例6: getName
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
@Override
public String getName() {
NodeIterator ni;
try {
ni = KBObjectImpl.getBaseContextModel().listObjectsOfProperty(
((Individual)((VariableImpl)this).getCore()),
(OntProperty)((KBPredicateImpl)Constants.getInstance().RIF_VARNAME_PRED).getCore());
if (ni.hasNext()) {
return ni.next().asLiteral().getString();
}
} catch (Exception ex) {
Logger.getLogger(VariableImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return "";
}
示例7: addTripleToModel
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
/**
* Method to add a triple to the model, either in-memory or TDB repository
* @param subj
* @param pred
* @param obj
* @param rowNum
* @throws ConfigurationException
*/
protected void addTripleToModel(Resource subj, Property pred, RDFNode obj,
int rowNum, int modelArrayPosition) throws ConfigurationException {
if (pred.equals(RDF.type) && obj instanceof Resource) {
// if we are assigning a type, look to see if it already has a more general type and if it does
// remove it.
if (subj.canAs(Individual.class) && ((Resource)obj).canAs(OntClass.class)) {
ExtendedIterator<Resource> typeitr = subj.as(Individual.class).listRDFTypes(true);
while (typeitr.hasNext()) {
Resource typ = typeitr.next();
if (!typ.equals(obj) && typ.canAs(OntClass.class)) {
if (getSadlUtils().classIsSubclassOf(((Resource)obj).as(OntClass.class), typ.as(OntClass.class), true)) {
subj.as(Individual.class).removeRDFType(typ.as(OntClass.class));
}
}
}
}
}
logger.debug("Adding triple while processing: " + subj + ", " + pred + ", " + obj);
if (triplesLoggerOut != null) {
logTriple(rowNum, subj, pred, obj, modelArrayPosition);
}
getModel(modelArrayPosition).add(subj, pred, obj);
numTriplesImported++;
}
示例8: addTripleToModel
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
/**
* Method to add a triple to the model, either in-memory or TDB repository
* @param subj
* @param pred
* @param obj
* @param rowNum
* @throws ConfigurationException
* @throws CircularDependencyException
*/
protected void addTripleToModel(Resource subj, Property pred, RDFNode obj,
int rowNum, int modelArrayPosition) throws ConfigurationException, CircularDependencyException {
if (pred.equals(RDF.type) && obj instanceof Resource) {
// if we are assigning a type, look to see if it already has a more general type and if it does
// remove it.
if (subj.canAs(Individual.class) && ((Resource)obj).canAs(OntClass.class)) {
ExtendedIterator<Resource> typeitr = subj.as(Individual.class).listRDFTypes(true);
while (typeitr.hasNext()) {
Resource typ = typeitr.next();
if (!typ.equals(obj) && typ.canAs(OntClass.class)) {
if (SadlUtils.classIsSubclassOf(((Resource)obj).as(OntClass.class), typ.as(OntClass.class), true, null)) {
subj.as(Individual.class).removeRDFType(typ.as(OntClass.class));
}
}
}
}
}
logger.debug("Adding triple while processing: " + subj + ", " + pred + ", " + obj);
if (triplesLoggerOut != null) {
logTriple(rowNum, subj, pred, obj, modelArrayPosition);
}
getModel(modelArrayPosition).add(subj, pred, obj);
numTriplesImported++;
}
示例9: checkResourceOutputComplete
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
private void checkResourceOutputComplete(OntResource r) {
if (r.canAs(Individual.class)) {
Individual inst = r.asIndividual();
StmtIterator sitr = inst.listProperties();
while (sitr.hasNext()) {
Statement s = sitr.next();
if (!s.getPredicate().equals(RDF.type)) {
System.out.println(s);
sitr.close();
return;
}
}
resourcesOutput.add(r);
sitr.close();
}
}
示例10: processStatement
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
public void processStatement(EquationStatement element)
throws JenaProcessorException, InvalidNameException, InvalidTypeException, TranslationException {
SadlResource nm = element.getName();
EList<SadlParameterDeclaration> params = element.getParameter();
SadlTypeReference rtype = element.getReturnType();
Expression bdy = element.getBody();
Equation eq = createEquation(element, nm, rtype, params, bdy);
addEquation(element.eResource(), eq, nm);
Individual eqinst = getTheJenaModel().createIndividual(getDeclarationExtensions().getConceptUri(nm),
getTheJenaModel().getOntClass(SadlConstants.SADL_BASE_MODEL_EQUATION_URI));
DatatypeProperty dtp = getTheJenaModel().getDatatypeProperty(SadlConstants.SADL_BASE_MODEL_EQ_EXPRESSION_URI);
Literal literal = getTheJenaModel().createTypedLiteral(eq.toString());
if (eqinst != null && dtp != null) {
// these can be null during clean/build with resource open in editor
eqinst.addProperty(dtp, literal);
}
}
示例11: sadlExplicitValuesToEnumeratedClass
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
private EnumeratedClass sadlExplicitValuesToEnumeratedClass(EList<SadlExplicitValue> values)
throws JenaProcessorException {
List<RDFNode> nodevals = new ArrayList<RDFNode>();
for (int i = 0; i < values.size(); i++) {
SadlExplicitValue value = values.get(i);
RDFNode nodeval = sadlExplicitValueToRdfNode(value, null, true);
if (nodeval.canAs(Individual.class)) {
nodevals.add(nodeval.as(Individual.class));
} else {
nodevals.add(nodeval);
}
}
RDFNode[] enumedArray = nodevals.toArray(new RDFNode[nodevals.size()]);
RDFList rdfl = getTheJenaModel().createList(enumedArray);
EnumeratedClass enumCls = getTheJenaModel().createEnumeratedClass(null, rdfl);
return enumCls;
}
示例12: addListValues
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
private void addListValues(Individual inst, OntClass cls, SadlValueList listInitializer) {
com.hp.hpl.jena.rdf.model.Resource to = null;
ExtendedIterator<OntClass> scitr = cls.listSuperClasses(true);
while (scitr.hasNext()) {
OntClass sc = scitr.next();
if (sc.isRestriction()
&& ((sc.as(Restriction.class)).isAllValuesFromRestriction() && sc.as(AllValuesFromRestriction.class)
.onProperty(getTheJenaModel().getProperty(SadlConstants.SADL_LIST_MODEL_FIRST_URI)))) {
to = sc.as(AllValuesFromRestriction.class).getAllValuesFrom();
break;
}
}
if (to == null) {
// addError("No 'to' resource found in restriction of List subclass",
// listInitializer);
}
Iterator<SadlExplicitValue> values = listInitializer.getExplicitValues().iterator();
addValueToList(null, inst, cls, to, values);
}
示例13: addUnittedQuantityAsInstancePropertyValue
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
private void addUnittedQuantityAsInstancePropertyValue(Individual inst, OntProperty oprop, OntResource rng,
String literalNumber, String unit) {
Individual unittedVal;
if (rng != null && rng.canAs(OntClass.class)) {
unittedVal = getTheJenaModel().createIndividual(rng.as(OntClass.class));
} else {
unittedVal = getTheJenaModel().createIndividual(
getTheJenaModel().getOntClass(SadlConstants.SADL_IMPLICIT_MODEL_UNITTEDQUANTITY_URI));
}
// TODO this may need to check for property restrictions on a subclass of
// UnittedQuantity
unittedVal.addProperty(getTheJenaModel().getProperty(SadlConstants.SADL_IMPLICIT_MODEL_VALUE_URI),
getTheJenaModel().createTypedLiteral(literalNumber));
unittedVal.addProperty(getTheJenaModel().getProperty(SadlConstants.SADL_IMPLICIT_MODEL_UNIT_URI),
getTheJenaModel().createTypedLiteral(unit));
inst.addProperty(oprop, unittedVal);
}
示例14: getTypeFromRestriction
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
protected TypeCheckInfo getTypeFromRestriction(String subjuri, String propuri, OntConceptType proptype, Expression predicate) throws InvalidTypeException, TranslationException {
Resource subj = theJenaModel.getResource(subjuri);
if (subj != null) {
if (!(subj instanceof OntClass || subj.canAs(OntClass.class)) && subj.canAs(Individual.class)) {
ExtendedIterator<Resource> subjects = subj.as(Individual.class).listRDFTypes(true);
while(subjects.hasNext()) {
TypeCheckInfo type = getTypeFromRestriction(subjects.next(), propuri, proptype, predicate);
if(type != null) {
return type;
}
}
}else {
return getTypeFromRestriction(subj, propuri, proptype, predicate);
}
}
return null;
}
示例15: instancesHaveCommonType
import com.hp.hpl.jena.ontology.Individual; //导入依赖的package包/类
private boolean instancesHaveCommonType(Individual individualL, Individual individualR) {
ExtendedIterator<Resource> lcitr = individualL.listRDFTypes(true);
ExtendedIterator<Resource> rcitr = individualR.listRDFTypes(true);
while (lcitr.hasNext()) {
Resource lr = lcitr.next();
while (rcitr.hasNext()) {
Resource rr = rcitr.next();
if (lr.equals(rr)) {
lcitr.close();
rcitr.close();
return true;
}
}
}
return false;
}