1 2 12 package com.versant.core.metadata.parser; 13 14 import com.versant.core.metadata.MDStatics; 15 import com.versant.core.metadata.MDStaticUtils; 16 import com.versant.core.common.Debug; 17 18 import java.io.PrintStream ; 19 import java.util.ArrayList ; 20 import java.util.Iterator ; 21 import java.util.Map ; 22 23 26 public final class JdoClass extends JdoElement implements MDStatics { 27 28 public String name; 29 public int identityType; 30 public String objectIdClass; 31 public boolean requiresExtent; 32 public String pcSuperclass; 33 public JdoPackage parent; 34 35 36 public JdoElement[] elements; 37 38 39 public ArrayList queries; 40 43 public boolean objectIdClasssRequired = true; 44 45 public JdoElement getParent() { return parent; } 46 47 52 public String getSubContext() { 53 return "class[" + name + "]"; 54 } 55 56 public String toString() { 57 StringBuffer s = new StringBuffer (); 58 s.append("class["); 59 s.append(name); 60 s.append("] identityType="); 61 s.append(MDStaticUtils.toIdentityTypeString(identityType)); 62 s.append(" objectIdClass="); 63 s.append(objectIdClass); 64 s.append(" requiresExtent="); 65 s.append(requiresExtent); 66 s.append(" pcSuperclass="); 67 s.append(pcSuperclass); 68 return s.toString(); 69 } 70 71 public void dump() { 72 dump(Debug.OUT, ""); 73 } 74 75 public void dump(PrintStream out, String indent) { 76 out.println(indent + this); 77 if (elements != null) { 78 for (int i = 0; i < elements.length; i++) { 79 Object o = elements[i]; 80 if (o instanceof JdoField) { 81 ((JdoField)o).dump(out, indent + " "); 82 } else if (o instanceof JdoExtension) { 83 ((JdoExtension)o).dump(out, indent + " "); 84 } else if (o instanceof JdoQuery) { 85 ((JdoQuery) o).dump(out, indent + " "); 86 } else { 87 out.println("unknown " + o); 88 } 89 } 90 } 91 if (queries != null) { 92 for (Iterator i = queries.iterator(); i.hasNext(); ) { 93 ((JdoQuery)i.next()).dump(out, indent + " "); 94 } 95 } 96 } 97 98 101 public String getQName() { 102 return getQName(name); 103 } 104 105 private String getQName(String n) { 106 if (n == null) return null; 107 int i = n.indexOf('.'); 108 if (i >= 0 || parent.name.length() == 0) return n; 109 return parent.name + '.' + n; 110 } 111 112 115 public String getPCSuperClassQName() { 116 return getQName(pcSuperclass); 117 } 118 119 122 public String getObjectIdClassQName() { 123 return getQName(objectIdClass); 124 } 125 126 129 public boolean hasKeyGen(){ 130 if (elements != null) { 131 JdoExtension ext = null; 132 for (int i = 0; i < elements.length; i++) { 133 Object o = elements[i]; 134 if (o instanceof JdoExtension) { 135 ext = (JdoExtension)o; 136 if (ext.key == JdoExtension.JDBC_KEY_GENERATOR) { 137 return true; 138 } else if (ext.contains(JdoExtension.JDBC_KEY_GENERATOR)){ 139 return true; 140 } 141 142 } 143 } 144 } 145 return false; 146 } 147 148 154 public void addJdoQuery(JdoQuery q) { 155 if (queries == null) queries = new ArrayList (); 160 queries.add(q); 161 } 162 163 public int getInheritance(Map enumMap) { 164 if (elements != null) { 165 JdoExtension ext = null; 166 for (int i = 0; i < elements.length; i++) { 167 Object o = elements[i]; 168 if (o instanceof JdoExtension) { 169 ext = (JdoExtension)o; 170 if (ext.key == JdoExtension.JDBC_INHERITANCE) { 171 if (ext.value == null) return -1; 172 return ext.getEnum(enumMap); 173 } 174 } 175 } 176 } 177 return -1; 178 } 179 180 public void addElement(JdoElement jdoElement) { 181 if (elements == null) { 182 elements = new JdoElement[] {jdoElement,}; 183 } else { 184 JdoElement[] tmp = new JdoElement[elements.length + 1]; 185 System.arraycopy(elements, 0, tmp, 0, elements.length); 186 tmp[elements.length] = jdoElement; 187 elements = tmp; 188 } 189 190 } 191 } 192 | Popular Tags |