1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jdo.model.java;
19
20 import java.io.InputStream;
21
22 import org.apache.jdo.model.ModelException;
23 import org.apache.jdo.model.jdo.JDOModel;
24
25
26 /***
27 * A JavaModel instance bundles a number of JavaType instances and provides
28 * methods to retrieve JavaType instance by their name. A type name must be
29 * unique must be unique within a JavaModel instance. If the JavaType
30 * represents a class or an interface its type name is the fully qualified
31 * name. The model supports multiple classes or interfaces having the same
32 * fully qualified name by different JavaModel instances.
33 *
34 * @author Michael Bouschen
35 * @since JDO 1.0.1
36 */
37 public interface JavaModel
38 {
39 /***
40 * The method returns the JavaType instance for the specified type
41 * name. A type name is unique within one JavaModel instance. The
42 * method returns <code>null</code> if this model instance does not
43 * know a type with the specified name.
44 * @param name the name of the type
45 * @return a JavaType instance for the specified name or
46 * <code>null</code> if not present in this model instance.
47 */
48 public JavaType getJavaType(String name);
49
50 /***
51 * The method returns the JavaType instance for the type name of the
52 * specified class object. This is a convenience method for
53 * <code>getJavaType(clazz.getName())</code>. The major difference
54 * between this method and getJavaType taking a type name is that this
55 * method is supposed to return a non-<code>null<code> value. The
56 * specified class object describes an existing type.
57 * @param clazz the Class instance representing the type
58 * @return a JavaType instance for the name of the specified class
59 * object.
60 */
61 public JavaType getJavaType(Class clazz);
62
63 /***
64 * Finds a resource with a given name. A resource is some data that can
65 * be accessed by class code in a way that is independent of the
66 * location of the code. The name of a resource is a "/"-separated path
67 * name that identifies the resource. The method method opens the
68 * resource for reading and returns an InputStream. It returns
69 * <code>null</code> if no resource with this name is found or if the
70 * caller doesn't have adequate privileges to get the resource.
71 * @param resourceName the resource name
72 * @return an input stream for reading the resource, or <code>null</code>
73 * if the resource could not be found or if the caller doesn't have
74 * adequate privileges to get the resource.
75 */
76 public InputStream getInputStreamForResource(String resourceName);
77
78 /***
79 * Returns the parent JavaModel instance of this JavaModel.
80 * @return the parent JavaModel
81 */
82 public JavaModel getParent();
83
84 /***
85 * Set the parent JavaModel for this JavaModel. The method
86 * automatically adds this JavaModel to the collection of children
87 * of the specified parent JavaModel.
88 * @param parent the parent JavaModel
89 * @exception ModelException if impossible
90 */
91 public void setParent(JavaModel parent)
92 throws ModelException;
93
94 /***
95 * Returns a collection of child JavaModel instances in the form
96 * of an array. All instances from the returned array have this
97 * JavaModel instance as parent.
98 * @return the child JavaModel instances
99 */
100 public JavaModel[] getChildren();
101
102 /***
103 * Returns the corresponding JDOModel instance.
104 * @return the corresponding JDOModel.
105 */
106 public JDOModel getJDOModel();
107
108 /***
109 * Sets the corresponding JDOModel instance.
110 * @param jdoModel the JDOModel instance
111 * @exception ModelException if impossible
112 */
113 public void setJDOModel(JDOModel jdoModel)
114 throws ModelException;
115
116 }