KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > metadata > FetchGroupField


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.metadata;
13
14 import com.versant.core.metadata.parser.JdoExtension;
15 import com.versant.core.common.Debug;
16
17 import java.io.Serializable JavaDoc;
18 import java.io.PrintStream JavaDoc;
19
20 /**
21  * A field in a fetch group. This holds the field and assorted store
22  * specific options.
23  */

24 public class FetchGroupField implements Serializable JavaDoc {
25
26     /**
27      * The field.
28      */

29     public FieldMetaData fmd;
30     /**
31      * The parsed meta data for this field (null if none i.e. automatically
32      * generated default fetch group).
33      */

34     public JdoExtension extension;
35     /**
36      * If a store does read ahead (e.g. a JDBC store using a join) and this
37      * field is a reference to another PC class then get the fields in this
38      * fetch group of that class. This will never be null as it is set to
39      * the default fetch group if not specified.
40      */

41     public FetchGroup nextFetchGroup;
42     /**
43      * If a store does read ahead (e.g. a JDBC store using a join) and this
44      * field is a map and the keys reference another PC class then get the
45      * fields in this fetch group of that class. This will never be null as
46      * it is set to the default fetch group if not specified.
47      */

48     public FetchGroup nextKeyFetchGroup;
49
50     /**
51      * This flag is used to include reference fields in a fetch group
52      * and to fetch only the OID of the reference and not the referenced
53      * object as well.
54      */

55     public boolean doNotFetchObject;
56
57     /**
58      * If this is a ref or a collection then this is the useJoin option
59      * to use when this group is fetched. The fields picked up by the join
60      * will be those in the nextFetchGroup of the referenced class.
61      * Values are from JdbcField: USE_JOIN_NO USE_JOIN_INNER USE_JOIN_OUTER.
62      * @see #nextFetchGroup
63      */

64     public int jdbcUseJoin;
65     /**
66      * If this is a map and the keys are a PC class then this is the useJoin
67      * option to use when this group is fetched. The fields picked up by the
68      * join will be those in the nextKeyFetchGroup of the referenced class.
69      * Values are from JdbcField: USE_JOIN_NO USE_JOIN_INNER USE_JOIN_OUTER.
70      * @see #nextKeyFetchGroup
71      */

72     public int jdbcUseKeyJoin;
73     /**
74      * Cache for SQL required to fetch this field. This is normally only
75      * used for pass 2 fields e.g. collections and so on.
76      */

77     public String JavaDoc jdbcSelectSql;
78     /**
79      * Cache for SQL required to fetch this field when selectForUpdate is on.
80      * This is normally only used for pass 2 fields e.g. collections and so on.
81      */

82     public String JavaDoc jdbcSelectSqlForUpdate;
83
84     public FetchGroupField(FieldMetaData field) {
85         this.fmd = field;
86     }
87
88     private static String JavaDoc toUseJoinString(int useJoin) {
89         // dont use constants from JdbcRefField to avoid engine depending
90
// on jdbc
91
switch (useJoin) {
92             case 1:
93                 return "NO";
94             case 3:
95                 return "INNER";
96             case 2:
97                 return "OUTER";
98         }
99         return "unknown(" + useJoin + ")";
100     }
101
102     public String JavaDoc toString() {
103         return String.valueOf(fmd) +
104             " jdbcUseJoin " + toUseJoinString(jdbcUseJoin) +
105             " nextFetchGroup " + nextFetchGroup +
106             (fmd.category == MDStatics.CATEGORY_MAP
107                 ? " jdbcUseKeyJoin " + toUseJoinString(jdbcUseKeyJoin) +
108                   " nextKeyFetchGroup " + nextKeyFetchGroup
109                 : "");
110     }
111
112     public void dump() {
113         dump(Debug.OUT, "");
114     }
115
116     public void dump(PrintStream JavaDoc out, String JavaDoc indent) {
117         out.println(indent + this);
118     }
119 }
120
Popular Tags