Coverage Report - org.apache.commons.classscan.bcel.BcelClassDigesterFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
BcelClassDigesterFactory
100%
3/3
N/A
1
BcelClassDigesterFactory$1
100%
2/2
N/A
1
 
 1  
 /*
 2  
  * Licensed under the Apache License, Version 2.0 (the "License");
 3  
  * you may not use this file except in compliance with the License.
 4  
  * You may obtain a copy of the License at
 5  
  *
 6  
  *      http://www.apache.org/licenses/LICENSE-2.0
 7  
  *
 8  
  * Unless required by applicable law or agreed to in writing, software
 9  
  * distributed under the License is distributed on an "AS IS" BASIS,
 10  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11  
  * See the License for the specific language governing permissions and
 12  
  * limitations under the License.
 13  
  */
 14  
 package org.apache.commons.classscan.bcel;
 15  
 
 16  
 import java.io.IOException;
 17  
 import java.io.InputStream;
 18  
 
 19  
 import org.apache.bcel.classfile.ClassParser;
 20  
 import org.apache.commons.classscan.MetaClassPathElement;
 21  
 import org.apache.commons.classscan.MetaRegistry;
 22  
 import org.apache.commons.classscan.spi.ClassDigesterFactory;
 23  
 import org.apache.commons.classscan.spi.model.SpiClassDigester;
 24  
 import org.apache.commons.classscan.spi.model.SpiMetaClass;
 25  
 
 26  
 /**
 27  
  * A ClassDigesterFactory that uses BCEL to digest the class bytes
 28  
  */
 29  11
 public class BcelClassDigesterFactory implements ClassDigesterFactory {
 30  
 
 31  
     // making digester an instance field ensures that BCEL library is loaded.
 32  
     // If load is successful, this factory will produce a usable digester
 33  11
     private SpiClassDigester spiClassDigester = new SpiClassDigester() {
 34  
                 @Override
 35  
                 public SpiMetaClass createMetaClass(MetaClassPathElement location, String className, InputStream byteStream) throws IOException {
 36  227997
                         return new BcelClass(location, new ClassParser(byteStream, className));
 37  
                 }
 38  
         };
 39  
 
 40  
         @Override
 41  
         public SpiClassDigester createDigester(MetaRegistry metaRegistry) {
 42  11
                 return spiClassDigester;
 43  
         }
 44  
 }