View Javadoc

1   /*
2    * $Id: IOWLElement.java,v 1.10 2004/09/02 20:45:52 jlerner Exp $
3    *
4    * Copyright (c) 1999-2004, BBN Technologies, LLC.
5    * All rights reserved.
6    * http://www.daml.org/legal/opensource/bbn_license.html
7    */
8   
9   package com.bbn.swede.core;
10  
11  import org.eclipse.core.resources.IResource;
12  import org.eclipse.core.runtime.IAdaptable;
13  import org.eclipse.core.runtime.IPath;
14  
15  /***
16   * Common protocol for all elements provided by the OWL model.
17   * @author jlerner
18   * @author tself
19   */
20  public interface IOWLElement extends IAdaptable
21  {
22     /***
23      * Returns the element directly containing this element.
24      * @return the parent element, or <code>null</code> if it has no parent.
25      */
26     IOWLElement getParent();
27     /***
28      * Sets the parent of this element.
29      * @param elem The parent element
30      */
31     void setParent(IOWLElement elem);
32  
33     /***
34      * Returns the path to the innermost resource enclosing this element.
35      * This is the full path relative to the workbench
36      * @return the path to the innermost enclosing resource
37      */
38     IPath getPath();
39  
40     /***
41      * Returns the innermost enclosing resource of this element.
42      * This may be a resource that corresponds directly to this element.
43      * @return the innermost enclosing resource of this element
44      */
45     IResource getResource();
46  
47     /***
48      * Returns the resource that corresponds to this element.
49      * Not all OWL elements have a corresponding resource.
50      * @return the corresponding resource or <code>null</code> if none exists.
51      */
52     IResource getCorrespondingResource();
53  
54     /***
55      * Returns the name of this element.
56      * @return the element name
57      */
58     String getElementName();
59  
60     /***
61      * Indicates whether the OWL element is read-only.
62      * @return <code>true</code> if this element is read-only
63      */
64     boolean isReadOnly();
65  
66     /***
67      * Returns the URI of the OWL element, or null if it has no URI.
68      * @return the full URI of the element or <code>null</code>
69      *         to indicate no URI
70      */
71     String getURI();
72  
73     /***
74      * Returns a file: URI indicating the resource's location on the filesystem.
75      * @return String of the local URI
76      */
77     String getLocalURI();
78  
79     /***
80      * Checks if this element or one of its decendents is based on a particular
81      * Eclipse resource.
82      * @param resource The resource to attempt to locate
83      * @return <code>true</code> if the specified IResource corresponds to
84      *         an OWL element descended from this one
85      */
86     boolean contains(IResource resource);
87  
88     /***
89      * Returns the OWLElementInfo for an OWL resource, creating it first if this
90      * is the first time it has been requested.
91      * @return an OWLElementInfo instance with detailed information about the
92      *         element
93      */
94     OWLElementInfo getElementInfo();
95  
96     /***
97      * Locates the OWL Element corresponding to a particular Eclipse resource.
98      * @param resource An Eclipse resource to locate in the OWL model
99      * @return The OWL Element that corresponds directly to resource, or
100     *         <code>null</code> if there is no such element
101     */
102    IOWLElement getCorrespondingElement(IResource resource);
103 
104    /***
105     * Accepts the given visitor.  The visitor's <code>visit</code> method is
106     * called with this element.  If the visitor returns true, this method
107     * will also visit the element's children.
108     * @param visitor The visitor
109     */
110    void accept(IOWLElementVisitor visitor);
111 }