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 01-Apr-2003
009: * Filename $RCSfile: AnnotationPropertyImpl.java,v $
010: * Revision $Revision: 1.11 $
011: * Release status $State: Exp $
012: *
013: * Last modified on $Date: 2008/01/02 12:08:01 $
014: * by $Author: andy_seaborne $
015: *
016: * (c) Copyright 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.ontology.*;
023: import com.hp.hpl.jena.graph.*;
024: import com.hp.hpl.jena.enhanced.*;
025: import com.hp.hpl.jena.rdf.model.*;
026:
027: /**
028: * <p>
029: * Implementation for ontology abstraction of annotation property
030: * </p>
031: *
032: * @author Ian Dickinson, HP Labs
033: * (<a href="mailto:Ian.Dickinson@hp.com" >email</a>)
034: * @version CVS $Id: AnnotationPropertyImpl.java,v 1.11 2008/01/02 12:08:01 andy_seaborne Exp $
035: */
036: public class AnnotationPropertyImpl extends OntPropertyImpl implements
037: AnnotationProperty {
038: // Constants
039: //////////////////////////////////
040:
041: // Static variables
042: //////////////////////////////////
043:
044: /**
045: * A factory for generating AnnotationProperty facets from nodes in enhanced graphs.
046: * Note: should not be invoked directly by user code: use
047: * {@link com.hp.hpl.jena.rdf.model.RDFNode#as as()} instead.
048: */
049: public static Implementation factory = new Implementation() {
050: public EnhNode wrap(Node n, EnhGraph eg) {
051: if (canWrap(n, eg)) {
052: return new AnnotationPropertyImpl(n, eg);
053: } else {
054: throw new ConversionException("Cannot convert node "
055: + n + " to AnnotationProperty");
056: }
057: }
058:
059: public boolean canWrap(Node node, EnhGraph eg) {
060: // node will support being an AnnotationProperty facet if it has rdf:type owl:AnnotationProperty or equivalent
061: Profile profile = (eg instanceof OntModel) ? ((OntModel) eg)
062: .getProfile()
063: : null;
064: return (profile != null)
065: && profile.isSupported(node, eg,
066: AnnotationProperty.class);
067: }
068: };
069:
070: // Instance variables
071: //////////////////////////////////
072:
073: /**
074: * <p>
075: * Construct an ontology resource represented by the given node in the given graph.
076: * </p>
077: *
078: * @param n The node that represents the resource
079: * @param g The enh graph that contains n
080: */
081: public AnnotationPropertyImpl(Node n, EnhGraph g) {
082: super (n, g);
083: }
084:
085: // Constructors
086: //////////////////////////////////
087:
088: // External signature methods
089: //////////////////////////////////
090:
091: /**
092: * <p>
093: * Answer true to indicate that this resource is an RDF property.
094: * </p>
095: *
096: * @return True.
097: */
098: public boolean isProperty() {
099: return true;
100: }
101:
102: /**
103: * @see Property#getOrdinal()
104: */
105: public int getOrdinal() {
106: return ((Property) as(Property.class)).getOrdinal();
107: }
108:
109: // Internal implementation methods
110: //////////////////////////////////
111:
112: //==============================================================================
113: // Inner class definitions
114: //==============================================================================
115:
116: }
117:
118: /*
119: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
120: All rights reserved.
121:
122: Redistribution and use in source and binary forms, with or without
123: modification, are permitted provided that the following conditions
124: are met:
125:
126: 1. Redistributions of source code must retain the above copyright
127: notice, this list of conditions and the following disclaimer.
128:
129: 2. Redistributions in binary form must reproduce the above copyright
130: notice, this list of conditions and the following disclaimer in the
131: documentation and/or other materials provided with the distribution.
132:
133: 3. The name of the author may not be used to endorse or promote products
134: derived from this software without specific prior written permission.
135:
136: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
137: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
138: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
139: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
140: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
141: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
145: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146: */
|