Coverage Report - org.acegisecurity.util.InMemoryResource
 
Classes in this File Line Coverage Branch Coverage Complexity
InMemoryResource
0% 
0% 
1
 
 1  
 /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
 2  
  *
 3  
  * Licensed under the Apache License, Version 2.0 (the "License");
 4  
  * you may not use this file except in compliance with the License.
 5  
  * You may obtain a copy of the License at
 6  
  *
 7  
  *     http://www.apache.org/licenses/LICENSE-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing, software
 10  
  * distributed under the License is distributed on an "AS IS" BASIS,
 11  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
  * See the License for the specific language governing permissions and
 13  
  * limitations under the License.
 14  
  */
 15  
 
 16  
 package org.acegisecurity.util;
 17  
 
 18  
 import org.springframework.core.io.AbstractResource;
 19  
 
 20  
 import java.io.ByteArrayInputStream;
 21  
 import java.io.IOException;
 22  
 import java.io.InputStream;
 23  
 
 24  
 
 25  
 /**
 26  
  * An in memory implementation of Spring's {@link org.springframework.core.io.Resource} interface.
 27  
  * <p>Used by the "Acegifier" web application to create a bean factory from an XML string, rather than a file.</p>
 28  
  *
 29  
  * @author Luke Taylor
 30  
  * @version $Id: InMemoryResource.java 1784 2007-02-24 21:00:24Z luke_t $
 31  
  */
 32  
 public class InMemoryResource extends AbstractResource {
 33  
     //~ Instance fields ================================================================================================
 34  
 
 35  
     private ByteArrayInputStream in;
 36  
     private String description;
 37  
 
 38  
     //~ Constructors ===================================================================================================
 39  
 
 40  
     public InMemoryResource(byte[] source) {
 41  0
         this(source, null);
 42  0
     }
 43  
 
 44  0
     public InMemoryResource(byte[] source, String description) {
 45  0
         in = new ByteArrayInputStream(source);
 46  0
         this.description = description;
 47  0
     }
 48  
 
 49  
     //~ Methods ========================================================================================================
 50  
 
 51  
     public String getDescription() {
 52  0
         return (description == null) ? in.toString() : description;
 53  
     }
 54  
 
 55  
     public InputStream getInputStream() throws IOException {
 56  0
         return in;
 57  
     }
 58  
 }