< prev index next >

src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StructureLoader.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 214                             attCatchAll.set(o,map);
 215                         }
 216 
 217                         String prefix;
 218                         int idx = qname.indexOf(':');
 219                         if(idx<0)   prefix="";
 220                         else        prefix=qname.substring(0,idx);
 221 
 222                         map.put(new QName(auri,alocal,prefix),avalue);
 223                     }
 224                 } catch (AccessorException e) {
 225                    handleGenericException(e,true);
 226                 }
 227             }
 228         }
 229     }
 230 
 231     @Override
 232     public void childElement(UnmarshallingContext.State state, TagName arg) throws SAXException {
 233         ChildLoader child = childUnmarshallers.get(arg.uri,arg.local);
 234         if(child==null) {
 235             if ((beanInfo != null) && (beanInfo.getTypeNames() != null)) {
 236                 Iterator typeNamesIt = beanInfo.getTypeNames().iterator();
 237                 QName parentQName = null;
 238                 if ((typeNamesIt != null) && (typeNamesIt.hasNext()) && (catchAll == null)) {
 239                     parentQName = (QName) typeNamesIt.next();
 240                     String parentUri = parentQName.getNamespaceURI();
 241                     child = childUnmarshallers.get(parentUri, arg.local);
 242                 }
 243             }
 244             if (child == null) {
 245                 child = catchAll;
 246                 if(child==null) {
 247                     super.childElement(state,arg);
 248                     return;
 249                 }
 250             }
 251         }
 252 
 253         state.setLoader(child.loader);
 254         state.setReceiver(child.receiver);
 255     }
 256 
 257     @Override
 258     public Collection<QName> getExpectedChildElements() {
 259         return childUnmarshallers.keySet();
 260     }
 261 
 262     @Override
 263     public Collection<QName> getExpectedAttributes() {
 264         return attUnmarshallers.keySet();
 265     }
 266 
 267     @Override
 268     public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException {
 269         if(textHandler!=null)
   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 214                             attCatchAll.set(o,map);
 215                         }
 216 
 217                         String prefix;
 218                         int idx = qname.indexOf(':');
 219                         if(idx<0)   prefix="";
 220                         else        prefix=qname.substring(0,idx);
 221 
 222                         map.put(new QName(auri,alocal,prefix),avalue);
 223                     }
 224                 } catch (AccessorException e) {
 225                    handleGenericException(e,true);
 226                 }
 227             }
 228         }
 229     }
 230 
 231     @Override
 232     public void childElement(UnmarshallingContext.State state, TagName arg) throws SAXException {
 233         ChildLoader child = childUnmarshallers.get(arg.uri,arg.local);










 234         if (child == null) {
 235             child = catchAll;
 236             if (child==null) {
 237                 super.childElement(state,arg);
 238                 return;

 239             }
 240         }
 241 
 242         state.setLoader(child.loader);
 243         state.setReceiver(child.receiver);
 244     }
 245 
 246     @Override
 247     public Collection<QName> getExpectedChildElements() {
 248         return childUnmarshallers.keySet();
 249     }
 250 
 251     @Override
 252     public Collection<QName> getExpectedAttributes() {
 253         return attUnmarshallers.keySet();
 254     }
 255 
 256     @Override
 257     public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException {
 258         if(textHandler!=null)
< prev index next >