src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/LeafBeanInfoImpl.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2011, 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


  62     private final Transducer<BeanT> xducer;
  63 
  64     /**
  65      * Non-null only if the leaf is also an element.
  66      */
  67     private final Name tagName;
  68 
  69     public LeafBeanInfoImpl(JAXBContextImpl grammar, RuntimeLeafInfo li) {
  70         super(grammar,li,li.getClazz(),li.getTypeNames(),li.isElement(),true,false);
  71 
  72         xducer = li.getTransducer();
  73         loader = new TextLoader(xducer);
  74         loaderWithSubst = new XsiTypeLoader(this);
  75 
  76         if(isElement())
  77             tagName = grammar.nameBuilder.createElementName(li.getElementName());
  78         else
  79             tagName = null;
  80     }
  81 

  82     public QName getTypeName(BeanT instance) {
  83         QName tn = xducer.getTypeName(instance);
  84         if(tn!=null)    return tn;
  85         // rely on default
  86         return super.getTypeName(instance);
  87     }
  88 
  89     public final String getElementNamespaceURI(BeanT _) {
  90         return tagName.nsUri;
  91     }
  92 
  93     public final String getElementLocalName(BeanT _) {
  94         return tagName.localName;
  95     }
  96 
  97     public BeanT createInstance(UnmarshallingContext context) {
  98         throw new UnsupportedOperationException();
  99     }
 100 
 101     public final boolean reset(BeanT bean, UnmarshallingContext context) {
 102         return false;
 103     }
 104 
 105     public final String getId(BeanT bean, XMLSerializer target) {
 106         return null;
 107     }
 108 
 109     public final void serializeBody(BeanT bean, XMLSerializer w) throws SAXException, IOException, XMLStreamException {
 110         // most of the times leaves are printed as leaf element/attribute property,
 111         // so this code is only used for example when you have multiple XmlElement on a property
 112         // and some of them are leaves. Hence this doesn't need to be super-fast.
 113         try {


   1 /*
   2  * Copyright (c) 1997, 2013, 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


  62     private final Transducer<BeanT> xducer;
  63 
  64     /**
  65      * Non-null only if the leaf is also an element.
  66      */
  67     private final Name tagName;
  68 
  69     public LeafBeanInfoImpl(JAXBContextImpl grammar, RuntimeLeafInfo li) {
  70         super(grammar,li,li.getClazz(),li.getTypeNames(),li.isElement(),true,false);
  71 
  72         xducer = li.getTransducer();
  73         loader = new TextLoader(xducer);
  74         loaderWithSubst = new XsiTypeLoader(this);
  75 
  76         if(isElement())
  77             tagName = grammar.nameBuilder.createElementName(li.getElementName());
  78         else
  79             tagName = null;
  80     }
  81 
  82     @Override
  83     public QName getTypeName(BeanT instance) {
  84         QName tn = xducer.getTypeName(instance);
  85         if(tn!=null)    return tn;
  86         // rely on default
  87         return super.getTypeName(instance);
  88     }
  89 
  90     public final String getElementNamespaceURI(BeanT t) {
  91         return tagName.nsUri;
  92     }
  93 
  94     public final String getElementLocalName(BeanT t) {
  95         return tagName.localName;
  96     }
  97 
  98     public BeanT createInstance(UnmarshallingContext context) {
  99         throw new UnsupportedOperationException();
 100     }
 101 
 102     public final boolean reset(BeanT bean, UnmarshallingContext context) {
 103         return false;
 104     }
 105 
 106     public final String getId(BeanT bean, XMLSerializer target) {
 107         return null;
 108     }
 109 
 110     public final void serializeBody(BeanT bean, XMLSerializer w) throws SAXException, IOException, XMLStreamException {
 111         // most of the times leaves are printed as leaf element/attribute property,
 112         // so this code is only used for example when you have multiple XmlElement on a property
 113         // and some of them are leaves. Hence this doesn't need to be super-fast.
 114         try {