JaxbParser.java
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one
00003  * or more contributor license agreements.  See the NOTICE file
00004  * distributed with this work for additional information
00005  * regarding copyright ownership.  The ASF licenses this file
00006  * to you under the Apache License, Version 2.0 (the
00007  * "License"); you may not use this file except in compliance
00008  * with the License.  You may obtain a copy of the License at
00009  *
00010  *   http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing,
00013  * software distributed under the License is distributed on an
00014  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00015  * KIND, either express or implied.  See the License for the
00016  * specific language governing permissions and limitations
00017  * under the License.    
00018  */
00019 package org.apache.xmlrpc.jaxb;
00020 
00021 import javax.xml.bind.JAXBContext;
00022 import javax.xml.bind.JAXBException;
00023 import javax.xml.bind.UnmarshallerHandler;
00024 
00025 import org.apache.xmlrpc.XmlRpcException;
00026 import org.apache.xmlrpc.parser.ExtParser;
00027 import org.xml.sax.ContentHandler;
00028 import org.xml.sax.SAXException;
00029 
00030 
00033 public class JaxbParser extends ExtParser {
00034         private final JAXBContext context;
00035         private UnmarshallerHandler handler;
00036 
00040         public JaxbParser(JAXBContext pContext) {
00041                 context = pContext;
00042         }
00043 
00044         protected ContentHandler getExtHandler() throws SAXException {
00045                 try {
00046                         handler = context.createUnmarshaller().getUnmarshallerHandler();
00047                 } catch (JAXBException e) {
00048                         throw new SAXException(e);
00049                 }
00050                 return handler;
00051         }
00052 
00053         protected String getTagName() { return JaxbSerializer.JAXB_TAG; }
00054 
00055         public Object getResult() throws XmlRpcException {
00056                 try {
00057                         return handler.getResult();
00058                 } catch (JAXBException e) {
00059                         throw new XmlRpcException("Failed to create result object: " + e.getMessage(), e);
00060                 }
00061         }
00062 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49