Coverage Report - org.apache.maven.shared.jar.JarData
 
Classes in this File Line Coverage Branch Coverage Complexity
JarData
0%
0/32
0%
0/4
1.111
 
 1  
 package org.apache.maven.shared.jar;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.shared.jar.classes.JarClasses;
 23  
 import org.apache.maven.shared.jar.identification.JarIdentification;
 24  
 import org.codehaus.plexus.util.StringUtils;
 25  
 
 26  
 import java.io.File;
 27  
 import java.util.Collections;
 28  
 import java.util.List;
 29  
 import java.util.jar.Attributes;
 30  
 import java.util.jar.Manifest;
 31  
 
 32  
 /**
 33  
  * Class that contains details of a single JAR file and it's entries.
 34  
  */
 35  
 public final class JarData
 36  
 {
 37  
     /**
 38  
      * The JAR file.
 39  
      */
 40  
     private final File file;
 41  
 
 42  
     /**
 43  
      * Whether the JAR file is sealed.
 44  
      */
 45  
     private final boolean sealed;
 46  
 
 47  
     /**
 48  
      * The hashcode for the entire file's contents.
 49  
      */
 50  
     private String fileHash;
 51  
 
 52  
     /**
 53  
      * The hashcode for the file's class data contents.
 54  
      */
 55  
     private String bytecodeHash;
 56  
 
 57  
     /**
 58  
      * The JAR's manifest.
 59  
      */
 60  
     private final Manifest manifest;
 61  
 
 62  
     /**
 63  
      * Information about the JAR's classes.
 64  
      */
 65  
     private JarClasses jarClasses;
 66  
 
 67  
     /**
 68  
      * The JAR entries.
 69  
      */
 70  
     private final List entries;
 71  
 
 72  
     /**
 73  
      * Information about the JAR's identifying features.
 74  
      */
 75  
     private JarIdentification jarIdentification;
 76  
 
 77  
     /**
 78  
      * Constructor.
 79  
      *
 80  
      * @param file     the JAR file
 81  
      * @param manifest the JAR manifest
 82  
      * @param entries  the JAR entries
 83  
      */
 84  
     public JarData( File file, Manifest manifest, List entries )
 85  0
     {
 86  0
         this.file = file;
 87  
 
 88  0
         this.manifest = manifest;
 89  
 
 90  0
         this.entries = Collections.unmodifiableList( entries );
 91  
 
 92  0
         boolean sealed = false;
 93  0
         if ( this.manifest != null )
 94  
         {
 95  0
             String sval = this.manifest.getMainAttributes().getValue( Attributes.Name.SEALED );
 96  0
             if ( StringUtils.isNotEmpty( sval ) )
 97  
             {
 98  0
                 sealed = "true".equalsIgnoreCase( sval.trim() );
 99  
             }
 100  
         }
 101  0
         this.sealed = sealed;
 102  0
     }
 103  
 
 104  
     public List getEntries()
 105  
     {
 106  0
         return entries;
 107  
     }
 108  
 
 109  
     public Manifest getManifest()
 110  
     {
 111  0
         return manifest;
 112  
     }
 113  
 
 114  
     public File getFile()
 115  
     {
 116  0
         return file;
 117  
     }
 118  
 
 119  
     public boolean isSealed()
 120  
     {
 121  0
         return sealed;
 122  
     }
 123  
 
 124  
     public void setFileHash( String fileHash )
 125  
     {
 126  0
         this.fileHash = fileHash;
 127  0
     }
 128  
 
 129  
     public String getFileHash()
 130  
     {
 131  0
         return fileHash;
 132  
     }
 133  
 
 134  
     public void setBytecodeHash( String bytecodeHash )
 135  
     {
 136  0
         this.bytecodeHash = bytecodeHash;
 137  0
     }
 138  
 
 139  
     public String getBytecodeHash()
 140  
     {
 141  0
         return bytecodeHash;
 142  
     }
 143  
 
 144  
     public boolean isDebugPresent()
 145  
     {
 146  0
         return jarClasses.isDebugPresent();
 147  
     }
 148  
 
 149  
     public void setJarClasses( JarClasses jarClasses )
 150  
     {
 151  0
         this.jarClasses = jarClasses;
 152  0
     }
 153  
 
 154  
     public int getNumEntries()
 155  
     {
 156  0
         return entries.size();
 157  
     }
 158  
 
 159  
     public int getNumClasses()
 160  
     {
 161  0
         return jarClasses.getClassNames().size();
 162  
     }
 163  
 
 164  
     public int getNumPackages()
 165  
     {
 166  0
         return jarClasses.getPackages().size();
 167  
     }
 168  
 
 169  
     public String getJdkRevision()
 170  
     {
 171  0
         return jarClasses.getJdkRevision();
 172  
     }
 173  
 
 174  
     public void setJarIdentification( JarIdentification jarIdentification )
 175  
     {
 176  0
         this.jarIdentification = jarIdentification;
 177  0
     }
 178  
 
 179  
     public JarIdentification getJarIdentification()
 180  
     {
 181  0
         return jarIdentification;
 182  
     }
 183  
 
 184  
     public JarClasses getJarClasses()
 185  
     {
 186  0
         return jarClasses;
 187  
     }
 188  
 }