KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > ejb > query > NavField


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.ejb.query;
13
14 import com.versant.core.metadata.FieldMetaData;
15 import com.versant.core.metadata.ClassMetaData;
16
17 /**
18  * Navigation through a field.
19  */

20 public class NavField extends NavBase {
21
22     private FieldMetaData fmd; // the field being navigated
23
private boolean outer; // navigate with outer join semantics
24
private boolean fetch; // is this navigation for a fetch?
25

26     private NavBase parent; // our parent
27
private NavField next; // our next sibling
28

29     /**
30      * This will append us to our parents list of children.
31      */

32     public NavField(FieldMetaData fmd, NavBase parent, boolean outer,
33             boolean fetch) {
34         this.fmd = fmd;
35         this.outer = outer;
36         this.fetch = fetch;
37         setParent(parent);
38     }
39
40     /**
41      * Remove us from our current parent (if any) and add us to np.
42      */

43     public void setParent(NavBase np) {
44         if (parent == np) {
45             return;
46         }
47         if (parent != null) {
48             NavField p = null;
49             for (NavField i = parent.children; i != this; i = i.next);
50             if (p == null) {
51                 parent.children = next;
52             } else {
53                 p.next = next;
54             }
55             next = null;
56         }
57         parent = np;
58         if (parent != null) {
59             if (parent.children == null) {
60                 parent.children = this;
61             } else {
62                 NavField i;
63                 for (i = parent.children; i.next != null; i = i.next);
64                 i.next = this;
65             }
66         }
67     }
68
69     /**
70      * Get the field being navigated.
71      */

72     public FieldMetaData getFmd() {
73         return fmd;
74     }
75
76     public NavRoot getRoot() {
77         return parent == null ? null : parent.getRoot();
78     }
79
80     public NavBase getParent() {
81         return parent;
82     }
83
84     public NavField getNext() {
85         return next;
86     }
87
88     public boolean isOuter() {
89         return outer;
90     }
91
92     public boolean isFetch() {
93         return fetch;
94     }
95
96     public ClassMetaData getNavClassMetaData() {
97         return fmd.getRefOrValueClassMetaData();
98     }
99
100     public String JavaDoc toString() {
101         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
102         s.append(fmd.name);
103         childrenToString(s);
104         return s.toString();
105     }
106
107 }
108
109
Popular Tags