1 28 29 package org.jibx.binding.def; 30 31 import org.jibx.binding.classes.*; 32 import org.jibx.runtime.JiBXException; 33 34 40 41 public class MappingDirect extends MappingBase 42 { 43 44 private final DirectObject m_mappingImpl; 45 46 47 private final BoundClass m_boundClass; 48 49 50 private boolean m_isGenerated; 51 52 60 61 public MappingDirect(IContainer contain, String type, DirectObject dir) 62 throws JiBXException { 63 super(contain, type, dir); 64 m_mappingImpl = dir; 65 m_boundClass = BoundClass.getInstance(type, null); 66 } 67 68 74 75 public BoundClass getBoundClass() { 76 return m_boundClass; 77 } 78 79 82 public String getBoundType() { 83 return m_mappingImpl.getTargetClass().getName(); 84 } 85 86 public IComponent getImplComponent() { 87 return m_component; 88 } 89 90 public ClassFile getMarshaller() throws JiBXException { 91 return m_mappingImpl.getMarshaller(); 92 } 93 94 public ClassFile getUnmarshaller() throws JiBXException { 95 return m_mappingImpl.getUnmarshaller(); 96 } 97 98 public NameDefinition getName() { 99 return m_mappingImpl.getName(); 100 } 101 102 public void addNamespace(NamespaceDefinition ns) { 103 throw new IllegalStateException 104 ("Internal error: no namespace definition possible"); 105 } 106 107 public boolean isAbstract() { 108 return false; 109 } 110 111 public void addExtension(MappingDefinition mdef) { 112 throw new IllegalStateException 113 ("Internal error: no extension possible"); 114 } 115 116 public IComponent buildRef(IContainer parent, IContextObj objc, String type, 117 PropertyDefinition prop) throws JiBXException { 118 return new DirectProperty(prop, m_mappingImpl); 119 } 120 121 public void generateCode() throws JiBXException { 122 if (!m_isGenerated) { 123 if (m_boundClass.isDirectAccess()) { 124 addIMarshallableMethod(); 125 addIUnmarshallableMethod(); 126 } 127 m_isGenerated = true; 128 } 129 } 130 131 public void setLinkages() throws JiBXException { 132 m_mappingImpl.setLinkages(); 133 } 134 135 public void print(int depth) { 137 BindingDefinition.indent(depth); 138 System.out.println("mapping direct " + 139 m_mappingImpl.getTargetClass().getName()); 140 } 141 } | Popular Tags |