Coverage Report - org.apache.xmlrpc.parser.SerializableParser
 
Classes in this File Line Coverage Branch Coverage Complexity
SerializableParser
56% 
N/A 
6
 
 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.parser;
 17  
 
 18  
 import java.io.ByteArrayInputStream;
 19  
 import java.io.IOException;
 20  
 import java.io.ObjectInputStream;
 21  
 
 22  
 import org.apache.xmlrpc.XmlRpcException;
 23  
 
 24  
 
 25  
 /** A parser for serializable objects.
 26  
  */
 27  8
 public class SerializableParser extends ByteArrayParser {
 28  
         public Object getResult() throws XmlRpcException {
 29  
                 try {
 30  8
                         byte[] res = (byte[]) super.getResult();
 31  8
                         ByteArrayInputStream bais = new ByteArrayInputStream(res);
 32  8
                         ObjectInputStream ois = new ObjectInputStream(bais);
 33  8
                         return ois.readObject();
 34  0
                 } catch (IOException e) {
 35  0
                         throw new XmlRpcException("Failed to read result object: " + e.getMessage(), e);
 36  0
                 } catch (ClassNotFoundException e) {
 37  0
                         throw new XmlRpcException("Failed to load class for result object: " + e.getMessage(), e);
 38  
                 }
 39  
         }
 40  
 }