// restrict the xsd:integer datatype using the xsd:minInclusive facet
// with a value of 18. Get hold of a literal that is an integer value 18
OWLLiteral eighteen = factory.getOWLLiteral(18);
// Now create the restriction. The OWLFacet enum provides an enumeration
// of the various facets that can be used
OWLDatatypeRestriction integerGE18 = factory.getOWLDatatypeRestriction(
integer, MIN_INCLUSIVE, eighteen);
// We could use this datatype in restriction, as the range of data
// properties etc. For example, if we want to restrict the range of the
// :hasAge data property to 18 or more we specify its range as this data
// range
PrefixManager pm = new DefaultPrefixManager(null, null,
"http://www.semanticweb.org/ontologies/dataranges#");
OWLDataProperty hasAge = factory.getOWLDataProperty(":hasAge", pm);
OWLDataPropertyRangeAxiom rangeAxiom = factory
.getOWLDataPropertyRangeAxiom(hasAge, integerGE18);
OWLOntology ontology = manager.createOntology(IRI
.create("http://www.semanticweb.org/ontologies/dataranges"));
// Add the range axiom to our ontology
manager.addAxiom(ontology, rangeAxiom);
// For creating datatype restrictions on integers or doubles there are
// some convenience methods on OWLDataFactory For example: Create a data
// range of integers greater or equal to 60
OWLDatatypeRestriction integerGE60 = factory
.getOWLDatatypeMinInclusiveRestriction(60);
// Create a data range of integers less than 16
OWLDatatypeRestriction integerLT16 = factory
.getOWLDatatypeMaxExclusiveRestriction(18);
// In OWL 2 it is possible to represent the intersection, union and
// complement of data types For example, we could create a union of data
// ranges of the data range integer less than 16 or integer greater or
// equal to 60