KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > ontology > daml > impl > DAMLOntologyImpl


1 /*****************************************************************************
2  * Source code information
3  * -----------------------
4  * Original author Ian Dickinson, HP Labs Bristol
5  * Author email Ian.Dickinson@hp.com
6  * Package Jena
7  * Created 5 Jan 2001
8  * Filename $RCSfile: DAMLOntologyImpl.java,v $
9  * Revision $Revision: 1.10 $
10  * Release status Preview-release $State: Exp $
11  *
12  * Last modified on $Date: 2005/02/21 12:05:26 $
13  * by $Author: andy_seaborne $
14  *
15  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
16  * (see footer for full conditions)
17  *****************************************************************************/

18
19 // Package
20
///////////////
21
package com.hp.hpl.jena.ontology.daml.impl;
22
23
24 // Imports
25
///////////////
26
import com.hp.hpl.jena.rdf.model.*;
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.ontology.daml.*;
31 import com.hp.hpl.jena.vocabulary.*;
32
33
34
35 /**
36  * <p>Encapsulates the properties known for a given source ontology.</p>
37  *
38  * @author Ian Dickinson, HP Labs (<a HREF="mailto:Ian.Dickinson@hp.com">email</a>)
39  * @version CVS info: $Id: DAMLOntologyImpl.java,v 1.10 2005/02/21 12:05:26 andy_seaborne Exp $
40  */

41 public class DAMLOntologyImpl
42     extends DAMLCommonImpl
43     implements DAMLOntology
44 {
45     // Constants
46
//////////////////////////////////
47

48
49     // Static variables
50
//////////////////////////////////
51

52     /**
53      * A factory for generating DAMLDataInstance facets from nodes in enhanced graphs.
54      * Note: should not be invoked directly by user code: use
55      * {@link com.hp.hpl.jena.rdf.model.RDFNode#as as()} instead.
56      */

57     public static Implementation factory = new Implementation() {
58         public EnhNode wrap( Node n, EnhGraph eg ) {
59             if (canWrap( n, eg )) {
60                 return new DAMLOntologyImpl( n, eg );
61             }
62             else {
63                 throw new ConversionException( "Cannot convert node " + n.toString() + " to DAMLOntology" );
64             }
65         }
66             
67         public boolean canWrap( Node node, EnhGraph eg ) {
68             return hasType( node, eg, DAML_OIL.Ontology );
69         }
70     };
71
72     // Instance variables
73
//////////////////////////////////
74

75     /** Literal value accessor for the version info property */
76     private LiteralAccessor m_propVersionInfo = null;
77
78
79
80     // Constructors
81
//////////////////////////////////
82

83     /**
84      * <p>
85      * Construct a DAML list represented by the given node in the given graph.
86      * </p>
87      *
88      * @param n The node that represents the resource
89      * @param g The enh graph that contains n
90      */

91     public DAMLOntologyImpl( Node n, EnhGraph g ) {
92         super( n, g );
93     }
94
95
96
97     // External signature methods
98
//////////////////////////////////
99

100
101     /**
102      * Property value accessor for the version info property of the ontology.
103      *
104      * @return A literal accessor that gives access to the version info of the ontology.
105      */

106     public LiteralAccessor prop_versionInfo() {
107         if (m_propVersionInfo == null) {
108             m_propVersionInfo = new LiteralAccessorImpl( getVocabulary().versionInfo(), this );
109         }
110
111         return m_propVersionInfo;
112     }
113
114
115     /**
116      * Answer an iteration of resources that represent the URI's of the
117      * ontologies that this ontology imports.
118      *
119      * @return An iterator over the resources representing imported ontologies
120      */

121     public NodeIterator getImportedOntologies() {
122         return listPropertyValues( DAML_OIL.imports );
123         //return new ConcatenatedNodeIterator( ,
124
// getPropertyValues( DAML_OIL_2000_12.imports ) );
125
}
126
127
128     /**
129      * Add the given ontology to the list of ontologies managed by the
130      * knowledge store, and add it as an imoport property to this ontology object.
131      *
132      * @param uri The URI of the model.
133      */

134     public void addImportedOntology( String JavaDoc uri ) {
135         // assert the model we're importing
136
addProperty( getVocabulary().imports(), getModel().createLiteral( uri ) );
137
138         // notify the knowledge store about the included model
139
if (getDAMLModel().getLoader().getLoadImportedOntologies()) {
140            getModel().read( uri );
141         }
142     }
143
144
145
146
147     // Internal implementation methods
148
//////////////////////////////////
149

150
151     //==============================================================================
152
// Inner class definitions
153
//==============================================================================
154

155
156 }
157
158
159 /*
160     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
161     All rights reserved.
162
163     Redistribution and use in source and binary forms, with or without
164     modification, are permitted provided that the following conditions
165     are met:
166
167     1. Redistributions of source code must retain the above copyright
168        notice, this list of conditions and the following disclaimer.
169
170     2. Redistributions in binary form must reproduce the above copyright
171        notice, this list of conditions and the following disclaimer in the
172        documentation and/or other materials provided with the distribution.
173
174     3. The name of the author may not be used to endorse or promote products
175        derived from this software without specific prior written permission.
176
177     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
178     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
179     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
180     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
181     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
182     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
183     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
184     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
185     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
186     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
187 */

188
189
Popular Tags