1 2 12 package com.versant.core.metadata.parser; 13 14 import com.versant.core.metadata.MDStatics; 15 16 import java.io.Serializable ; 17 import java.util.ArrayList ; 18 19 22 public abstract class JdoElement implements Serializable , MDStatics { 23 24 public abstract JdoElement getParent(); 25 26 30 public String getContext() { 31 ArrayList a = new ArrayList (); 32 for (JdoElement e = this; e != null; e = e.getParent()) a.add(e); 33 StringBuffer s = new StringBuffer (); 34 boolean first = true; 35 for (int i = a.size() - 1; i >= 0; i--) { 36 if (first) { 37 first = false; 38 s.append("--> "); 39 } else s.append('/'); 40 s.append(((JdoElement)a.get(i)).getSubContext()); 41 } 42 return s.toString(); 43 } 44 45 50 public abstract String getSubContext(); 51 52 public JdoExtension[] addExtension(JdoExtension[] exts, JdoExtension e) { 53 JdoExtension[] tmp = new JdoExtension[exts.length + 1]; 54 System.arraycopy(exts, 0, tmp, 0, exts.length); 55 tmp[exts.length] = e; 56 return tmp; 57 } 58 59 public JdoExtension createChild(int key, String value, JdoElement parent) { 60 JdoExtension e = new JdoExtension(); 61 e.key = key; 62 e.value = value; 63 e.parent = parent; 64 return e; 65 } 66 67 } 68 69 | Popular Tags |