Coverage Report - org.apache.camel.spring.converter.ResourceConverter
 
Classes in this File Line Coverage Branch Coverage Complexity
ResourceConverter
0% 
N/A 
0
 
 1  
 /**
 2  
  *
 3  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 4  
  * contributor license agreements.  See the NOTICE file distributed with
 5  
  * this work for additional information regarding copyright ownership.
 6  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 7  
  * (the "License"); you may not use this file except in compliance with
 8  
  * the License.  You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 package org.apache.camel.spring.converter;
 19  
 
 20  
 import org.apache.camel.Converter;
 21  
 import org.springframework.core.io.ByteArrayResource;
 22  
 import org.springframework.core.io.FileSystemResource;
 23  
 import org.springframework.core.io.Resource;
 24  
 import org.springframework.core.io.UrlResource;
 25  
 
 26  
 import java.io.File;
 27  
 import java.io.IOException;
 28  
 import java.io.InputStream;
 29  
 import java.net.URL;
 30  
 
 31  
 /**
 32  
  * Some Spring based
 33  
  * <a href="http://activemq.apache.org/camel/type-converter.html">Type Converters</a>
 34  
  *
 35  
  * @version $Revision: 524222 $
 36  
  */
 37  
 @Converter
 38  0
 public class ResourceConverter {
 39  
     @Converter
 40  
     public static InputStream toInputStream(Resource resource) throws IOException {
 41  0
         return resource.getInputStream();
 42  
     }
 43  
 
 44  
     @Converter
 45  
     public static File toFile(Resource resource) throws IOException {
 46  0
         return resource.getFile();
 47  
     }
 48  
 
 49  
     @Converter
 50  
     public static URL toUrl(Resource resource) throws IOException {
 51  0
         return resource.getURL();
 52  
     }
 53  
 
 54  
     @Converter
 55  
     public static UrlResource toResource(String uri) throws IOException {
 56  0
         return new UrlResource(uri);
 57  
     }
 58  
 
 59  
     @Converter
 60  
     public static UrlResource toResource(URL uri) throws IOException {
 61  0
         return new UrlResource(uri);
 62  
     }
 63  
 
 64  
     @Converter
 65  
     public static FileSystemResource toResource(File file) throws IOException {
 66  0
         return new FileSystemResource(file);
 67  
     }
 68  
 
 69  
     @Converter
 70  
     public static ByteArrayResource toResource(byte[] data) throws IOException {
 71  0
         return new ByteArrayResource(data);
 72  
     }
 73  
 }