Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* Copyright (c) 2015 Laurent Wouters
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this program.
* If not, see .
*
* Contributors:
* Laurent Wouters - [email protected]
******************************************************************************/
package org.xowl.infra.store;
import org.xowl.infra.lang.owl2.IRI;
import org.xowl.infra.lang.owl2.Ontology;
import org.xowl.infra.store.owl.DynamicNode;
import org.xowl.infra.store.rdf.*;
import org.xowl.infra.store.storage.UnsupportedNodeType;
import org.xowl.infra.utils.collections.*;
import org.xowl.infra.utils.logging.Logger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
/**
* Represents an object in an ontology
*
* @author Laurent Wouters
*/
public class ProxyObject {
/**
* The parent repository
*/
protected Repository repository;
/**
* The containing ontology
*/
protected Ontology ontology;
/**
* The represented entity as a subject RDF node
*/
protected SubjectNode subject;
/**
* Initializes this object
*
* @param repository The parent repository
* @param ontology The containing ontology
* @param subject The represented entity as a subject RDF node
*/
protected ProxyObject(Repository repository, Ontology ontology, SubjectNode subject) {
this.repository = repository;
this.ontology = ontology;
this.subject = subject;
}
/**
* Gets the parent repository
*
* @return The parent repository
*/
public Repository getRepository() {
return repository;
}
/**
* Gets the containing ontology
*
* @return The containing ontology
*/
public Ontology getOntology() {
return ontology;
}
/**
* Gets the represented entity as an RDF IRI node
*
* @return The represented entity as an RDF IRI node
*/
protected SubjectNode getNode() {
return subject;
}
/**
* Gets the IRI of this object
*
* @return The IRI of this object
*/
public IRI getIRI() {
return subject.getNodeType() == Node.TYPE_IRI ? repository.getIRI(((IRINode) subject).getIRIValue()) : null;
}
/**
* Gets the value of the IRI of this object
*
* @return The value of the IRI of this object
*/
public String getIRIString() {
return subject.getNodeType() == Node.TYPE_IRI ? ((IRINode) subject).getIRIValue() : null;
}
/**
* Gets the classifiers of this object
*
* @return The classifiers of this object
*/
public Collection getClassifiers() {
return queryObjects(node(Vocabulary.rdfType));
}
/**
* Gets the instances of this objects, i.e. objects classified by this object
*
* @return the instances of this object
*/
public Collection getInstances() {
return queryInverseObjects(node(Vocabulary.rdfType));
}
/**
* Gets the value for the specified object property
*
* @param property An object property
* @return The value
*/
public ProxyObject getObjectValue(String property) {
Collection result = queryObjects(node(property));
if (result.isEmpty())
return null;
return result.iterator().next();
}
/**
* Gets the object for which this one is a value for the specified property
*
* @param property An object property
* @return The object
*/
public ProxyObject getObjectFrom(String property) {
Collection result = queryInverseObjects(node(property));
if (result.isEmpty())
return null;
return result.iterator().next();
}
/**
* Gets the value for the specified data property
*
* @param property A data property
* @return The value
*/
public Object getDataValue(String property) {
Collection