Coverage Report - org.apache.xmlrpc.jaxb.JaxbTypeFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
JaxbTypeFactory
0% 
0% 
3
 
 1  
 /*
 2  
  * Copyright 1999,2005 The Apache Software Foundation.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.xmlrpc.jaxb;
 17  
 
 18  
 import javax.xml.bind.Element;
 19  
 import javax.xml.bind.JAXBContext;
 20  
 
 21  
 import org.apache.ws.commons.util.NamespaceContextImpl;
 22  
 import org.apache.xmlrpc.common.TypeFactoryImpl;
 23  
 import org.apache.xmlrpc.common.XmlRpcController;
 24  
 import org.apache.xmlrpc.common.XmlRpcStreamConfig;
 25  
 import org.apache.xmlrpc.parser.TypeParser;
 26  
 import org.apache.xmlrpc.serializer.TypeSerializer;
 27  
 import org.apache.xmlrpc.serializer.XmlRpcWriter;
 28  
 import org.xml.sax.SAXException;
 29  
 
 30  
 
 31  
 /** A type factory with support for JAXB objects.
 32  
  */
 33  
 public class JaxbTypeFactory extends TypeFactoryImpl {
 34  
         private final JAXBContext context;
 35  
         private final JaxbSerializer serializer; 
 36  
 
 37  
         /** Creates a new instance with the given controller and
 38  
          * JAXB context.
 39  
          * @param pController The controller, which will invoke the factory.
 40  
          * @param pContext The context being used to create marshallers
 41  
          * and unmarshallers.
 42  
          */
 43  
         public JaxbTypeFactory(XmlRpcController pController, JAXBContext pContext) {
 44  0
                 super(pController);
 45  0
                 context = pContext;
 46  0
                 serializer = new JaxbSerializer(context);
 47  0
         }
 48  
 
 49  
         public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) {
 50  0
                 TypeParser tp = super.getParser(pConfig, pContext, pURI, pLocalName);
 51  0
                 if (tp == null) {
 52  0
                         if (XmlRpcWriter.EXTENSIONS_URI.equals(pURI)  &&  JaxbSerializer.JAXB_TAG.equals(pLocalName)) {
 53  0
                                 return new JaxbParser(context);
 54  
                         }
 55  
                 }
 56  0
                 return tp;
 57  
         }
 58  
 
 59  
         public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException {
 60  0
                 TypeSerializer ts = super.getSerializer(pConfig, pObject);
 61  0
                 if (ts == null) {
 62  0
                         if (pObject instanceof Element) {
 63  0
                                 return serializer;
 64  
                         }
 65  
                 }
 66  0
                 return ts;
 67  
         }
 68  
 }