KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > jdo > jdoql > Import


1 package org.apache.ojb.jdo.jdoql;
2
3 /* Copyright 2003-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /**
19  * Represents a direct or on-demand import within a JDOQL query.
20  *
21  * @author <a HREF="mailto:tomdz@apache.org">Thomas Dudziak</a>
22  */

23 public class Import extends QueryTreeNode
24 {
25     /** The import spec, either a fully qualified class name or a qualified package name */
26     private String JavaDoc _spec;
27     /** Whether this import is direct (class) or on-demand (package) */
28     private boolean _isOnDemand;
29     /** If an direct import, this is the resolved class */
30     private Class JavaDoc _importedClass;
31
32     /**
33      * Creates a new import object.
34      *
35      * @param spec The import spec
36      * @param isOnDemand Whether the import is on-demand or direct
37      */

38     public Import(String JavaDoc spec, boolean isOnDemand)
39     {
40         _spec = spec;
41         _isOnDemand = isOnDemand;
42     }
43
44     /**
45      * Returns whether this import is direct (class) or on-demand (package).
46      *
47      * @return <code>true</code> if this import is on-demand
48      */

49     public boolean isOnDemand()
50     {
51         return _isOnDemand;
52     }
53
54     /**
55      * Returns the import spec which is either a fully qualified class name or
56      * a package.
57      *
58      * @return The spec
59      */

60     public String JavaDoc getSpec()
61     {
62         return _spec;
63     }
64
65     /* (non-Javadoc)
66      * @see org.apache.ojb.jdo.jdoql.Acceptor#accept(org.apache.ojb.jdo.jdoql.Visitor)
67      */

68     public void accept(Visitor visitor)
69     {
70         visitor.visit(this);
71     }
72
73     /* (non-Javadoc)
74      * @see java.lang.Object#toString()
75      */

76     public String JavaDoc toString()
77     {
78         return _isOnDemand ? _spec + ".*" : _spec;
79     }
80 }
81
Popular Tags