1 19 20 package com.hp.hpl.jena.ontology.impl; 23 import com.hp.hpl.jena.rdf.model.*; 24 25 26 import com.hp.hpl.jena.vocabulary.*; 29 import com.hp.hpl.jena.enhanced.*; 30 import com.hp.hpl.jena.graph.*; 31 import com.hp.hpl.jena.ontology.*; 32 33 import java.util.*; 34 35 36 37 46 public class OWLDLProfile 47 extends OWLProfile 48 { 49 52 53 56 57 60 61 64 65 68 69 75 public String getLabel() { 76 return "OWL DL"; 77 } 78 79 80 83 protected static Object [][] s_supportsCheckData = new Object [][] { 84 { AllDifferent.class, new SupportsCheck() { 86 public boolean doCheck( Node n, EnhGraph g ) { 87 return g.asGraph().contains( n, RDF.type.asNode(), OWL.AllDifferent.asNode() ); 88 } 89 } 90 }, 91 { AnnotationProperty.class, new SupportsCheck() { 92 public boolean doCheck( Node n, EnhGraph g ) { 93 for (Iterator i = ((OntModel) g).getProfile().getAnnotationProperties(); i.hasNext(); ) { 94 if (((Resource) i.next()).asNode().equals( n )) { 95 return true; 97 } 98 } 99 return g.asGraph().contains( n, RDF.type.asNode(), OWL.AnnotationProperty.asNode() ); 100 } 101 } 102 }, 103 { OntClass.class, new SupportsCheck() { 104 public boolean doCheck( Node n, EnhGraph g ) { 105 return OWL.Thing.asNode().equals( n ) || 106 OWL.Nothing.asNode().equals( n ) || 107 g.asGraph().contains( n, RDF.type.asNode(), OWL.Class.asNode() ) || 108 g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) || 109 g.asGraph().contains( n, RDF.type.asNode(), RDFS.Class.asNode() ) || 110 n.equals( OWL.Thing.asNode() ) || 112 n.equals( OWL.Nothing.asNode() ) || 113 g.asGraph().contains( Node.ANY, RDFS.domain.asNode(), n ) || 114 g.asGraph().contains( Node.ANY, RDFS.range.asNode(), n ) 115 ; 116 } 117 } 118 }, 119 { DatatypeProperty.class, new SupportsCheck() { 120 public boolean doCheck( Node n, EnhGraph g ) { 121 return g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() ); 122 } 123 } 124 }, 125 { ObjectProperty.class, new SupportsCheck() { 126 public boolean doCheck( Node n, EnhGraph g ) { 127 return g.asGraph().contains( n, RDF.type.asNode(), OWL.ObjectProperty.asNode() ) || 128 g.asGraph().contains( n, RDF.type.asNode(), OWL.TransitiveProperty.asNode() ) || 129 g.asGraph().contains( n, RDF.type.asNode(), OWL.SymmetricProperty.asNode() ) || 130 g.asGraph().contains( n, RDF.type.asNode(), OWL.InverseFunctionalProperty.asNode() ); 131 } 132 } 133 }, 134 { FunctionalProperty.class, new SupportsCheck() { 135 public boolean doCheck( Node n, EnhGraph g ) { 136 return g.asGraph().contains( n, RDF.type.asNode(), OWL.FunctionalProperty.asNode() ); 137 } 138 } 139 }, 140 { InverseFunctionalProperty.class, new SupportsCheck() { 141 public boolean doCheck( Node n, EnhGraph g ) { 142 return g.asGraph().contains( n, RDF.type.asNode(), OWL.InverseFunctionalProperty.asNode() ) && 143 !g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() ); 144 } 145 } 146 }, 147 { RDFList.class, new SupportsCheck() { 148 public boolean doCheck( Node n, EnhGraph g ) { 149 return n.equals( RDF.nil.asNode() ) || 150 g.asGraph().contains( n, RDF.type.asNode(), RDF.List.asNode() ); 151 } 152 } 153 }, 154 { OntProperty.class, new SupportsCheck() { 155 public boolean doCheck( Node n, EnhGraph g ) { 156 return g.asGraph().contains( n, RDF.type.asNode(), RDF.Property.asNode() ) || 157 g.asGraph().contains( n, RDF.type.asNode(), OWL.ObjectProperty.asNode() ) || 158 g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() ) || 159 g.asGraph().contains( n, RDF.type.asNode(), OWL.AnnotationProperty.asNode() ) || 160 g.asGraph().contains( n, RDF.type.asNode(), OWL.TransitiveProperty.asNode() ) || 161 g.asGraph().contains( n, RDF.type.asNode(), OWL.SymmetricProperty.asNode() ) || 162 g.asGraph().contains( n, RDF.type.asNode(), OWL.FunctionalProperty.asNode() ) || 163 g.asGraph().contains( n, RDF.type.asNode(), OWL.InverseFunctionalProperty.asNode() ); 164 } 165 } 166 }, 167 { Ontology.class, new SupportsCheck() { 168 public boolean doCheck( Node n, EnhGraph g ) { 169 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Ontology.asNode() ); 170 } 171 } 172 }, 173 { Restriction.class, new SupportsCheck() { 174 public boolean doCheck( Node n, EnhGraph g ) { 175 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ); 176 } 177 } 178 }, 179 { AllValuesFromRestriction.class, new SupportsCheck() { 180 public boolean doCheck( Node n, EnhGraph g ) { 181 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 182 containsSome( g, n, OWL.allValuesFrom ) && 183 containsSome( g, n, OWL.onProperty ); 184 } 185 } 186 }, 187 { SomeValuesFromRestriction.class, new SupportsCheck() { 188 public boolean doCheck( Node n, EnhGraph g ) { 189 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 190 containsSome( g,n, OWL.someValuesFrom ) && 191 containsSome( g,n, OWL.onProperty ); 192 } 193 } 194 }, 195 { HasValueRestriction.class, new SupportsCheck() { 196 public boolean doCheck( Node n, EnhGraph g ) { 197 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 198 containsSome( g, n, OWL.hasValue ) && 199 containsSome( g, n, OWL.onProperty ); 200 } 201 } 202 }, 203 { CardinalityRestriction.class, new SupportsCheck() { 204 public boolean doCheck( Node n, EnhGraph g ) { 205 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 206 containsSome( g, n, OWL.cardinality ) && 207 containsSome( g, n, OWL.onProperty ); 208 } 209 } 210 }, 211 { MinCardinalityRestriction.class, new SupportsCheck() { 212 public boolean doCheck( Node n, EnhGraph g ) { 213 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 214 containsSome( g, n, OWL.minCardinality ) && 215 containsSome( g, n, OWL.onProperty ); 216 } 217 } 218 }, 219 { MaxCardinalityRestriction.class, new SupportsCheck() { 220 public boolean doCheck( Node n, EnhGraph g ) { 221 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 222 containsSome( g, n, OWL.maxCardinality ) && 223 containsSome( g, n, OWL.onProperty ); 224 } 225 } 226 }, 227 { SymmetricProperty.class, new SupportsCheck() { 228 public boolean doCheck( Node n, EnhGraph g ) { 229 return g.asGraph().contains( n, RDF.type.asNode(), OWL.SymmetricProperty.asNode() ) && 230 !g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() ); 231 } 232 } 233 }, 234 { TransitiveProperty.class, new SupportsCheck() { 235 public boolean doCheck( Node n, EnhGraph g ) { 236 return g.asGraph().contains( n, RDF.type.asNode(), OWL.TransitiveProperty.asNode() ) && 237 !g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() ); 238 } 239 } 240 }, 241 { Individual.class, new SupportsCheck() { 242 public boolean doCheck( Node n, EnhGraph eg ) { 243 if (n instanceof Node_URI || n instanceof Node_Blank) { 244 Graph g = eg.asGraph(); 246 247 return !(g.contains( n, RDF.type.asNode(), RDFS.Class.asNode() ) || 249 g.contains( n, RDF.type.asNode(), RDF.Property.asNode() )); 250 } 251 else { 252 return false; 253 } 254 } 255 } 256 }, 257 { DataRange.class, new SupportsCheck() { 258 public boolean doCheck( Node n, EnhGraph g ) { 259 return n instanceof Node_Blank && 260 g.asGraph().contains( n, RDF.type.asNode(), OWL.DataRange.asNode() ); 261 } 262 } 263 } 264 }; 265 266 267 public static boolean containsSome( EnhGraph g, Node n, Property p ) { 269 return AbstractProfile.containsSome( g, n, p ); 270 } 271 272 273 private static HashMap s_supportsChecks = new HashMap(); 274 275 static { 276 for (int i = 0; i < s_supportsCheckData.length; i++) { 278 s_supportsChecks.put( s_supportsCheckData[i][0], s_supportsCheckData[i][1] ); 279 } 280 } 281 282 protected Map getCheckTable() { 283 return s_supportsChecks; 284 } 285 286 290 291 } 292 293 294 295 296 325 326 | Popular Tags |