KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > ontology > impl > DAML_OILProfile


1 /*****************************************************************************
2  * Source code information
3  * -----------------------
4  * Original author Ian Dickinson, HP Labs Bristol
5  * Author email Ian.Dickinson@hp.com
6  * Package Jena 2
7  * Web http://sourceforge.net/projects/jena/
8  * Created 10 Feb 2003
9  * Filename $RCSfile: DAML_OILProfile.java,v $
10  * Revision $Revision: 1.27 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/04/11 16:22:50 $
14  * by $Author: ian_dickinson $
15  *
16  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
17  * (see footer for full conditions)
18  *****************************************************************************/

19
20 // Package
21
///////////////
22
package com.hp.hpl.jena.ontology.impl;
23
24
25 // Imports
26
///////////////
27
import com.hp.hpl.jena.enhanced.*;
28 import com.hp.hpl.jena.graph.*;
29 import com.hp.hpl.jena.ontology.*;
30 import com.hp.hpl.jena.rdf.model.*;
31 import com.hp.hpl.jena.vocabulary.*;
32
33 import java.util.*;
34
35
36
37 /**
38  * <p>
39  * Vocabulary constants for DAML+OIL, March 2001 version. This version of the DAML
40  * vocabulary uses RDFS namespace terms for subClass, subProperty, etc. This was not
41  * the case up to and including Jena 2.1. In Jena 2.1, all of the constants in the
42  * DAML vocabulary used the DAML namespace. The DAML langauge defines both as
43  * equivalent, but recognising this equivalence requires the use of the DAML micro
44  * reasoner. For backwards compatability with Jena 2.1, developers should use
45  * {@link DAML_OILLegacyProfile} with the OntModelSpec.
46  * </p>
47  *
48  * @author Ian Dickinson, HP Labs
49  * (<a HREF="mailto:Ian.Dickinson@hp.com" >email</a>)
50  * @version CVS $Id: DAML_OILProfile.java,v 1.27 2005/04/11 16:22:50 ian_dickinson Exp $
51  */

