1 25 package org.objectweb.speedo.metadata; 26 27 import java.util.Map ; 28 import java.util.HashMap ; 29 import java.util.Iterator ; 30 import java.util.Set ; 31 import java.util.HashSet ; 32 33 34 37 public class SpeedoFetchGroup extends SpeedoElement { 38 39 public static final String FG_AT = "@"; 40 public static final String FG_SHARP = "#"; 41 public static final String FG_DOT = "."; 42 public static final String FG_KEY = "#key"; 43 public static final String FG_VALUE = "#value"; 44 public static final String FG_ELEMENT = "#element"; 45 public static final String FG_SLASH = "/"; 46 47 public static final byte NOTHING_DEFINED = 0; 48 public static final byte DEPTH_DEFINED = 1; 49 public static final byte FG_DEFINED = 2; 50 51 54 public String name; 55 56 59 protected Map jdoFetchGroups = new HashMap (); 60 61 64 protected Map jdoFields = new HashMap (); 65 66 71 public int depth = 0; 72 73 79 public boolean postLoad; 80 81 84 public int getDepth(){ 85 return depth; 86 } 87 88 91 public String getName(){ 92 return name; 93 } 94 95 98 public boolean getPostLoad() { 99 return postLoad; 100 } 101 102 105 public Map getFields(){ 106 return jdoFields; 107 } 108 109 112 public Map getNestedFetchGroups() { 113 return jdoFetchGroups; 114 } 115 116 120 public void addFetchGroup(Object fetchGroup) { 121 SpeedoFetchGroup speedoFetchGroup = (SpeedoFetchGroup) fetchGroup; 122 jdoFetchGroups.put(speedoFetchGroup.name, speedoFetchGroup); 123 } 124 125 129 public void addField(Object field) { 130 SpeedoField speedoField = (SpeedoField) field; 131 jdoFields.put(speedoField.name, speedoField); 132 } 133 134 137 public Set getFieldsToLoad(){ 138 Set fieldsToLoad = new HashSet (); 139 fieldsToLoad.addAll(jdoFields.keySet()); 141 Set fg = jdoFetchGroups.entrySet(); 143 Iterator it = fg.iterator(); 144 while(it.hasNext()){ 145 SpeedoFetchGroup sfg = (SpeedoFetchGroup) it.next(); 146 fieldsToLoad.addAll(sfg.jdoFields.keySet()); 147 } 148 return fieldsToLoad; 149 } 150 151 public String toString(){ 152 String s = "\n fetchgroup name: " + name + 153 ", postload: " + postLoad + 154 ", depth: " + depth; 155 s += ", \t fields:["; 156 Iterator it = jdoFields.values().iterator(); 157 while (it.hasNext()) { 158 s = s + "\t" + it.next().toString(); 159 } 160 s += "], \t nestedFetchGroups:["; 161 Iterator it2 = jdoFetchGroups.values().iterator(); 162 while (it2.hasNext()) { 163 s += "\t" + it2.next().toString(); 164 } 165 s += "]"; 166 return s; 167 } 168 } 169 | Popular Tags |