/** A class that represents a set of property restrictions for some class. All constraints on the same property are included in a single object. */ public class OwlProperty { public static final int UNBOUNDED = Integer.MAX_VALUE; /** The URI of the property that has constraints. */ String id; /** The minimum cardinality of the property. */ int minCardinality; /** The maximum cardinality of the property. */ int maxCardinality; /** The URI for the class from which all values must be from. */ String allValuesFrom; /** The URI for the class from which at least one value must be from. */ String someValuesFrom; /** The URI of an instance that must be a value for the property. */ String hasValue; public OwlProperty(String id) { this.id = id; minCardinality = 0; maxCardinality = UNBOUNDED; allValuesFrom = null; someValuesFrom = null; hasValue = null; } /** Returns the URI of the property. */ public String getId() { return id; } /** Returns the URI of the class specified in an owl:allValuesFrom restriction. */ public String getAllValuesFrom() { return allValuesFrom; } /** Returns the URI of an instance specified in an owl:hasValue restriction. */ public String getHasValue() { return hasValue; } /** Returns the value specified in an owl:minCardinality restriction. */ public int getMinCardinality() { return minCardinality; } /** Returns the value specified in an owl:maxCardinality restriction. */ public int getMaxCardinality() { return maxCardinality; } /** Returns the URI of the class specified in an owl:someValuesFrom retrction. */ public String getSomeValuesFrom() { return someValuesFrom; } /** Sets the URI of the class specified in an owl:allValuesFrom restriction. */ public void setAllValuesFrom(String classId) { allValuesFrom = classId; } /** Sets the URI of an instance specified in an owl:hasValue restriction. */ public void setHasValue(String indivId) { hasValue = indivId; } /** Sets the value specified in an owl:minCardinality restriction. */ public void setMinCardinality(int minCard) { minCardinality = minCard; } /** Sets the value specified in an owl:maxCardinality restriction. */ public void setMaxCardinality(int maxCard) { maxCardinality = maxCard; } /** Sets the URI of the class specified in an owl:someValuesFrom retrction. */ public void setSomeValuesFrom(String classId) { someValuesFrom = classId; } /** Provides a raw description of the property and its restrictions. Useful for debugging. */ public String toString() { String str = id + "["; if (minCardinality > 0) str = str + ">=" + minCardinality + "; "; if (maxCardinality != UNBOUNDED) str = str + "<=" + maxCardinality + "; "; if (hasValue != null) str = str + "='" + hasValue + "'; "; if (allValuesFrom != null) str = str + "ALL." + allValuesFrom + "; "; if (someValuesFrom != null) str = str + "SOME." + someValuesFrom + "; "; return str + "]"; } }