KickJava   Java API By Example, From Geeks To Geeks.

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


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_OILLegacyProfile.java,v $
10  * Revision $Revision: 1.3 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/04/11 16:22:49 $
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 vocabulary is
40  * the one that was in use up to Jena 2.1. It has been replaced by a new version that
41  * uses RDFS namespace terms for subClass and subProperty, which is more normal practice
42  * in DAML ontologies. This version is retained for backwards compatability with Jena 2.1
43  * programs.
44  * </p>
45  *
46  * @author Ian Dickinson, HP Labs
47  * (<a HREF="mailto:Ian.Dickinson@hp.com" >email</a>)
48  * @version CVS $Id: DAML_OILLegacyProfile.java,v 1.3 2005/04/11 16:22:49 ian_dickinson Exp $
49  */

50 public class DAML_OILLegacyProfile
51     extends AbstractProfile
52 {
53     // Constants
54
//////////////////////////////////
55

56
57     // Static variables
58
//////////////////////////////////
59

60
61     // Instance variables
62
//////////////////////////////////
63

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

127
128     // External signature methods
129
//////////////////////////////////
130

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

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

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

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

306
307     //==============================================================================
308
// Inner class definitions
309
//==============================================================================
310

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

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

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

538
539
Popular Tags