01: package org.apache.ojb.jdo.jdoql;
02:
03: /* Copyright 2003-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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: /** The import spec, either a fully qualified class name or a qualified package name */
25: private String _spec;
26: /** Whether this import is direct (class) or on-demand (package) */
27: private boolean _isOnDemand;
28: /** If an direct import, this is the resolved class */
29: private Class _importedClass;
30:
31: /**
32: * Creates a new import object.
33: *
34: * @param spec The import spec
35: * @param isOnDemand Whether the import is on-demand or direct
36: */
37: public Import(String spec, boolean isOnDemand) {
38: _spec = spec;
39: _isOnDemand = isOnDemand;
40: }
41:
42: /**
43: * Returns whether this import is direct (class) or on-demand (package).
44: *
45: * @return <code>true</code> if this import is on-demand
46: */
47: public boolean isOnDemand() {
48: return _isOnDemand;
49: }
50:
51: /**
52: * Returns the import spec which is either a fully qualified class name or
53: * a package.
54: *
55: * @return The spec
56: */
57: public String getSpec() {
58: return _spec;
59: }
60:
61: /* (non-Javadoc)
62: * @see org.apache.ojb.jdo.jdoql.Acceptor#accept(org.apache.ojb.jdo.jdoql.Visitor)
63: */
64: public void accept(Visitor visitor) {
65: visitor.visit(this );
66: }
67:
68: /* (non-Javadoc)
69: * @see java.lang.Object#toString()
70: */
71: public String toString() {
72: return _isOnDemand ? _spec + ".*" : _spec;
73: }
74: }
|