KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > classfile > impl > DelegatingCodeBaseEntry


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.classfile.impl;
21
22 import java.io.IOException JavaDoc;
23 import java.io.InputStream JavaDoc;
24
25 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
26 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
27 import edu.umd.cs.findbugs.classfile.ICodeBase;
28 import edu.umd.cs.findbugs.classfile.ICodeBaseEntry;
29 import edu.umd.cs.findbugs.classfile.InvalidClassFileFormatException;
30 import edu.umd.cs.findbugs.classfile.ResourceNotFoundException;
31
32 /**
33  * Implementation of ICodeBaseEntry that delegates to another
34  * codebase entry. This is needed for codebase entries in
35  * nested zipfiles, which are implemented using a private
36  * zipfile codebase.
37  *
38  * @author David Hovemeyer
39  */

40 public class DelegatingCodeBaseEntry implements ICodeBaseEntry {
41     private ICodeBase frontEndCodeBase;
42     private ICodeBaseEntry delegateCodeBaseEntry;
43     
44     public DelegatingCodeBaseEntry(ICodeBase frontEndCodeBase, ICodeBaseEntry delegateCodeBaseEntry) {
45         this.frontEndCodeBase = frontEndCodeBase;
46         this.delegateCodeBaseEntry = delegateCodeBaseEntry;
47     }
48
49     /* (non-Javadoc)
50      * @see edu.umd.cs.findbugs.classfile.ICodeBaseEntry#getNumBytes()
51      */

52     public int getNumBytes() {
53         return delegateCodeBaseEntry.getNumBytes();
54     }
55
56     /* (non-Javadoc)
57      * @see edu.umd.cs.findbugs.classfile.ICodeBaseEntry#getResourceName()
58      */

59     public String JavaDoc getResourceName() {
60         return delegateCodeBaseEntry.getResourceName();
61     }
62
63     /* (non-Javadoc)
64      * @see edu.umd.cs.findbugs.classfile.ICodeBaseEntry#openResource()
65      */

66     public InputStream JavaDoc openResource() throws IOException JavaDoc {
67         return delegateCodeBaseEntry.openResource();
68     }
69     
70     /* (non-Javadoc)
71      * @see edu.umd.cs.findbugs.classfile.ICodeBaseEntry#getCodeBase()
72      */

73     public ICodeBase getCodeBase() {
74         return frontEndCodeBase;
75     }
76     
77     /* (non-Javadoc)
78      * @see edu.umd.cs.findbugs.classfile.ICodeBaseEntry#getClassDescriptor()
79      */

80     public ClassDescriptor getClassDescriptor() throws ResourceNotFoundException, InvalidClassFileFormatException {
81         return delegateCodeBaseEntry.getClassDescriptor();
82     }
83     
84     /* (non-Javadoc)
85      * @see edu.umd.cs.findbugs.classfile.ICodeBaseEntry#overrideResourceName(java.lang.String)
86      */

87     public void overrideResourceName(String JavaDoc resourceName) {
88         delegateCodeBaseEntry.overrideResourceName(resourceName);
89     }
90     
91     /* (non-Javadoc)
92      * @see java.lang.Object#equals(java.lang.Object)
93      */

94     @Override JavaDoc
95     public boolean equals(Object JavaDoc obj) {
96         if (obj == null || obj.getClass() != this.getClass()) {
97             return false;
98         }
99         DelegatingCodeBaseEntry other = (DelegatingCodeBaseEntry) obj;
100         return this.frontEndCodeBase.equals(other.frontEndCodeBase)
101             && this.delegateCodeBaseEntry.equals(other.delegateCodeBaseEntry);
102     }
103     
104     /* (non-Javadoc)
105      * @see java.lang.Object#hashCode()
106      */

107     @Override JavaDoc
108     public int hashCode() {
109         return 7919 * frontEndCodeBase.hashCode() + delegateCodeBaseEntry.hashCode();
110     }
111
112     /* (non-Javadoc)
113      * @see java.lang.Object#toString()
114      */

115     @Override JavaDoc
116     public String JavaDoc toString() {
117         return delegateCodeBaseEntry.toString();
118     }
119 }
120
Popular Tags