public Loader getLoader(JAXBContextImpl context, boolean typeSubstitutionCapable) { if(loader==null) { // this has to be done lazily to avoid cyclic reference issue UnmarshallerChain c = new UnmarshallerChain(context); QNameMap<ChildLoader> result = new QNameMap<ChildLoader>(); property.buildChildElementUnmarshallers(c,result); if(result.size()==1) // for ElementBeanInfoImpl created from RuntimeElementInfo this.loader = new IntercepterLoader(result.getOne().getValue().loader); else // for special ElementBeanInfoImpl only used for marshalling this.loader = Discarder.INSTANCE; } return loader; }
/** * Associates the specified value with the specified keys in this map. * If the map previously contained a mapping for this key, the old * value is replaced. * * @param namespaceUri First key with which the specified value is to be associated. * @param localname Second key with which the specified value is to be associated. * @param value value to be associated with the specified key. * */ public void put(String namespaceUri,String localname, V value ) { //keys cannot be null assert localname !=null; assert namespaceUri !=null; // keys must be interned assert localname == localname.intern(); assert namespaceUri == namespaceUri.intern(); int hash = hash(localname); int i = indexFor(hash, table.length); for (Entry<V> e = table[i]; e != null; e = e.next) { if (e.hash == hash && localname == e.localName && namespaceUri==e.nsUri) { e.value = value; return; } } addEntry(hash, namespaceUri,localname, value, i); }
@Override public Accessor getElementPropertyAccessor(String nsUri, String localName) { // TODO: unwrap JAXBElement if(wrapperTagName!=null) { if(wrapperTagName.equals(nsUri,localName)) return acc; } else { if(expectedElements.containsKey(nsUri,localName)) return acc; } return null; } }
private Entry<V> getEntry(String nsUri,String localName) { // strings must be interned assert nsUri==nsUri.intern(); assert localName==localName.intern(); int hash = hash(localName); int i = indexFor(hash, table.length); Entry<V> e = table[i]; while (e != null && !(localName == e.localName && nsUri == e.nsUri)) e = e.next; return e; }
/** * Copies all of the mappings from the specified map to this map * These mappings will replace any mappings that * this map had for any of the keys currently in the specified map. * * @param map mappings to be stored in this map. * */ public QNameMap<V> putAll(QNameMap<? extends V> map) { int numKeysToBeAdded = map.size(); if (numKeysToBeAdded == 0) return this; if (numKeysToBeAdded > threshold) { int targetCapacity = numKeysToBeAdded; if (targetCapacity > MAXIMUM_CAPACITY) targetCapacity = MAXIMUM_CAPACITY; int newCapacity = table.length; while (newCapacity < targetCapacity) newCapacity <<= 1; if (newCapacity > table.length) resize(newCapacity); } for( Entry<? extends V> e : map.entrySet() ) put(e.nsUri,e.localName,e.getValue()); return this; }
case ATTRIBUTE: if(attUnmarshallers==null) attUnmarshallers = new QNameMap<TransducedAccessor>(); AttributeProperty ap = (AttributeProperty) p; attUnmarshallers.put(ap.attName.toQName(),ap.xacc); break; case ELEMENT: textHandler = childUnmarshallers.get(StructureLoaderBuilder.TEXT_HANDLER); catchAll = childUnmarshallers.get(StructureLoaderBuilder.CATCH_ALL);
public void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> handlers) { for (QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet()) handlers.put(n.nsUri,n.localName, new ChildLoader(n.getValue().getLoader(chain.context,true),acc)); if(domHandler!=null) handlers.put(CATCH_ALL,new ChildLoader(new WildcardLoader(domHandler,wcMode),acc)); }
public V get( QName name ) { return get(name.getNamespaceURI(),name.getLocalPart()); }
public final void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> loaders) { if(wrapperTagName!=null) { UnmarshallerChain c = new UnmarshallerChain(chain.context); QNameMap<ChildLoader> m = new QNameMap<ChildLoader>(); createBodyUnmarshaller(c,m); Loader loader = new ItemsLoader(acc, lister, m); if(isWrapperNillable || chain.context.allNillable) loader = new XsiNilLoader(loader); loaders.put(wrapperTagName,new ChildLoader(loader,null)); } else { createBodyUnmarshaller(chain,loaders); } }
@Override public Collection<QName> getExpectedChildElements() { return children.keySet(); } }
public Collection<QName> keySet() { Set<QName> r = new HashSet<QName>(); for (Entry<V> e : entrySet()) { r.add(e.createQName()); } return r; }
public boolean containsKey(String nsUri,String localName) { return getEntry(nsUri,localName)!=null; }
/** * Transfer all entries from current table to newTable. */ private void transfer(Entry<V>[] newTable) { Entry<V>[] src = table; int newCapacity = newTable.length; for (int j = 0; j < src.length; j++) { Entry<V> e = src[j]; if (e != null) { src[j] = null; do { Entry<V> next = e.next; int i = indexFor(e.hash, newCapacity); e.next = newTable[i]; newTable[i] = e; e = next; } while (e != null); } } }
private final QNameMap<JaxBeanInfo> rootMap = new QNameMap<JaxBeanInfo>(); private final HashMap<QName,JaxBeanInfo> typeMap = new HashMap<QName,JaxBeanInfo>();
/** * Copies all of the mappings from the specified map to this map * These mappings will replace any mappings that * this map had for any of the keys currently in the specified map. * * @param map mappings to be stored in this map. * */ public QNameMap<V> putAll(QNameMap<? extends V> map) { int numKeysToBeAdded = map.size(); if (numKeysToBeAdded == 0) return this; if (numKeysToBeAdded > threshold) { int targetCapacity = numKeysToBeAdded; if (targetCapacity > MAXIMUM_CAPACITY) targetCapacity = MAXIMUM_CAPACITY; int newCapacity = table.length; while (newCapacity < targetCapacity) newCapacity <<= 1; if (newCapacity > table.length) resize(newCapacity); } for( Entry<? extends V> e : map.entrySet() ) put(e.nsUri,e.localName,e.getValue()); return this; }
case ATTRIBUTE: if(attUnmarshallers==null) attUnmarshallers = new QNameMap<TransducedAccessor>(); AttributeProperty ap = (AttributeProperty) p; attUnmarshallers.put(ap.attName.toQName(),ap.xacc); break; case ELEMENT: textHandler = childUnmarshallers.get(StructureLoaderBuilder.TEXT_HANDLER); catchAll = childUnmarshallers.get(StructureLoaderBuilder.CATCH_ALL);
public void createBodyUnmarshaller(UnmarshallerChain chain, QNameMap<ChildLoader> loaders) { final int offset = chain.allocateOffset(); Receiver recv = new ReceiverImpl(offset); for( QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet() ) { final JaxBeanInfo beanInfo = n.getValue(); loaders.put(n.nsUri,n.localName,new ChildLoader(beanInfo.getLoader(chain.context,true),recv)); } if(isMixed) { // handler for processing mixed contents. loaders.put(TEXT_HANDLER, new ChildLoader(new MixedTextLoader(recv),null)); } if(domHandler!=null) { loaders.put(CATCH_ALL, new ChildLoader(new WildcardLoader(domHandler,wcMode),recv)); } }
@Override public Accessor getElementPropertyAccessor(String nsUri, String localName) { JaxBeanInfo bi = expectedElements.get(nsUri, localName); if(bi!=null) { if(bi instanceof ElementBeanInfoImpl) {