1 28 29 package org.jibx.binding.def; 30 31 32 import org.jibx.binding.classes.*; 33 import org.jibx.runtime.JiBXException; 34 35 44 45 public class OptionalStructureWrapper extends PassThroughComponent 46 { 47 private static final String MARSHALCONTEXT_CLASS = 48 "org.jibx.runtime.impl.MarshallingContext"; 49 50 51 private final PropertyDefinition m_property; 52 53 54 private final boolean m_loadMarshal; 55 56 62 63 public OptionalStructureWrapper(IComponent wrap, PropertyDefinition prop, 64 boolean load) { 65 super(wrap); 66 m_property = prop; 67 m_loadMarshal = load; 68 } 69 70 73 public void genAttributeMarshal(ContextMethodBuilder mb) 74 throws JiBXException { 75 mb.loadObject(); 76 BranchWrapper ifmiss = m_property.genTest(mb); 77 super.genAttributeMarshal(mb); 78 mb.targetNext(ifmiss); 79 } 80 81 public void genContentMarshal(ContextMethodBuilder mb) 82 throws JiBXException { 83 mb.loadObject(); 84 BranchWrapper ifmiss = m_property.genTest(mb); 85 if (m_loadMarshal) { 86 mb.loadObject(); 87 m_property.genLoad(mb); 88 } 89 super.genContentMarshal(mb); 90 mb.targetNext(ifmiss); 91 } 92 93 public void print(int depth) { 95 BindingDefinition.indent(depth); 96 System.out.print("optional structure wrapper " + m_property.toString()); 97 if (m_loadMarshal) { 98 System.out.print(" (load marshal)"); 99 } 100 System.out.println(); 101 m_component.print(depth+1); 102 } 103 } | Popular Tags |