KickJava   Java API By Example, From Geeks To Geeks.

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


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.ClassMetaData;
15 import com.versant.core.common.CmdBitSet;
16
17 /**
18  * Base class for Nav and NavRoot holding the children list and associated
19  * methods.
20  */

21 public abstract class NavBase {
22
23     /**
24      * Fields navigated from us.
25      */

26     protected NavField children;
27
28     /**
29      * Store specific info attached to us.
30      */

31     public Object JavaDoc storeObject;
32
33     public NavBase() {
34     }
35
36     /**
37      * Field the child with name and matching outer and fetch or null if none.
38      */

39     public NavField findChild(String JavaDoc name, boolean outer, boolean fetch) {
40         NavField i;
41         for (i = children; i != null; i = i.getNext()) {
42             if (i.getFmd().name.equals(name) && i.isOuter() == outer
43                     && i.isFetch() == fetch) {
44                 return i;
45             }
46         }
47         return null;
48     }
49
50     /**
51      * Get our root.
52      */

53     public abstract NavRoot getRoot();
54
55     /**
56      * Get the meta data used to resolve navigation from us in paths.
57      */

58     public abstract ClassMetaData getNavClassMetaData();
59
60     /**
61      * Convert our children into a nice String.
62      */

63     protected void childrenToString(StringBuffer JavaDoc s) {
64         if (children != null) {
65             if (children.getNext() == null) {
66                 s.append(" -> ");
67                 s.append(children);
68             } else {
69                 for (NavField f = children; f != null; f = f.getNext()) {
70                     s.append(" [ -> ");
71                     s.append(children);
72                     s.append("] ");
73                 }
74             }
75         }
76     }
77
78     /**
79      * Add all classes referenced by this node and its children recursivley
80      * to bits. This is used to figure out class dependencies for flushing
81      * and eviction.
82      */

83     public void addInvolvedClasses(CmdBitSet bits) {
84         bits.addPlus(getNavClassMetaData());
85         for (NavField i = children; i != null; i = i.getNext()) {
86             i.addInvolvedClasses(bits);
87         }
88     }
89
90     public NavField getChildren() {
91         return children;
92     }
93
94 }
95
96
Popular Tags