1 22 package org.jboss.xb.binding.group; 23 24 import java.util.Map ; 25 import java.util.Collections ; 26 import java.util.List ; 27 import java.util.ArrayList ; 28 import javax.xml.namespace.QName ; 29 import org.jboss.xb.binding.JBossXBRuntimeException; 30 import org.jboss.xb.binding.sunday.unmarshalling.AttributeBinding; 31 import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding; 32 import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding; 33 import org.jboss.xb.binding.sunday.unmarshalling.CharactersHandler; 34 35 39 public class ValueListInitializer 40 { 41 private int initializedState; 42 private Map attrIndex = Collections.EMPTY_MAP; 43 private Map elemIndex = Collections.EMPTY_MAP; 44 private List requiredBindings = Collections.EMPTY_LIST; 45 46 public void addRequiredAttribute(QName qName, AttributeBinding binding) 47 { 48 63 throw new UnsupportedOperationException (); 64 } 65 66 public void addRequiredElement(QName qName, ElementBinding binding) 67 { 68 83 throw new UnsupportedOperationException (); 84 } 85 86 public ValueList newValueList(ValueListHandler handler, Class targetClass) 87 { 88 return new ValueList(this, handler, targetClass); 89 } 90 91 public void addAttributeValue(QName qName, AttributeBinding binding, ValueList valueList, Object value) 92 { 93 Integer index = (Integer )attrIndex.get(qName); 94 if(index == null) 95 { 96 valueList.setAttributeValue(qName, binding, value); 97 } 98 else 99 { 100 if(isInitialized(valueList)) 101 { 102 throw new JBossXBRuntimeException("The value list has already been initialized!"); 103 } 104 valueList.setRequiredValue(index.intValue(), qName.hashCode(), value); 105 } 106 } 107 108 public void addTextValue(QName qName, 109 ParticleBinding particle, 110 CharactersHandler handler, 111 ValueList valueList, 112 Object value) 113 { 114 valueList.addTextValue(qName, particle, handler, value); 115 } 116 117 public void addTermValue(QName qName, ParticleBinding binding, Object handler, ValueList valueList, Object value, ParticleBinding parentParticle) 118 { 119 Integer index = (Integer )elemIndex.get(qName); 120 if(index == null) 121 { 122 if(binding.isRepeatable()) 123 { 124 valueList.addRepeatableTermValue(qName, binding, handler, value, parentParticle); 125 } 126 else 127 { 128 valueList.addTermValue(qName, binding, handler, value, parentParticle); 129 } 130 } 131 else 132 { 133 if(isInitialized(valueList)) 134 { 135 throw new JBossXBRuntimeException("The value list has already been initialized!"); 136 } 137 valueList.setRequiredValue(index.intValue(), qName.hashCode(), value); 138 } 139 } 140 141 public boolean isInitialized(ValueList valueList) 142 { 143 throw new UnsupportedOperationException (); 145 } 146 147 public Object getAttributeValue(QName qName, ValueList valueList) 148 { 149 162 throw new UnsupportedOperationException (); 163 } 164 165 public Object getElementValue(QName qName, ValueList valueList) 166 { 167 180 throw new UnsupportedOperationException (); 181 } 182 183 public List getRequiredBindings() 184 { 185 throw new UnsupportedOperationException (); 187 } 188 189 191 private void addBinding(Object binding) 192 { 193 if(requiredBindings == Collections.EMPTY_LIST) 194 { 195 requiredBindings = new ArrayList (); 196 } 197 requiredBindings.add(binding); 198 } 199 } 200 | Popular Tags |