View Javadoc

1   package org.apache.maven.shared.jar.identification;
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 java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   * Gathered Maven information about the JAR file. Stores both assumed/validated values and potential values.
27   *
28   * @see org.apache.maven.shared.jar.identification.JarIdentificationAnalysis#analyze(org.apache.maven.shared.jar.JarAnalyzer)
29   */
30  public class JarIdentification
31  {
32      /**
33       * The group ID derived or guessed from the list of potentials of the JAR.
34       */
35      private String groupId;
36  
37      /**
38       * The artifact ID derived or guessed from the list of potentials of the JAR.
39       */
40      private String artifactId;
41  
42      /**
43       * The version derived or guessed from the list of potentials of the JAR.
44       */
45      private String version;
46  
47      /**
48       * The project name derived or guessed from the list of potentials of the JAR.
49       */
50      private String name;
51  
52      /**
53       * The vendor (organization name) derived or guessed from the list of potentials of the JAR.
54       */
55      private String vendor;
56  
57      /**
58       * The list of possible group IDs discovered.
59       */
60      private List potentialGroupIds = new ArrayList();
61  
62      /**
63       * The list of possible artifact IDs discovered.
64       */
65      private List potentialArtifactIds = new ArrayList();
66  
67      /**
68       * The list of possible versions discovered.
69       */
70      private List potentialVersions = new ArrayList();
71  
72      /**
73       * The list of possible artifact names discovered.
74       */
75      private List potentialNames = new ArrayList();
76  
77      /**
78       * The list of possible vendors discovered.
79       */
80      private List potentialVendors = new ArrayList();
81  
82      /**
83       * Add a validated group ID.
84       *
85       * @param groupId the group ID discovered
86       */
87      public void addAndSetGroupId( String groupId )
88      {
89          if ( groupId != null )
90          {
91              this.groupId = groupId;
92          }
93  
94          addGroupId( groupId );
95      }
96  
97      /**
98       * Add a potential group ID.
99       *
100      * @param groupId the group ID discovered
101      */
102     public void addGroupId( String groupId )
103     {
104         addUnique( potentialGroupIds, groupId );
105     }
106 
107     /**
108      * Add a validated artifact ID.
109      *
110      * @param artifactId the artifact ID discovered
111      */
112     public void addAndSetArtifactId( String artifactId )
113     {
114         if ( artifactId != null )
115         {
116             this.artifactId = artifactId;
117         }
118 
119         addArtifactId( artifactId );
120     }
121 
122     /**
123      * Add a potential artifact ID.
124      *
125      * @param artifactId the artifact ID discovered
126      */
127     public void addArtifactId( String artifactId )
128     {
129         addUnique( potentialArtifactIds, artifactId );
130     }
131 
132     /**
133      * Add a validated version.
134      *
135      * @param version the version discovered
136      */
137     public void addAndSetVersion( String version )
138     {
139         if ( version != null )
140         {
141             this.version = version;
142         }
143 
144         addVersion( version );
145     }
146 
147     /**
148      * Add a potential version.
149      *
150      * @param version the version discovered
151      */
152     public void addVersion( String version )
153     {
154         addUnique( potentialVersions, version );
155     }
156 
157     /**
158      * Add a validated vendor name.
159      *
160      * @param name the vendor name discovered
161      */
162     public void addAndSetVendor( String name )
163     {
164         if ( name != null )
165         {
166             vendor = name;
167         }
168 
169         addVendor( name );
170     }
171 
172     /**
173      * Add a potential vendor name.
174      *
175      * @param name the vendor name discovered
176      */
177     public void addVendor( String name )
178     {
179         addUnique( potentialVendors, name );
180     }
181 
182     /**
183      * Add a validated artifact name.
184      *
185      * @param name the artifact name discovered
186      */
187     public void addAndSetName( String name )
188     {
189         if ( name != null )
190         {
191             this.name = name;
192         }
193 
194         addName( name );
195     }
196 
197     /**
198      * Add a potential artifact name.
199      *
200      * @param name the artifact name discovered
201      */
202     public void addName( String name )
203     {
204         addUnique( potentialNames, name );
205     }
206 
207     private static void addUnique( List list, String value )
208     {
209         if ( value != null )
210         {
211             if ( !list.contains( value ) )
212             {
213                 list.add( value );
214             }
215         }
216     }
217 
218     public String getArtifactId()
219     {
220         return artifactId;
221     }
222 
223     public void setArtifactId( String artifactId )
224     {
225         this.artifactId = artifactId;
226     }
227 
228     public String getGroupId()
229     {
230         return groupId;
231     }
232 
233     public void setGroupId( String groupId )
234     {
235         this.groupId = groupId;
236     }
237 
238     public String getName()
239     {
240         return name;
241     }
242 
243     public void setName( String name )
244     {
245         this.name = name;
246     }
247 
248     public String getVendor()
249     {
250         return vendor;
251     }
252 
253     public void setVendor( String vendor )
254     {
255         this.vendor = vendor;
256     }
257 
258     public String getVersion()
259     {
260         return version;
261     }
262 
263     public void setVersion( String version )
264     {
265         this.version = version;
266     }
267 
268     public List getPotentialVersions()
269     {
270         return potentialVersions;
271     }
272 
273     public List getPotentialNames()
274     {
275         return potentialNames;
276     }
277 
278     public List getPotentialGroupIds()
279     {
280         return potentialGroupIds;
281     }
282 
283     public List getPotentialArtifactIds()
284     {
285         return potentialArtifactIds;
286     }
287 
288     public List getPotentialVendors()
289     {
290         return potentialVendors;
291     }
292 }