Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JarClasses |
|
| 1.0;1 |
1 | package org.apache.maven.shared.jar.classes; | |
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.commons.collections.list.SetUniqueList; | |
23 | ||
24 | import java.util.ArrayList; | |
25 | import java.util.Collections; | |
26 | import java.util.List; | |
27 | ||
28 | /** | |
29 | * Gathered facts about the classes within a JAR file. | |
30 | * | |
31 | * @see org.apache.maven.shared.jar.classes.JarClassesAnalysis#analyze(org.apache.maven.shared.jar.JarAnalyzer) | |
32 | */ | |
33 | public class JarClasses | |
34 | { | |
35 | /** | |
36 | * The list of imports in the classes in the JAR. | |
37 | */ | |
38 | private List imports; | |
39 | ||
40 | /** | |
41 | * A list of packages represented by classes in the JAR. | |
42 | */ | |
43 | private List packages; | |
44 | ||
45 | /** | |
46 | * A list of the classes that in the JAR. | |
47 | */ | |
48 | private List classNames; | |
49 | ||
50 | /** | |
51 | * A list of methods within the classes in the JAR. | |
52 | */ | |
53 | private List methods; | |
54 | ||
55 | /** | |
56 | * Whether the JAR contains any code with debug information. If there is a mix of debug and release code, this will | |
57 | * still be true. | |
58 | */ | |
59 | private boolean isDebugPresent; | |
60 | ||
61 | /** | |
62 | * The highest JVM revision available in any class files. While the JAR may work on earlier JVMs if particular | |
63 | * classes are not used, this is the minimum JVM that guarantees compatibility. | |
64 | */ | |
65 | private String jdkRevision; | |
66 | ||
67 | /** | |
68 | * Constructor to create an empty instance. | |
69 | */ | |
70 | public JarClasses() | |
71 | 0 | { |
72 | // Unique list decorators are used to ensure natural ordering is retained, the list interface is availble, and | |
73 | // that duplicates are not entered. | |
74 | 0 | imports = SetUniqueList.decorate( new ArrayList() ); |
75 | 0 | packages = SetUniqueList.decorate( new ArrayList() ); |
76 | 0 | classNames = SetUniqueList.decorate( new ArrayList() ); |
77 | 0 | methods = SetUniqueList.decorate( new ArrayList() ); |
78 | 0 | } |
79 | ||
80 | /** | |
81 | * Add a discovered class to the record. | |
82 | * | |
83 | * @param name the name of the class | |
84 | */ | |
85 | public void addClassName( String name ) | |
86 | { | |
87 | 0 | this.classNames.add( name ); |
88 | 0 | } |
89 | ||
90 | /** | |
91 | * Add a discovered package to the record. | |
92 | * | |
93 | * @param name the name of the package | |
94 | */ | |
95 | public void addPackage( String name ) | |
96 | { | |
97 | 0 | this.packages.add( name ); |
98 | 0 | } |
99 | ||
100 | /** | |
101 | * Add a discovered method to the record. | |
102 | * | |
103 | * @param name the name of the method | |
104 | */ | |
105 | public void addMethod( String name ) | |
106 | { | |
107 | 0 | this.methods.add( name ); |
108 | 0 | } |
109 | ||
110 | /** | |
111 | * Add a list of discovered imports to the record. | |
112 | * | |
113 | * @param imports the imports to add. Each item should be a String to avoid down the line ClassCastExceptions. | |
114 | */ | |
115 | public void addImports( List imports ) | |
116 | { | |
117 | 0 | this.imports.addAll( imports ); |
118 | 0 | } |
119 | ||
120 | public List getImports() | |
121 | { | |
122 | 0 | return Collections.unmodifiableList( imports ); |
123 | } | |
124 | ||
125 | public List getClassNames() | |
126 | { | |
127 | 0 | return Collections.unmodifiableList( classNames ); |
128 | } | |
129 | ||
130 | public List getPackages() | |
131 | { | |
132 | 0 | return Collections.unmodifiableList( packages ); |
133 | } | |
134 | ||
135 | public boolean isDebugPresent() | |
136 | { | |
137 | 0 | return isDebugPresent; |
138 | } | |
139 | ||
140 | public void setDebugPresent( boolean hasDebugSymbols ) | |
141 | { | |
142 | 0 | this.isDebugPresent = hasDebugSymbols; |
143 | 0 | } |
144 | ||
145 | public String getJdkRevision() | |
146 | { | |
147 | 0 | return jdkRevision; |
148 | } | |
149 | ||
150 | public void setJdkRevision( String jdkRevision ) | |
151 | { | |
152 | 0 | this.jdkRevision = jdkRevision; |
153 | 0 | } |
154 | ||
155 | public List getMethods() | |
156 | { | |
157 | 0 | return Collections.unmodifiableList( methods ); |
158 | } | |
159 | } |