001: /*
002: * Copyright (c) 1998 - 2005 Versant Corporation
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * Versant Corporation - initial API and implementation
010: */
011: package com.versant.core.metadata.parser;
012:
013: import com.versant.core.common.Debug;
014:
015: import java.io.PrintStream;
016:
017: /**
018: * A named query in the meta data.
019: */
020: public final class JdoQuery extends JdoElement {
021:
022: // query
023: public String name;
024: public String language;
025: public int ignoreCache;
026: public int includeSubclasses;
027: public String ordering;
028: public int rangeStart;
029: public int rangeEnd;
030:
031: // filter
032: public String filter;
033:
034: // sql
035: public String sql;
036:
037: // declare
038: public String imports;
039: public String parameters;
040: public String variables;
041:
042: // result
043: public String result;
044: public String resultClass;
045: public String grouping;
046: public int unique;
047:
048: public JdoExtension[] extensions;
049:
050: public JdoClass parent;
051:
052: public JdoElement getParent() {
053: return parent;
054: }
055:
056: /**
057: * Get the fully qualified name of the candidate class for the query.
058: */
059: public String getCandidateClass() {
060: return parent.parent.name + "." + parent.name;
061: }
062:
063: /**
064: * Get information for this element to be used in building up a
065: * context string.
066: *
067: * @see #getContext
068: */
069: public String getSubContext() {
070: return "query[" + name + "]";
071: }
072:
073: public String toString() {
074: StringBuffer s = new StringBuffer();
075: s.append("query[");
076: s.append(name);
077: s.append("] language=");
078: s.append(language);
079: s.append(" ignore-cache=");
080: s.append(ignoreCache);
081: s.append(" include-subclasses=");
082: s.append(includeSubclasses);
083: s.append("\nfilter[");
084: s.append(filter);
085: s.append("]");
086: s.append("\ndeclarations imports=");
087: s.append(imports);
088: s.append(" parameters=");
089: s.append(parameters);
090: s.append(" variables=");
091: s.append(variables);
092: s.append(" ordering=");
093: s.append(ordering);
094: s.append("\nresult class=");
095: s.append(resultClass);
096: s.append(" grouping=");
097: s.append(grouping);
098: s.append(" unique=");
099: s.append(unique);
100:
101: return s.toString();
102: }
103:
104: public void dump() {
105: dump(Debug.OUT, "");
106: }
107:
108: public void dump(PrintStream out, String indent) {
109: out.println(indent + this );
110: String is = indent + " ";
111: if (extensions != null) {
112: for (int i = 0; i < extensions.length; i++) {
113: extensions[i].dump(out, is);
114: }
115: }
116: }
117: }
|