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