001: /*****************************************************************************
002: * Source code information
003: * -----------------------
004: * Original author Ian Dickinson, HP Labs Bristol
005: * Author email Ian.Dickinson@hp.com
006: * Package Jena 2
007: * Web http://sourceforge.net/projects/jena/
008: * Created 10 Feb 2003
009: * Filename $RCSfile: DAML_OILLegacyProfile.java,v $
010: * Revision $Revision: 1.6 $
011: * Release status $State: Exp $
012: *
013: * Last modified on $Date: 2008/01/02 12:08:03 $
014: * by $Author: andy_seaborne $
015: *
016: * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
017: * (see footer for full conditions)
018: *****************************************************************************/package com.hp.hpl.jena.ontology.impl;
019:
020: // Imports
021: ///////////////
022: import com.hp.hpl.jena.enhanced.*;
023: import com.hp.hpl.jena.graph.*;
024: import com.hp.hpl.jena.ontology.*;
025: import com.hp.hpl.jena.rdf.model.*;
026: import com.hp.hpl.jena.vocabulary.*;
027:
028: import java.util.*;
029:
030: /**
031: * <p>
032: * Vocabulary constants for DAML+OIL March 2001 version. This version of the vocabulary is
033: * the one that was in use up to Jena 2.1. It has been replaced by a new version that
034: * uses RDFS namespace terms for subClass and subProperty, which is more normal practice
035: * in DAML ontologies. This version is retained for backwards compatability with Jena 2.1
036: * programs.
037: * </p>
038: *
039: * @author Ian Dickinson, HP Labs
040: * (<a href="mailto:Ian.Dickinson@hp.com" >email</a>)
041: * @version CVS $Id: DAML_OILLegacyProfile.java,v 1.6 2008/01/02 12:08:03 andy_seaborne Exp $
042: */
043: public class DAML_OILLegacyProfile extends AbstractProfile {
044: // Constants
045: //////////////////////////////////
046:
047: // Static variables
048: //////////////////////////////////
049:
050: // Instance variables
051: //////////////////////////////////
052:
053: /** Model to hold the vocabulary resources only */
054: private Model m_vocabModel = ModelFactory.createDefaultModel();
055:
056: // class resources
057: private Resource m_class = m_vocabModel
058: .createResource(DAML_OIL.Class.getURI());
059: private Resource m_restriction = m_vocabModel
060: .createResource(DAML_OIL.Restriction.getURI());
061: private Resource m_thing = m_vocabModel
062: .createResource(DAML_OIL.Thing.getURI());
063: private Resource m_nothing = m_vocabModel
064: .createResource(DAML_OIL.Nothing.getURI());
065: private Resource m_property = m_vocabModel
066: .createResource(DAML_OIL.Property.getURI());
067: private Resource m_objectProperty = m_vocabModel
068: .createResource(DAML_OIL.ObjectProperty.getURI());
069: private Resource m_datatypeProperty = m_vocabModel
070: .createResource(DAML_OIL.DatatypeProperty.getURI());
071: private Resource m_transitiveProperty = m_vocabModel
072: .createResource(DAML_OIL.TransitiveProperty.getURI());
073: private Resource m_symmetricProperty = null;
074: private Resource m_functionalProperty = m_vocabModel
075: .createResource(DAML_OIL.UniqueProperty.getURI());
076: private Resource m_inverseFunctionalProperty = m_vocabModel
077: .createResource(DAML_OIL.UnambiguousProperty.getURI());
078: private Resource m_allDifferent = null;
079: private Resource m_ontology = m_vocabModel
080: .createResource(DAML_OIL.Ontology.getURI());
081: private Resource m_deprecatedClass = null;
082: private Resource m_deprecatedProperty = null;
083: private Resource m_annotationProperty = null;
084: private Resource m_ontologyProperty = null;
085: private Resource m_list = m_vocabModel.createResource(DAML_OIL.List
086: .getURI());
087: private Resource m_nil = m_vocabModel.createResource(DAML_OIL.nil
088: .getURI());
089: private Resource m_datarange = null;
090:
091: private Property m_equivalentProperty = m_vocabModel
092: .createProperty(DAML_OIL.samePropertyAs.getNameSpace(),
093: DAML_OIL.samePropertyAs.getLocalName());
094: private Property m_equivalentClass = m_vocabModel.createProperty(
095: DAML_OIL.sameClassAs.getNameSpace(), DAML_OIL.sameClassAs
096: .getLocalName());
097: private Property m_disjointWith = m_vocabModel.createProperty(
098: DAML_OIL.disjointWith.getNameSpace(), DAML_OIL.disjointWith
099: .getLocalName());
100: private Property m_sameIndividualAs = m_vocabModel.createProperty(
101: DAML_OIL.sameIndividualAs.getNameSpace(),
102: DAML_OIL.sameIndividualAs.getLocalName());
103: private Property m_sameAs = m_vocabModel.createProperty(
104: DAML_OIL.equivalentTo.getNameSpace(), DAML_OIL.equivalentTo
105: .getLocalName());
106: private Property m_differentFrom = m_vocabModel.createProperty(
107: DAML_OIL.differentIndividualFrom.getNameSpace(),
108: DAML_OIL.differentIndividualFrom.getLocalName());
109: private Property m_distinctMembers = null;
110: private Property m_unionOf = m_vocabModel.createProperty(
111: DAML_OIL.unionOf.getNameSpace(), DAML_OIL.unionOf
112: .getLocalName());
113: private Property m_intersectionOf = m_vocabModel.createProperty(
114: DAML_OIL.intersectionOf.getNameSpace(),
115: DAML_OIL.intersectionOf.getLocalName());
116: private Property m_complementOf = m_vocabModel.createProperty(
117: DAML_OIL.complementOf.getNameSpace(), DAML_OIL.complementOf
118: .getLocalName());
119: private Property m_oneOf = m_vocabModel.createProperty(
120: DAML_OIL.oneOf.getNameSpace(), DAML_OIL.oneOf
121: .getLocalName());
122: private Property m_onProperty = m_vocabModel.createProperty(
123: DAML_OIL.onProperty.getNameSpace(), DAML_OIL.onProperty
124: .getLocalName());
125: private Property m_allValuesFrom = m_vocabModel.createProperty(
126: DAML_OIL.toClass.getNameSpace(), DAML_OIL.toClass
127: .getLocalName());
128: private Property m_hasValue = m_vocabModel.createProperty(
129: DAML_OIL.hasValue.getNameSpace(), DAML_OIL.hasValue
130: .getLocalName());
131: private Property m_someValuesFrom = m_vocabModel.createProperty(
132: DAML_OIL.hasClass.getNameSpace(), DAML_OIL.hasClass
133: .getLocalName());
134: private Property m_minCardinality = m_vocabModel.createProperty(
135: DAML_OIL.minCardinality.getNameSpace(),
136: DAML_OIL.minCardinality.getLocalName());
137: private Property m_maxCardinality = m_vocabModel.createProperty(
138: DAML_OIL.maxCardinality.getNameSpace(),
139: DAML_OIL.maxCardinality.getLocalName());
140: private Property m_cardinality = m_vocabModel.createProperty(
141: DAML_OIL.cardinality.getNameSpace(), DAML_OIL.cardinality
142: .getLocalName());
143: private Property m_inverseOf = m_vocabModel.createProperty(
144: DAML_OIL.inverseOf.getNameSpace(), DAML_OIL.inverseOf
145: .getLocalName());
146: private Property m_imports = m_vocabModel.createProperty(
147: DAML_OIL.imports.getNameSpace(), DAML_OIL.imports
148: .getLocalName());
149: private Property m_versionInfo = m_vocabModel.createProperty(
150: DAML_OIL.versionInfo.getNameSpace(), DAML_OIL.versionInfo
151: .getLocalName());
152: private Property m_priorVersion = null;
153: private Property m_backwardsCompatibleWith = null;
154: private Property m_incompatibleWith = null;
155: private Property m_subPropertyOf = m_vocabModel.createProperty(
156: DAML_OIL.subPropertyOf.getNameSpace(),
157: DAML_OIL.subPropertyOf.getLocalName());
158: private Property m_subClassOf = m_vocabModel.createProperty(
159: DAML_OIL.subClassOf.getNameSpace(), DAML_OIL.subClassOf
160: .getLocalName());
161: private Property m_domain = m_vocabModel.createProperty(
162: DAML_OIL.subClassOf.getNameSpace(), DAML_OIL.domain
163: .getLocalName());
164: private Property m_range = m_vocabModel.createProperty(
165: DAML_OIL.subClassOf.getNameSpace(), DAML_OIL.range
166: .getLocalName());
167: private Property m_first = m_vocabModel.createProperty(
168: DAML_OIL.first.getNameSpace(), DAML_OIL.first
169: .getLocalName());
170: private Property m_rest = m_vocabModel.createProperty(DAML_OIL.rest
171: .getNameSpace(), DAML_OIL.rest.getLocalName());
172: private Property m_minCardinalityQ = m_vocabModel.createProperty(
173: DAML_OIL.minCardinalityQ.getNameSpace(),
174: DAML_OIL.minCardinalityQ.getLocalName());
175: private Property m_maxCardinalityQ = m_vocabModel.createProperty(
176: DAML_OIL.maxCardinalityQ.getNameSpace(),
177: DAML_OIL.maxCardinalityQ.getLocalName());
178: private Property m_cardinalityQ = m_vocabModel.createProperty(
179: DAML_OIL.cardinalityQ.getNameSpace(), DAML_OIL.cardinalityQ
180: .getLocalName());
181: private Property m_hasClassQ = m_vocabModel.createProperty(
182: DAML_OIL.hasClassQ.getNameSpace(), DAML_OIL.hasClassQ
183: .getLocalName());
184:
185: // Constructors
186: //////////////////////////////////
187:
188: // External signature methods
189: //////////////////////////////////
190:
191: /**
192: * <p>
193: * Answer the string that is the namespace prefix for this vocabulary
194: * </p>
195: *
196: * @return The namespace prefix <code>http://www.daml.org/2001/03/daml+oil#</code>
197: */
198: public static String _NAMESPACE() {
199: return "http://www.daml.org/2001/03/daml+oil#";
200: }
201:
202: public String NAMESPACE() {
203: return DAML_OILProfile._NAMESPACE();
204: }
205:
206: public Resource CLASS() {
207: return m_class;
208: }
209:
210: public Resource RESTRICTION() {
211: return m_restriction;
212: }
213:
214: public Resource THING() {
215: return m_thing;
216: }
217:
218: public Resource NOTHING() {
219: return m_nothing;
220: }
221:
222: public Resource PROPERTY() {
223: return m_property;
224: }
225:
226: public Resource OBJECT_PROPERTY() {
227: return m_objectProperty;
228: }
229:
230: public Resource DATATYPE_PROPERTY() {
231: return m_datatypeProperty;
232: }
233:
234: public Resource TRANSITIVE_PROPERTY() {
235: return m_transitiveProperty;
236: }
237:
238: public Resource SYMMETRIC_PROPERTY() {
239: return m_symmetricProperty;
240: }
241:
242: public Resource FUNCTIONAL_PROPERTY() {
243: return m_functionalProperty;
244: }
245:
246: public Resource INVERSE_FUNCTIONAL_PROPERTY() {
247: return m_inverseFunctionalProperty;
248: }
249:
250: public Resource ALL_DIFFERENT() {
251: return m_allDifferent;
252: }
253:
254: public Resource ONTOLOGY() {
255: return m_ontology;
256: }
257:
258: public Resource DEPRECATED_CLASS() {
259: return m_deprecatedClass;
260: }
261:
262: public Resource DEPRECATED_PROPERTY() {
263: return m_deprecatedProperty;
264: }
265:
266: public Resource ANNOTATION_PROPERTY() {
267: return m_annotationProperty;
268: }
269:
270: public Resource ONTOLOGY_PROPERTY() {
271: return m_ontologyProperty;
272: }
273:
274: public Resource LIST() {
275: return m_list;
276: }
277:
278: public Resource NIL() {
279: return m_nil;
280: }
281:
282: public Resource DATARANGE() {
283: return m_datarange;
284: }
285:
286: public Property EQUIVALENT_PROPERTY() {
287: return m_equivalentProperty;
288: }
289:
290: public Property EQUIVALENT_CLASS() {
291: return m_equivalentClass;
292: }
293:
294: public Property DISJOINT_WITH() {
295: return m_disjointWith;
296: }
297:
298: public Property SAME_INDIVIDUAL_AS() {
299: return m_sameIndividualAs;
300: }
301:
302: public Property SAME_AS() {
303: return m_sameAs;
304: }
305:
306: public Property DIFFERENT_FROM() {
307: return m_differentFrom;
308: }
309:
310: public Property DISTINCT_MEMBERS() {
311: return m_distinctMembers;
312: }
313:
314: public Property UNION_OF() {
315: return m_unionOf;
316: }
317:
318: public Property INTERSECTION_OF() {
319: return m_intersectionOf;
320: }
321:
322: public Property COMPLEMENT_OF() {
323: return m_complementOf;
324: }
325:
326: public Property ONE_OF() {
327: return m_oneOf;
328: }
329:
330: public Property ON_PROPERTY() {
331: return m_onProperty;
332: }
333:
334: public Property ALL_VALUES_FROM() {
335: return m_allValuesFrom;
336: }
337:
338: public Property HAS_VALUE() {
339: return m_hasValue;
340: }
341:
342: public Property SOME_VALUES_FROM() {
343: return m_someValuesFrom;
344: }
345:
346: public Property MIN_CARDINALITY() {
347: return m_minCardinality;
348: }
349:
350: public Property MAX_CARDINALITY() {
351: return m_maxCardinality;
352: }
353:
354: public Property CARDINALITY() {
355: return m_cardinality;
356: }
357:
358: public Property INVERSE_OF() {
359: return m_inverseOf;
360: }
361:
362: public Property IMPORTS() {
363: return m_imports;
364: }
365:
366: public Property PRIOR_VERSION() {
367: return m_priorVersion;
368: }
369:
370: public Property BACKWARD_COMPATIBLE_WITH() {
371: return m_backwardsCompatibleWith;
372: }
373:
374: public Property INCOMPATIBLE_WITH() {
375: return m_incompatibleWith;
376: }
377:
378: public Property SUB_CLASS_OF() {
379: return m_subClassOf;
380: }
381:
382: public Property SUB_PROPERTY_OF() {
383: return m_subPropertyOf;
384: }
385:
386: public Property DOMAIN() {
387: return m_domain;
388: }
389:
390: public Property RANGE() {
391: return m_range;
392: }
393:
394: public Property FIRST() {
395: return m_first;
396: }
397:
398: public Property REST() {
399: return m_rest;
400: }
401:
402: public Property MIN_CARDINALITY_Q() {
403: return m_minCardinalityQ;
404: }
405:
406: public Property MAX_CARDINALITY_Q() {
407: return m_maxCardinalityQ;
408: }
409:
410: public Property CARDINALITY_Q() {
411: return m_cardinalityQ;
412: }
413:
414: public Property HAS_CLASS_Q() {
415: return m_hasClassQ;
416: }
417:
418: // Annotations
419: public Property VERSION_INFO() {
420: return m_versionInfo;
421: }
422:
423: public Property LABEL() {
424: return RDFS.label;
425: }
426:
427: public Property COMMENT() {
428: return RDFS.comment;
429: }
430:
431: public Property SEE_ALSO() {
432: return RDFS.seeAlso;
433: }
434:
435: public Property IS_DEFINED_BY() {
436: return RDFS.isDefinedBy;
437: }
438:
439: protected Resource[][] aliasTable() {
440: return new Resource[][] {
441: { DAML_OIL.subClassOf, RDFS.subClassOf },
442: { DAML_OIL.Literal, RDFS.Literal },
443: { DAML_OIL.Property, RDF.Property },
444: { DAML_OIL.type, RDF.type },
445: { DAML_OIL.value, RDF.value },
446: { DAML_OIL.subPropertyOf, RDFS.subPropertyOf },
447: { DAML_OIL.domain, RDFS.domain },
448: { DAML_OIL.range, RDFS.range },
449: { DAML_OIL.label, RDFS.label },
450: { DAML_OIL.comment, RDFS.comment },
451: { DAML_OIL.seeAlso, RDFS.seeAlso },
452: { DAML_OIL.isDefinedBy, RDFS.isDefinedBy }, };
453: }
454:
455: /** There are no first-class axioms in DAML */
456: public Iterator getAxiomTypes() {
457: return Arrays.asList(new Resource[] {}).iterator();
458: }
459:
460: /** The annotation properties of DAML (currently none) */
461: public Iterator getAnnotationProperties() {
462: return Arrays.asList(new Resource[] {}).iterator();
463: }
464:
465: public Iterator getClassDescriptionTypes() {
466: return Arrays
467: .asList(
468: new Resource[] { DAML_OIL.Class,
469: DAML_OIL.Restriction }).iterator();
470: }
471:
472: /**
473: * <p>
474: * Answer true if the given graph supports a view of this node as the given
475: * language element, according to the semantic constraints of the profile.
476: * If strict checking on the ontology model is turned off, this check is
477: * skipped.
478: * </p>
479: *
480: * @param n A node to test
481: * @param g The enhanced graph containing <code>n</code>, which is assumed to
482: * be an {@link OntModel}.
483: * @param type A class indicating the facet that we are testing against.
484: * @return True if strict checking is off, or if <code>n</code> can be
485: * viewed according to the facet resource <code>res</code>
486: */
487: public boolean isSupported(Node n, EnhGraph g, Class type) {
488: if (g instanceof OntModel) {
489: OntModel m = (OntModel) g;
490:
491: if (type == null) {
492: // if the facet resource is null, the facet is not in this profile so
493: // we automatically return false;
494: return false;
495: } else if (!m.strictMode()) {
496: // checking turned off
497: return true;
498: } else {
499: // lookup the profile check for this resource
500: SupportsCheck check = (SupportsCheck) s_supportsChecks
501: .get(type);
502:
503: return (check == null) || check.doCheck(n, g);
504: }
505: } else {
506: return false;
507: }
508: }
509:
510: /**
511: * <p>
512: * Answer a descriptive string for this profile, for use in debugging and other output.
513: * </p>
514: * @return "DAML+OIL"
515: */
516: public String getLabel() {
517: return "DAML+OIL";
518: }
519:
520: // Internal implementation methods
521: //////////////////////////////////
522:
523: //==============================================================================
524: // Inner class definitions
525: //==============================================================================
526:
527: /** Helper class for doing syntactic/semantic checks on a node */
528: protected static class SupportsCheck {
529: public boolean doCheck(Node n, EnhGraph g) {
530: return true;
531: }
532: }
533:
534: // Table of check data
535: //////////////////////
536:
537: private static Object[][] s_supportsCheckTable = new Object[][] {
538: // Resource (key), check method
539: { OntClass.class, new SupportsCheck() {
540: public boolean doCheck(Node n, EnhGraph g) {
541: return g.asGraph().contains(n, RDF.type.asNode(),
542: DAML_OIL.Class.asNode())
543: || g.asGraph().contains(n,
544: RDF.type.asNode(),
545: DAML_OIL.Restriction.asNode())
546: || g.asGraph().contains(n,
547: RDF.type.asNode(),
548: RDFS.Class.asNode())
549: ||
550: // common cases we should support
551: n.equals(DAML_OIL.Thing.asNode())
552: || n.equals(DAML_OIL.Nothing.asNode())
553: || g.asGraph().contains(Node.ANY,
554: DAML_OIL.domain.asNode(), n)
555: || g.asGraph().contains(Node.ANY,
556: DAML_OIL.range.asNode(), n);
557: }
558: } },
559: { DatatypeProperty.class, new SupportsCheck() {
560: public boolean doCheck(Node n, EnhGraph g) {
561: return g.asGraph().contains(n, RDF.type.asNode(),
562: DAML_OIL.DatatypeProperty.asNode());
563: }
564: } },
565: { ObjectProperty.class, new SupportsCheck() {
566: public boolean doCheck(Node n, EnhGraph g) {
567: return g.asGraph().contains(n, RDF.type.asNode(),
568: DAML_OIL.ObjectProperty.asNode())
569: || g.asGraph().contains(
570: n,
571: RDF.type.asNode(),
572: DAML_OIL.TransitiveProperty
573: .asNode())
574: || g.asGraph().contains(
575: n,
576: RDF.type.asNode(),
577: DAML_OIL.UnambiguousProperty
578: .asNode());
579: }
580: } },
581: { FunctionalProperty.class, new SupportsCheck() {
582: public boolean doCheck(Node n, EnhGraph g) {
583: // DAML's alias for functional property is uniqueProperty
584: return g.asGraph().contains(n, RDF.type.asNode(),
585: DAML_OIL.UniqueProperty.asNode());
586: }
587: } },
588: { InverseFunctionalProperty.class, new SupportsCheck() {
589: public boolean doCheck(Node n, EnhGraph g) {
590: // DAML's alias for functional property is unambiguousProperty
591: return g.asGraph().contains(n, RDF.type.asNode(),
592: DAML_OIL.UnambiguousProperty.asNode());
593: }
594: } },
595: { RDFList.class, new SupportsCheck() {
596: public boolean doCheck(Node n, EnhGraph g) {
597: return n.equals(DAML_OIL.nil.asNode())
598: || g.asGraph().contains(n,
599: RDF.type.asNode(),
600: DAML_OIL.List.asNode());
601: }
602: } },
603: { Ontology.class, new SupportsCheck() {
604: public boolean doCheck(Node n, EnhGraph g) {
605: return n.equals(RDF.nil.asNode())
606: || g.asGraph().contains(n,
607: RDF.type.asNode(),
608: DAML_OIL.Ontology.asNode());
609: }
610: } },
611: { OntProperty.class, new SupportsCheck() {
612: public boolean doCheck(Node n, EnhGraph g) {
613: return g.asGraph().contains(n, RDF.type.asNode(),
614: RDF.Property.asNode())
615: || g.asGraph().contains(n,
616: RDF.type.asNode(),
617: DAML_OIL.Property.asNode())
618: || g.asGraph().contains(n,
619: RDF.type.asNode(),
620: DAML_OIL.ObjectProperty.asNode())
621: || g.asGraph().contains(n,
622: RDF.type.asNode(),
623: DAML_OIL.DatatypeProperty.asNode())
624: || g.asGraph().contains(
625: n,
626: RDF.type.asNode(),
627: DAML_OIL.TransitiveProperty
628: .asNode())
629: || g.asGraph().contains(
630: n,
631: RDF.type.asNode(),
632: DAML_OIL.UnambiguousProperty
633: .asNode())
634: || g.asGraph().contains(n,
635: RDF.type.asNode(),
636: DAML_OIL.UniqueProperty.asNode());
637: }
638: } },
639: { Restriction.class, new SupportsCheck() {
640: public boolean doCheck(Node n, EnhGraph g) {
641: return g.asGraph().contains(n, RDF.type.asNode(),
642: DAML_OIL.Restriction.asNode());
643: }
644: } },
645: { HasValueRestriction.class, new SupportsCheck() {
646: public boolean doCheck(Node n, EnhGraph g) {
647: return g.asGraph().contains(n, RDF.type.asNode(),
648: DAML_OIL.Restriction.asNode())
649: && containsSome(g, n, DAML_OIL.hasValue)
650: && containsSome(g, n, DAML_OIL.onProperty);
651: }
652: } },
653: { AllValuesFromRestriction.class, new SupportsCheck() {
654: public boolean doCheck(Node n, EnhGraph g) {
655: return g.asGraph().contains(n, RDF.type.asNode(),
656: DAML_OIL.Restriction.asNode())
657: && containsSome(g, n, DAML_OIL.toClass)
658: && containsSome(g, n, DAML_OIL.onProperty);
659: }
660: } },
661: { SomeValuesFromRestriction.class, new SupportsCheck() {
662: public boolean doCheck(Node n, EnhGraph g) {
663: return g.asGraph().contains(n, RDF.type.asNode(),
664: DAML_OIL.Restriction.asNode())
665: && containsSome(g, n, DAML_OIL.hasClass)
666: && containsSome(g, n, DAML_OIL.onProperty);
667: }
668: } },
669: { CardinalityRestriction.class, new SupportsCheck() {
670: public boolean doCheck(Node n, EnhGraph g) {
671: return g.asGraph().contains(n, RDF.type.asNode(),
672: DAML_OIL.Restriction.asNode())
673: && containsSome(g, n, DAML_OIL.cardinality)
674: && containsSome(g, n, DAML_OIL.onProperty);
675: }
676: } },
677: { MinCardinalityRestriction.class, new SupportsCheck() {
678: public boolean doCheck(Node n, EnhGraph g) {
679: return g.asGraph().contains(n, RDF.type.asNode(),
680: DAML_OIL.Restriction.asNode())
681: && containsSome(g, n,
682: DAML_OIL.minCardinality)
683: && containsSome(g, n, DAML_OIL.onProperty);
684: }
685: } },
686: { MaxCardinalityRestriction.class, new SupportsCheck() {
687: public boolean doCheck(Node n, EnhGraph g) {
688: return g.asGraph().contains(n, RDF.type.asNode(),
689: DAML_OIL.Restriction.asNode())
690: && containsSome(g, n,
691: DAML_OIL.maxCardinality)
692: && containsSome(g, n, DAML_OIL.onProperty);
693: }
694: } },
695: { TransitiveProperty.class, new SupportsCheck() {
696: public boolean doCheck(Node n, EnhGraph g) {
697: return g.asGraph().contains(n, RDF.type.asNode(),
698: DAML_OIL.TransitiveProperty.asNode())
699: && !g.asGraph().contains(n,
700: RDF.type.asNode(),
701: DAML_OIL.DatatypeProperty.asNode());
702: }
703: } },
704: { QualifiedRestriction.class, new SupportsCheck() {
705: public boolean doCheck(Node n, EnhGraph g) {
706: return g.asGraph().contains(n, RDF.type.asNode(),
707: DAML_OIL.Restriction.asNode())
708: && g.asGraph().contains(n,
709: DAML_OIL.hasClassQ.asNode(),
710: Node.ANY);
711: }
712: } },
713: { CardinalityQRestriction.class, new SupportsCheck() {
714: public boolean doCheck(Node n, EnhGraph g) {
715: return g.asGraph().contains(n, RDF.type.asNode(),
716: DAML_OIL.Restriction.asNode())
717: && g.asGraph().contains(n,
718: DAML_OIL.cardinalityQ.asNode(),
719: Node.ANY);
720: }
721: } },
722: { MinCardinalityQRestriction.class, new SupportsCheck() {
723: public boolean doCheck(Node n, EnhGraph g) {
724: return g.asGraph().contains(n, RDF.type.asNode(),
725: DAML_OIL.Restriction.asNode())
726: && g.asGraph().contains(n,
727: DAML_OIL.minCardinalityQ.asNode(),
728: Node.ANY);
729: }
730: } },
731: { MaxCardinalityQRestriction.class, new SupportsCheck() {
732: public boolean doCheck(Node n, EnhGraph g) {
733: return g.asGraph().contains(n, RDF.type.asNode(),
734: DAML_OIL.Restriction.asNode())
735: && g.asGraph().contains(n,
736: DAML_OIL.maxCardinalityQ.asNode(),
737: Node.ANY);
738: }
739: } }, };
740:
741: /* just to avoid having to decorate all the calls above */
742:
743: public static boolean containsSome(EnhGraph g, Node n, Property p) {
744: return AbstractProfile.containsSome(g, n, p);
745: }
746:
747: // Static variables
748: //////////////////////////////////
749:
750: /** Map from resource to syntactic/semantic checks that a node can be seen as the given facet */
751: protected static HashMap s_supportsChecks = new HashMap();
752:
753: static {
754: // initialise the map of supports checks from a table of static data
755: for (int i = 0; i < s_supportsCheckTable.length; i++) {
756: s_supportsChecks.put(s_supportsCheckTable[i][0],
757: s_supportsCheckTable[i][1]);
758: }
759: }
760:
761: }
762:
763: /*
764: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
765: All rights reserved.
766:
767: Redistribution and use in source and binary forms, with or without
768: modification, are permitted provided that the following conditions
769: are met:
770:
771: 1. Redistributions of source code must retain the above copyright
772: notice, this list of conditions and the following disclaimer.
773:
774: 2. Redistributions in binary form must reproduce the above copyright
775: notice, this list of conditions and the following disclaimer in the
776: documentation and/or other materials provided with the distribution.
777:
778: 3. The name of the author may not be used to endorse or promote products
779: derived from this software without specific prior written permission.
780:
781: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
782: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
783: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
784: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
785: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
786: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
787: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
788: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
789: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
790: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
791: */
|