1 28 29 package org.jibx.binding.model; 30 31 import java.util.ArrayList ; 32 import java.util.Iterator ; 33 34 import org.jibx.binding.util.StringArray; 35 36 44 45 public abstract class TemplateElementBase extends ContainerElementBase 46 { 47 48 public static final StringArray s_allowedAttributes = 49 new StringArray(new String [] { "class" }, 50 ContainerElementBase.s_allowedAttributes); 51 52 53 private String m_className; 54 55 56 private IClass m_handledClass; 57 58 59 protected ArrayList m_children; 60 61 63 private ArrayList m_extensionTypes; 65 66 71 public TemplateElementBase(int type) { 72 super(type); 73 m_extensionTypes = new ArrayList (); 74 } 75 76 81 public void setClassName(String name) { 82 m_className = name; 83 } 84 85 90 public String getClassName() { 91 return m_className; 92 } 93 94 100 public IClass getHandledClass() { 101 return m_handledClass; 102 } 103 104 109 protected void addExtensionType(TemplateElementBase ext) { 110 m_extensionTypes.add(ext); 111 } 112 113 118 public ArrayList getExtensionTypes() { 119 return m_extensionTypes; 120 } 121 122 128 public abstract boolean isDefaultTemplate(); 129 130 136 public void addTopChild(Object child) { 137 m_children.add(child); 138 } 139 140 145 public ArrayList topChildren() { 146 return m_children; 147 } 148 149 154 public Iterator topChildIterator() { 155 return m_children.iterator(); 156 } 157 158 161 164 public boolean isOptional() { 165 throw new IllegalStateException 166 ("Internal error: method should never be called"); 167 } 168 169 172 public IClass getEffectiveType() { 173 return m_handledClass; 174 } 175 176 179 public IClass getActualType() { 180 return m_handledClass; 181 } 182 183 186 189 public void prevalidate(ValidationContext vctx) { 190 if (m_className == null) { 191 vctx.addFatal("Class name is required"); 192 } else { 193 m_handledClass = vctx.getClassInfo(m_className); 194 if (m_handledClass == null) { 195 vctx.addFatal("Cannot find information for class " + 196 m_className); 197 } else { 198 super.prevalidate(vctx); 199 } 200 } 201 } 202 } | Popular Tags |