KickJava   Java API By Example, From Geeks To Geeks.

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


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 01-Apr-2003
9  * Filename $RCSfile: AnnotationPropertyImpl.java,v $
10  * Revision $Revision: 1.7 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/02/21 12:06:16 $
14  * by $Author: andy_seaborne $
15  *
16  * (c) Copyright 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.ontology.*;
28 import com.hp.hpl.jena.graph.*;
29 import com.hp.hpl.jena.enhanced.*;
30 import com.hp.hpl.jena.rdf.model.*;
31
32
33 /**
34  * <p>
35  * Implementation for ontology abstraction of annotation property
36  * </p>
37  *
38  * @author Ian Dickinson, HP Labs
39  * (<a HREF="mailto:Ian.Dickinson@hp.com" >email</a>)
40  * @version CVS $Id: AnnotationPropertyImpl.java,v 1.7 2005/02/21 12:06:16 andy_seaborne Exp $
41  */

42 public class AnnotationPropertyImpl
43     extends OntResourceImpl
44     implements AnnotationProperty
45 {
46     // Constants
47
//////////////////////////////////
48

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

52     /**
53      * A factory for generating AnnotationProperty 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 AnnotationPropertyImpl( n, eg );
61             }
62             else {
63                 throw new ConversionException( "Cannot convert node " + n + " to AnnotationProperty");
64             }
65         }
66         
67         public boolean canWrap( Node node, EnhGraph eg ) {
68             // node will support being an AnnotationProperty facet if it has rdf:type owl:AnnotationProperty or equivalent
69
Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null;
70             return (profile != null) && profile.isSupported( node, eg, AnnotationProperty.class );
71         }
72     };
73
74
75     // Instance variables
76
//////////////////////////////////
77

78     /**
79      * <p>
80      * Construct an ontology resource represented by the given node in the given graph.
81      * </p>
82      *
83      * @param n The node that represents the resource
84      * @param g The enh graph that contains n
85      */

86     public AnnotationPropertyImpl( Node n, EnhGraph g ) {
87         super( n, g );
88     }
89     
90     
91     // Constructors
92
//////////////////////////////////
93

94     // External signature methods
95
//////////////////////////////////
96

97     /**
98      * <p>
99      * Answer true to indicate that this resource is an RDF property.
100      * </p>
101      *
102      * @return True.
103      */

104     public boolean isProperty() {
105         return true;
106     }
107     
108     
109     /**
110      * @see Property#getOrdinal()
111      */

112     public int getOrdinal() {
113         return ((Property) as( Property.class )).getOrdinal();
114     }
115     
116     
117     // Internal implementation methods
118
//////////////////////////////////
119

120     //==============================================================================
121
// Inner class definitions
122
//==============================================================================
123

124 }
125
126
127 /*
128     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
129     All rights reserved.
130
131     Redistribution and use in source and binary forms, with or without
132     modification, are permitted provided that the following conditions
133     are met:
134
135     1. Redistributions of source code must retain the above copyright
136        notice, this list of conditions and the following disclaimer.
137
138     2. Redistributions in binary form must reproduce the above copyright
139        notice, this list of conditions and the following disclaimer in the
140        documentation and/or other materials provided with the distribution.
141
142     3. The name of the author may not be used to endorse or promote products
143        derived from this software without specific prior written permission.
144
145     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
146     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
147     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
148     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
149     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
150     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
151     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
152     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
153     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
154     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
155 */

156
Popular Tags