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