52 public class DAML_OILProfile
53     extends AbstractProfile
54 {
55     // Constants
56
//////////////////////////////////
57

58
59     // Static variables
60
//////////////////////////////////
61

62
63     // Instance variables
64
//////////////////////////////////
65

66     /** Model to hold the vocabulary resources only */
67     private Model m_vocabModel = ModelFactory.createDefaultModel();
68
69     // class resources
70
private Resource m_class = m_vocabModel.createResource( DAML_OIL.Class.getURI() );
71     private Resource m_restriction = m_vocabModel.createResource( DAML_OIL.Restriction.getURI() );
72     private Resource m_thing = m_vocabModel.createResource( DAML_OIL.Thing.getURI() );
73     private Resource m_nothing = m_vocabModel.createResource( DAML_OIL.Nothing.getURI() );
74     private Resource m_property = m_vocabModel.createResource( DAML_OIL.Property.getURI() );
75     private Resource m_objectProperty = m_vocabModel.createResource( DAML_OIL.ObjectProperty.getURI() );
76     private Resource m_datatypeProperty = m_vocabModel.createResource( DAML_OIL.DatatypeProperty.getURI() );
77     private Resource m_transitiveProperty = m_vocabModel.createResource( DAML_OIL.TransitiveProperty.getURI() );
78     private Resource m_symmetricProperty = null;
79     private Resource m_functionalProperty = m_vocabModel.createResource( DAML_OIL.UniqueProperty.getURI() );
80     private Resource m_inverseFunctionalProperty = m_vocabModel.createResource( DAML_OIL.UnambiguousProperty.getURI() );
81     private Resource m_allDifferent = null;
82     private Resource m_ontology = m_vocabModel.createResource( DAML_OIL.Ontology.getURI() );
83     private Resource m_deprecatedClass = null;
84     private Resource m_deprecatedProperty = null;
85     private Resource m_annotationProperty = null;
86     private Resource m_ontologyProperty = null;
87     private Resource m_list = m_vocabModel.createResource( DAML_OIL.List.getURI() );
88     private Resource m_nil = m_vocabModel.createResource( DAML_OIL.nil.getURI() );
89     private Resource m_datarange = null;
90
91     private Property m_equivalentProperty = m_vocabModel.createProperty( DAML_OIL.samePropertyAs.getNameSpace(), DAML_OIL.samePropertyAs.getLocalName() );
92     private Property m_equivalentClass = m_vocabModel.createProperty( DAML_OIL.sameClassAs.getNameSpace(), DAML_OIL.sameClassAs.getLocalName() );
93     private Property m_disjointWith = m_vocabModel.createProperty( DAML_OIL.disjointWith.getNameSpace(), DAML_OIL.disjointWith.getLocalName() );
94     private Property m_sameIndividualAs = m_vocabModel.createProperty( DAML_OIL.sameIndividualAs.getNameSpace(), DAML_OIL.sameIndividualAs.getLocalName() );
95     private Property m_sameAs = m_vocabModel.createProperty( DAML_OIL.equivalentTo.getNameSpace(), DAML_OIL.equivalentTo.getLocalName() );
96     private Property m_differentFrom = m_vocabModel.createProperty( DAML_OIL.differentIndividualFrom.getNameSpace(), DAML_OIL.differentIndividualFrom.getLocalName() );
97     private Property m_distinctMembers = null;
98     private Property m_unionOf = m_vocabModel.createProperty( DAML_OIL.unionOf.getNameSpace(), DAML_OIL.unionOf.getLocalName() );
99     private Property m_intersectionOf = m_vocabModel.createProperty( DAML_OIL.intersectionOf.getNameSpace(), DAML_OIL.intersectionOf.getLocalName() );
100     private Property m_complementOf = m_vocabModel.createProperty( DAML_OIL.complementOf.getNameSpace(), DAML_OIL.complementOf.getLocalName() );
101     private Property m_oneOf = m_vocabModel.createProperty( DAML_OIL.oneOf.getNameSpace(), DAML_OIL.oneOf.getLocalName() );
102     private Property m_onProperty = m_vocabModel.createProperty( DAML_OIL.onProperty.getNameSpace(), DAML_OIL.onProperty.getLocalName() );
103     private Property m_allValuesFrom = m_vocabModel.createProperty( DAML_OIL.toClass.getNameSpace(), DAML_OIL.toClass.getLocalName() );
104     private Property m_hasValue = m_vocabModel.createProperty( DAML_OIL.hasValue.getNameSpace(), DAML_OIL.hasValue.getLocalName() );
105     private Property m_someValuesFrom = m_vocabModel.createProperty( DAML_OIL.hasClass.getNameSpace(), DAML_OIL.hasClass.getLocalName() );
106     private Property m_minCardinality = m_vocabModel.createProperty( DAML_OIL.minCardinality.getNameSpace(), DAML_OIL.minCardinality.getLocalName() );
107     private Property m_maxCardinality = m_vocabModel.createProperty( DAML_OIL.maxCardinality.getNameSpace(), DAML_OIL.maxCardinality.getLocalName() );
108     private Property m_cardinality = m_vocabModel.createProperty( DAML_OIL.cardinality.getNameSpace(), DAML_OIL.cardinality.getLocalName() );
109     private Property m_inverseOf = m_vocabModel.createProperty( DAML_OIL.inverseOf.getNameSpace(), DAML_OIL.inverseOf.getLocalName() );
110     private Property m_imports = m_vocabModel.createProperty( DAML_OIL.imports.getNameSpace(), DAML_OIL.imports.getLocalName() );
111     private Property m_versionInfo = m_vocabModel.createProperty( DAML_OIL.versionInfo.getNameSpace(), DAML_OIL.versionInfo.getLocalName() );
112     private Property m_priorVersion = null;
113     private Property m_backwardsCompatibleWith = null;
114     private Property m_incompatibleWith = null;
115     private Property m_subPropertyOf = m_vocabModel.createProperty( RDFS.subPropertyOf.getURI() );
116     private Property m_subClassOf = m_vocabModel.createProperty( RDFS.subClassOf.getURI() );
117     private Property m_domain = m_vocabModel.createProperty( RDFS.domain.getURI() );
118     private Property m_range = m_vocabModel.createProperty( RDFS.range.getURI() );
119     private Property m_first = m_vocabModel.createProperty( DAML_OIL.first.getNameSpace(), DAML_OIL.first.getLocalName() );
120     private Property m_rest = m_vocabModel.createProperty( DAML_OIL.rest.getNameSpace(), DAML_OIL.rest.getLocalName() );
121     private Property m_minCardinalityQ = m_vocabModel.createProperty( DAML_OIL.minCardinalityQ.getNameSpace(), DAML_OIL.minCardinalityQ.getLocalName() );
122     private Property m_maxCardinalityQ = m_vocabModel.createProperty( DAML_OIL.maxCardinalityQ.getNameSpace(), DAML_OIL.maxCardinalityQ.getLocalName() );
123     private Property m_cardinalityQ = m_vocabModel.createProperty( DAML_OIL.cardinalityQ.getNameSpace(), DAML_OIL.cardinalityQ.getLocalName() );
124     private Property m_hasClassQ = m_vocabModel.createProperty( DAML_OIL.hasClassQ.getNameSpace(), DAML_OIL.hasClassQ.getLocalName() );
125
126     // Constructors
127
//////////////////////////////////
128

129
130     // External signature methods
131
//////////////////////////////////
132

133     /**
134      * <p>
135      * Answer the string that is the namespace prefix for this vocabulary
136      * </p>
137      *
138      * @return The namespace prefix <code>http://www.daml.org/2001/03/daml+oil#</code>
139      */

140     public static String JavaDoc _NAMESPACE() { return "http://www.daml.org/2001/03/daml+oil#"; }
141
142
143     public String JavaDoc NAMESPACE() { return DAML_OILProfile._NAMESPACE(); }
144
145     public Resource CLASS() { return m_class; }
146     public Resource RESTRICTION() { return m_restriction; }
147     public Resource THING() { return m_thing; }
148     public Resource NOTHING() { return m_nothing; }
149     public Resource PROPERTY() { return m_property; }
150     public Resource OBJECT_PROPERTY() { return m_objectProperty; }
151     public Resource DATATYPE_PROPERTY() { return m_datatypeProperty; }
152     public Resource TRANSITIVE_PROPERTY() { return m_transitiveProperty; }
153     public Resource SYMMETRIC_PROPERTY() { return m_symmetricProperty; }
154     public Resource FUNCTIONAL_PROPERTY() { return m_functionalProperty; }
155     public Resource INVERSE_FUNCTIONAL_PROPERTY() { return m_inverseFunctionalProperty; }
156     public Resource ALL_DIFFERENT() { return m_allDifferent; }
157     public Resource ONTOLOGY() { return m_ontology; }
158     public Resource DEPRECATED_CLASS() { return m_deprecatedClass; }
159     public Resource DEPRECATED_PROPERTY() { return m_deprecatedProperty; }
160     public Resource ANNOTATION_PROPERTY() { return m_annotationProperty; }
161     public Resource ONTOLOGY_PROPERTY() { return m_ontologyProperty; }
162     public Resource LIST() { return m_list; }
163     public Resource NIL() { return m_nil; }
164     public Resource DATARANGE() { return m_datarange; }
165
166     public Property EQUIVALENT_PROPERTY() { return m_equivalentProperty; }
167     public Property EQUIVALENT_CLASS() { return m_equivalentClass; }
168     public Property DISJOINT_WITH() { return m_disjointWith; }
169     public Property SAME_INDIVIDUAL_AS() { return m_sameIndividualAs; }
170     public Property SAME_AS() { return m_sameAs; }
171     public Property DIFFERENT_FROM() { return m_differentFrom; }
172     public Property DISTINCT_MEMBERS() { return m_distinctMembers; }
173     public Property UNION_OF() { return m_unionOf; }
174     public Property INTERSECTION_OF() { return m_intersectionOf; }
175     public Property COMPLEMENT_OF() { return m_complementOf; }
176     public Property ONE_OF() { return m_oneOf; }
177     public Property ON_PROPERTY() { return m_onProperty; }
178     public Property ALL_VALUES_FROM() { return m_allValuesFrom; }
179     public Property HAS_VALUE() { return m_hasValue; }
180     public Property SOME_VALUES_FROM() { return m_someValuesFrom; }
181     public Property MIN_CARDINALITY() { return m_minCardinality; }
182     public Property MAX_CARDINALITY() { return m_maxCardinality; }
183     public Property CARDINALITY() { return m_cardinality; }
184     public Property INVERSE_OF() { return m_inverseOf; }
185     public Property IMPORTS() { return m_imports; }
186     public Property PRIOR_VERSION() { return m_priorVersion; }
187     public Property BACKWARD_COMPATIBLE_WITH() { return m_backwardsCompatibleWith; }
188     public Property INCOMPATIBLE_WITH() { return m_incompatibleWith; }
189     public Property SUB_CLASS_OF() { return m_subClassOf; }
190     public Property SUB_PROPERTY_OF() { return m_subPropertyOf; }
191     public Property DOMAIN() { return m_domain; }
192     public Property RANGE() { return m_range; }
193     public Property FIRST() { return m_first; }
194     public Property REST() { return m_rest; }
195     public Property MIN_CARDINALITY_Q() { return m_minCardinalityQ; }
196     public Property MAX_CARDINALITY_Q() { return m_maxCardinalityQ; }
197     public Property CARDINALITY_Q() { return m_cardinalityQ; }
198     public Property HAS_CLASS_Q() { return m_hasClassQ; }
199
200
201     // Annotations
202
public Property VERSION_INFO() { return m_versionInfo; }
203     public Property LABEL() { return RDFS.label; }
204     public Property COMMENT() { return RDFS.comment; }
205     public Property SEE_ALSO() { return RDFS.seeAlso; }
206     public Property IS_DEFINED_BY() { return RDFS.isDefinedBy; }
207
208     protected Resource[][] aliasTable() {
209         return new Resource[][] {
210             {DAML_OIL.subClassOf, RDFS.subClassOf},
211             {DAML_OIL.Literal, RDFS.Literal},
212             {DAML_OIL.Property, RDF.Property},
213             {DAML_OIL.type, RDF.type},
214             {DAML_OIL.value, RDF.value},
215             {DAML_OIL.subPropertyOf, RDFS.subPropertyOf},
216             {DAML_OIL.domain, RDFS.domain},
217             {DAML_OIL.range, RDFS.range},
218             {DAML_OIL.label, RDFS.label},
219             {DAML_OIL.comment, RDFS.comment},
220             {DAML_OIL.seeAlso, RDFS.seeAlso},
221             {DAML_OIL.isDefinedBy, RDFS.isDefinedBy},
222         };
223     }
224
225     /** There are no first-class axioms in DAML */
226     public Iterator getAxiomTypes() {
227         return Arrays.asList(
228             new Resource[] {
229             }
230         ).iterator();
231     }
232
233     /** The annotation properties of DAML (currently none) */
234     public Iterator getAnnotationProperties() {
235         return Arrays.asList(
236             new Resource[] {
237             }
238         ).iterator();
239     }
240
241     public Iterator getClassDescriptionTypes() {
242         return Arrays.asList(
243             new Resource[] {
244                 DAML_OIL.Class,
245                 DAML_OIL.Restriction
246             }
247         ).iterator();
248     }
249
250
251
252     /**
253      * <p>
254      * Answer true if the given graph supports a view of this node as the given
255      * language element, according to the semantic constraints of the profile.
256      * If strict checking on the ontology model is turned off, this check is
257      * skipped.
258      * </p>
259      *
260      * @param n A node to test
261      * @param g The enhanced graph containing <code>n</code>, which is assumed to
262      * be an {@link OntModel}.
263      * @param type A class indicating the facet that we are testing against.
264      * @return True if strict checking is off, or if <code>n</code> can be
265      * viewed according to the facet resource <code>res</code>
266      */

267     public boolean isSupported( Node n, EnhGraph g, Class JavaDoc type ) {
268         if (g instanceof OntModel) {
269             OntModel m = (OntModel) g;
270
271             if (type == null) {
272                 // if the facet resource is null, the facet is not in this profile so
273
// we automatically return false;
274
return false;
275             }
276             else if (!m.strictMode()) {
277                 // checking turned off
278
return true;
279             }
280             else {
281                 // lookup the profile check for this resource
282
SupportsCheck check = (SupportsCheck) s_supportsChecks.get( type );
283
284                 return (check == null) || check.doCheck( n, g );
285             }
286         }
287         else {
288             return false;
289         }
290     }
291
292
293     /**
294      * <p>
295      * Answer a descriptive string for this profile, for use in debugging and other output.
296      * </p>
297      * @return "DAML+OIL"
298      */

299     public String JavaDoc getLabel() {
300         return "DAML+OIL";
301     }
302
303
304
305     // Internal implementation methods
306
//////////////////////////////////
307

308
309     //==============================================================================
310
// Inner class definitions
311
//==============================================================================
312

313     /** Helper class for doing syntactic/semantic checks on a node */
314     protected static class SupportsCheck
315     {
316         public boolean doCheck( Node n, EnhGraph g ) {
317             return true;
318         }
319     }
320
321
322     // Table of check data
323
//////////////////////
324

325     private static Object JavaDoc[][] s_supportsCheckTable = new Object JavaDoc[][] {
326         // Resource (key), check method
327
{ OntClass.class, new SupportsCheck() {
328                                             public boolean doCheck( Node n, EnhGraph g ) {
329                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Class.asNode() ) ||
330                                                        g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) ||
331                                                        g.asGraph().contains( n, RDF.type.asNode(), RDFS.Class.asNode() ) ||
332                                                        // common cases we should support
333
n.equals( DAML_OIL.Thing.asNode() ) ||
334                                                        n.equals( DAML_OIL.Nothing.asNode() ) ||
335                                                        g.asGraph().contains( Node.ANY, RDFS.domain.asNode(), n ) ||
336                                                        g.asGraph().contains( Node.ANY, RDFS.range.asNode(), n )
337                                                        ;
338                                             }
339                                         }
340         },
341         { DatatypeProperty.class, new SupportsCheck() {
342                                             public boolean doCheck( Node n, EnhGraph g ) {
343                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.DatatypeProperty.asNode() );
344                                             }
345                                         }
346         },
347         { ObjectProperty.class, new SupportsCheck() {
348                                             public boolean doCheck( Node n, EnhGraph g ) {
349                                                return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.ObjectProperty.asNode() ) ||
350                                                       g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.TransitiveProperty.asNode() ) ||
351                                                       g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UnambiguousProperty.asNode() );
352                                             }
353                                         }
354         },
355         { FunctionalProperty.class, new SupportsCheck() {
356                                             public boolean doCheck( Node n, EnhGraph g ) {
357                                                 // DAML's alias for functional property is uniqueProperty
358
return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UniqueProperty.asNode() );
359                                             }
360                                         }
361         },
362         { InverseFunctionalProperty.class, new SupportsCheck() {
363                                             public boolean doCheck( Node n, EnhGraph g ) {
364                                                 // DAML's alias for functional property is unambiguousProperty
365
return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UnambiguousProperty.asNode() );
366                                             }
367                                         }
368         },
369         { RDFList.class, new SupportsCheck() {
370                                             public boolean doCheck( Node n, EnhGraph g ) {
371                                                 return n.equals( DAML_OIL.nil.asNode() ) ||
372                                                        g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.List.asNode() );
373                                             }
374                                         }
375         },
376         { Ontology.class, new SupportsCheck() {
377                                             public boolean doCheck( Node n, EnhGraph g ) {
378                                                 return n.equals( RDF.nil.asNode() ) ||
379                                                        g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Ontology.asNode() );
380                                             }
381                                         }
382         },
383         { OntProperty.class, new SupportsCheck() {
384                                             public boolean doCheck( Node n, EnhGraph g ) {
385                                                 return g.asGraph().contains( n, RDF.type.asNode(), RDF.Property.asNode() ) ||
386                                                        g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Property.asNode() ) ||
387                                                        g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.ObjectProperty.asNode() ) ||
388                                                        g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.DatatypeProperty.asNode() ) ||
389                                                        g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.TransitiveProperty.asNode() ) ||
390                                                        g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UnambiguousProperty.asNode() ) ||
391                                                        g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UniqueProperty.asNode() )
392                                                        ;
393                                             }
394                                         }
395         },
396         { Restriction.class, new SupportsCheck() {
397                                             public boolean doCheck( Node n, EnhGraph g ) {
398                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() );
399                                             }
400                                         }
401         },
402         { HasValueRestriction.class, new SupportsCheck() {
403                                             public boolean doCheck( Node n, EnhGraph g ) {
404                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
405                                                        containsSome( g, n, DAML_OIL.hasValue ) &&
406                                                        containsSome( g, n, DAML_OIL.onProperty );
407                                             }
408                                         }
409         },
410         { AllValuesFromRestriction.class, new SupportsCheck() {
411                                             public boolean doCheck( Node n, EnhGraph g ) {
412                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
413                                                        containsSome( g, n, DAML_OIL.toClass ) &&
414                                                        containsSome( g, n, DAML_OIL.onProperty );
415                                             }
416                                         }
417         },
418         { SomeValuesFromRestriction.class, new SupportsCheck() {
419                                             public boolean doCheck( Node n, EnhGraph g ) {
420                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
421                                                        containsSome( g, n, DAML_OIL.hasClass ) &&
422                                                        containsSome( g, n, DAML_OIL.onProperty );
423                                             }
424                                         }
425         },
426         { CardinalityRestriction.class, new SupportsCheck() {
427                                             public boolean doCheck( Node n, EnhGraph g ) {
428                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
429                                                        containsSome( g, n, DAML_OIL.cardinality ) &&
430                                                        containsSome( g, n, DAML_OIL.onProperty );
431                                             }
432                                         }
433         },
434         { MinCardinalityRestriction.class, new SupportsCheck() {
435                                             public boolean doCheck( Node n, EnhGraph g ) {
436                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
437                                                        containsSome( g, n, DAML_OIL.minCardinality ) &&
438                                                        containsSome( g, n, DAML_OIL.onProperty );
439                                             }
440                                         }
441         },
442         { MaxCardinalityRestriction.class, new SupportsCheck() {
443                                             public boolean doCheck( Node n, EnhGraph g ) {
444                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
445                                                        containsSome( g, n, DAML_OIL.maxCardinality ) &&
446                                                        containsSome( g, n, DAML_OIL.onProperty );
447                                             }
448                                         }
449         },
450         { TransitiveProperty.class, new SupportsCheck() {
451                                             public boolean doCheck( Node n, EnhGraph g ) {
452                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.TransitiveProperty.asNode() ) &&
453                                                        !g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.DatatypeProperty.asNode() );
454                                             }
455                                         }
456         },
457         { QualifiedRestriction.class, new SupportsCheck() {
458                                             public boolean doCheck( Node n, EnhGraph g ) {
459                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
460                                                        g.asGraph().contains( n, DAML_OIL.hasClassQ.asNode(), Node.ANY );
461                                             }
462                                         }
463         },
464         { CardinalityQRestriction.class, new SupportsCheck() {
465                                             public boolean doCheck( Node n, EnhGraph g ) {
466                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
467                                                        g.asGraph().contains( n, DAML_OIL.cardinalityQ.asNode(), Node.ANY );
468                                             }
469                                         }
470         },
471         { MinCardinalityQRestriction.class, new SupportsCheck() {
472                                             public boolean doCheck( Node n, EnhGraph g ) {
473                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
474                                                        g.asGraph().contains( n, DAML_OIL.minCardinalityQ.asNode(), Node.ANY );
475                                             }
476                                         }
477         },
478         { MaxCardinalityQRestriction.class, new SupportsCheck() {
479                                             public boolean doCheck( Node n, EnhGraph g ) {
480                                                 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) &&
481                                                        g.asGraph().contains( n, DAML_OIL.maxCardinalityQ.asNode(), Node.ANY );
482                                             }
483                                         }
484         },
485     };
486
487     /* just to avoid having to decorate all the calls above */
488
489     public static boolean containsSome( EnhGraph g, Node n, Property p ) {
490         return AbstractProfile.containsSome( g, n, p );
491     }
492
493     // Static variables
494
//////////////////////////////////
495

496     /** Map from resource to syntactic/semantic checks that a node can be seen as the given facet */
497     protected static HashMap s_supportsChecks = new HashMap();
498
499     static {
500         // initialise the map of supports checks from a table of static data
501
for (int i = 0; i < s_supportsCheckTable.length; i++) {
502             s_supportsChecks.put( s_supportsCheckTable[i][0], s_supportsCheckTable[i][1] );
503         }
504     }
505
506 }
507
508
509
510
511 /*
512     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
513     All rights reserved.
514
515     Redistribution and use in source and binary forms, with or without
516     modification, are permitted provided that the following conditions
517     are met:
518
519     1. Redistributions of source code must retain the above copyright
520        notice, this list of conditions and the following disclaimer.
521
522     2. Redistributions in binary form must reproduce the above copyright
523        notice, this list of conditions and the following disclaimer in the
524        documentation and/or other materials provided with the distribution.
525
526     3. The name of the author may not be used to endorse or promote products
527        derived from this software without specific prior written permission.
528
529     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
530     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
531     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
532     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
533     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
534     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
535     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
536     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
537     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
538     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
539 */

540
541
Popular Tags