本文整理汇总了Java中gate.creole.ontology.OConstants.MAX_CARDINALITY_RESTRICTION属性的典型用法代码示例。如果您正苦于以下问题:Java OConstants.MAX_CARDINALITY_RESTRICTION属性的具体用法?Java OConstants.MAX_CARDINALITY_RESTRICTION怎么用?Java OConstants.MAX_CARDINALITY_RESTRICTION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gate.creole.ontology.OConstants
的用法示例。
在下文中一共展示了OConstants.MAX_CARDINALITY_RESTRICTION属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRestrictionName
public static String getRestrictionName(byte classType) {
switch (classType) {
case OConstants.HAS_VALUE_RESTRICTION:
return OntologyUtilities.HASVALUE;
case OConstants.ALL_VALUES_FROM_RESTRICTION:
return OntologyUtilities.ALLVALUESFROM;
case OConstants.SOME_VALUES_FROM_RESTRICTION:
return OntologyUtilities.SOMEVALUESFROM;
case OConstants.CARDINALITY_RESTRICTION:
return OntologyUtilities.CARDINALITY;
case OConstants.MIN_CARDINALITY_RESTRICTION:
return OntologyUtilities.MINCARDINALITY;
case OConstants.MAX_CARDINALITY_RESTRICTION:
return OntologyUtilities.MAXCARDINALITY;
case OConstants.ANNONYMOUS_CLASS:
return "Annonymous";
default:
return "Unknown";
}
}
示例2: getPropertyValue
/**
* Gets the datatype uri specified on the given restriction uri.
*
* @param repositoryID
* @param restrictionURI
* @return
* @throws GateOntologyException
*/
public PropertyValue getPropertyValue(
String restrictionURI, byte restrictionType)
{
org.openrdf.model.URI whatValueURI = null;
switch (restrictionType) {
case OConstants.CARDINALITY_RESTRICTION:
whatValueURI = OWL.CARDINALITY;
break;
case OConstants.MAX_CARDINALITY_RESTRICTION:
whatValueURI = OWL.MAXCARDINALITY;
break;
case OConstants.MIN_CARDINALITY_RESTRICTION:
whatValueURI = OWL.MINCARDINALITY;
break;
default:
throw new GateOntologyException("Invalid restriction type :" + restrictionType + " for the " + restrictionURI);
}
try {
RepositoryResult<Statement> iter =
repositoryConnection.getStatements(getResource(restrictionURI), whatValueURI,
null, true);
if (iter.hasNext()) {
Value v = iter.next().getObject();
if (v instanceof Literal) {
return new PropertyValue(((Literal) v).getDatatype().toString(), ((Literal) v).getLabel());
}
} else {
throw new GateOntologyException("Could not find restriction value for "+restrictionURI+"/"+whatValueURI);
}
} catch (Exception e) {
throw new GateOntologyException(e);
}
return null;
}
示例3: createOClass
/**
* Creates a new instance of Ontology Class
*
* @param ontology
* @param owlim
* @param uri
* @param classType
* @return
*/
public static OClass createOClass(Ontology ontology,
OWLOntologyService owlim, String uri, byte classType) {
OClass aClass = null; //(OClass)ontology.getOResourceFromMap(uri);
//if(aClass != null) {
//return aClass;
//}
switch (classType) {
case OConstants.HAS_VALUE_RESTRICTION:
return new HasValueRestrictionImpl(new OBNodeIDImpl(uri), ontology,
owlim);
case OConstants.ALL_VALUES_FROM_RESTRICTION:
return new AllValuesFromRestrictionImpl(new OBNodeIDImpl(uri), ontology,
owlim);
case OConstants.SOME_VALUES_FROM_RESTRICTION:
return new SomeValuesFromRestrictionImpl(new OBNodeIDImpl(uri),
ontology, owlim);
case OConstants.CARDINALITY_RESTRICTION:
return new CardinalityRestrictionImpl(new OBNodeIDImpl(uri), ontology,
owlim);
case OConstants.MIN_CARDINALITY_RESTRICTION:
return new MinCardinalityRestrictionImpl(new OBNodeIDImpl(uri),
ontology, owlim);
case OConstants.MAX_CARDINALITY_RESTRICTION:
return new MaxCardinalityRestrictionImpl(new OBNodeIDImpl(uri),
ontology, owlim);
case OConstants.ANNONYMOUS_CLASS:
return new AnonymousClassImpl(new OBNodeIDImpl(uri),
ontology, owlim);
default:
return new OClassImpl(new OURIImpl(uri), ontology,
owlim);
}
}
示例4: setPropertyValue
/**
* Sets the datatype uri for the given restriction uri.
*
* @param restrictionURI
* @param datatypeURI
*/
public void setPropertyValue(String restrictionURI,
byte restrictionType, String value, String datatypeURI)
{
String whatValueURI = null;
switch (restrictionType) {
case OConstants.CARDINALITY_RESTRICTION:
whatValueURI = OWL.CARDINALITY.toString();
break;
case OConstants.MAX_CARDINALITY_RESTRICTION:
whatValueURI = OWL.MAXCARDINALITY.toString();
break;
case OConstants.MIN_CARDINALITY_RESTRICTION:
whatValueURI = OWL.MINCARDINALITY.toString();
break;
default:
throw new GateOntologyException("Invalid restriction type :" + restrictionType + " for the restriction " + restrictionURI);
}
Statement toDelete = null;
try {
RepositoryResult<Statement> iter =
repositoryConnection.getStatements(getResource(restrictionURI), makeSesameURI(whatValueURI),
null, true);
if (iter.hasNext()) {
Statement stmt = iter.next();
Value v = stmt.getObject();
if (v instanceof Literal) {
if (((Literal) v).getDatatype().toString().intern() == datatypeURI.intern()) {
toDelete = stmt;
}
}
}
} catch (Exception e) {
throw new GateOntologyException(e);
}
if (toDelete != null) {
Literal l = (Literal) toDelete.getObject();
// TODO: !! replace !!
removeUUUStatement(whatValueURI, l.getLabel(), l.getDatatype().toString());
}
// TODO: !! replace !!
addUUDStatement(restrictionURI, whatValueURI, value,
datatypeURI);
}
示例5: getRestrictionValue
/**
* Gets the cardinality value specified on the given restriction uri.
*
* @param restrictionURI
* @param restrictionType
* - either of the following constants from the OConstants -
* ALL_VALUES_FROM_RESTRICTION, SOME_VALUES_FROM_RESTRICTION, and
* HAS_VALUE_RESTRICTION
* @return
*/
public ResourceInfo getRestrictionValue(
String restrictionURI, byte restrictionType)
{
System.out.println("getRestrictionValue for "+restrictionURI);
URI whatValueURI = null;
switch (restrictionType) {
case OConstants.ALL_VALUES_FROM_RESTRICTION:
whatValueURI = OWL.ALLVALUESFROM;
break;
case OConstants.HAS_VALUE_RESTRICTION:
whatValueURI = OWL.HASVALUE;
break;
case OConstants.SOME_VALUES_FROM_RESTRICTION:
whatValueURI = OWL.SOMEVALUESFROM;
break;
default:
throw new GateOntologyException("Invalid restriction type:" + restrictionType + " for the restriction " + restrictionURI);
}
String resourceURI;
try {
RepositoryResult<Statement> iter =
repositoryConnection.getStatements(string2SesameResource(restrictionURI), whatValueURI,
null, true);
if (iter.hasNext()) {
resourceURI = iter.next().getObject().toString();
Resource res = getResource(resourceURI);
boolean isRestriction =
repositoryConnection.hasStatement(
res,
RDF.TYPE,
OWL.RESTRICTION,
true);
byte classType = OConstants.OWL_CLASS;
if (isRestriction) {
if (repositoryConnection.hasStatement(res, OWL.HASVALUE, null, true)) {
classType = OConstants.HAS_VALUE_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.SOMEVALUESFROM, null, true)) {
classType = OConstants.SOME_VALUES_FROM_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.ALLVALUESFROM, null, true)) {
classType = OConstants.ALL_VALUES_FROM_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.CARDINALITY, null, true)) {
classType = OConstants.CARDINALITY_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.MINCARDINALITY, null, true)) {
classType = OConstants.MIN_CARDINALITY_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.MAXCARDINALITY, null, true)) {
classType = OConstants.MAX_CARDINALITY_RESTRICTION;
}
}
if (classType == OConstants.OWL_CLASS) {
if (res instanceof BNode) {
classType = OConstants.ANNONYMOUS_CLASS;
} else {
// check if it is an instance
if (isIndividual(resourceURI)) {
classType = OConstants.INSTANCE;
}
}
}
return new ResourceInfo(resourceURI, classType);
}
} catch (Exception e) {
throw new GateOntologyException("Problem getting restriction value for "+restrictionURI,e);
}
return null;
}
示例6: getClassType
/**
* This method tells what type of restriction the given uri refers to. If the
* given URI is not a restriction, the method returns -1. Otherwise one of the
* following values from the OConstants class. OWL_CLASS,
* CARDINALITY_RESTRICTION, MIN_CARDINALITY_RESTRICTION,
* MAX_CARDINALITY_RESTRICTION, HAS_VALUE_RESTRICTION,
* ALL_VALUES_FROM_RESTRICTION.
*
* @param restrictionURI
* @return
*/
// TODO: !!! how does this relate to getRestrictionForONodeID
public byte getClassType(String restrictionURI)
{
Resource res = getResource(restrictionURI);
logger.debug("Converted to resource: " + res);
String rep1 = "<" + restrictionURI + ">";
if (res instanceof BNode) {
logger.debug("is an instance of Bnode: " + res);
rep1 = restrictionURI;
}
if (res instanceof BNode) {
logger.debug("is an instance of Bnode: " + res);
String query = "select * from {" + rep1 + "} owl:hasValue {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.HAS_VALUE_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:someValuesFrom {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.SOME_VALUES_FROM_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:allValuesFrom {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.ALL_VALUES_FROM_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:cardinality {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.CARDINALITY_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:minCardinality {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.MIN_CARDINALITY_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:maxCardinality {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.MAX_CARDINALITY_RESTRICTION;
}
}
if (res instanceof BNode) {
logger.debug("is an instance of Bnode: " + res);
return OConstants.ANNONYMOUS_CLASS;
} else {
logger.debug("is an ordinary class: " + res);
return OConstants.OWL_CLASS;
}
}