View Javadoc

1   package org.apache.maven;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  import org.apache.maven.project.Dependency;
21  
22  
23  /**
24   * Dependency wrapper. Adds an url to download and a description.
25   *
26   * @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
27   * @version $Id: DescribedDependency.java 532339 2007-04-25 12:28:56Z ltheussl $
28   */
29  public class DescribedDependency implements Comparable
30  {
31    //~ Instance fields ----------------------------------------------------------
32  
33    /** Original dependency. */
34    private Dependency dependency;
35  
36    /** Dependency description. */
37    private String description = null;
38  
39    /** Dependency Url. */
40    private String url = null;
41  
42    //~ Constructors -------------------------------------------------------------
43  
44    /**
45     * Creates a new DescribedDependency object.
46     *
47     * @param dependencyToWrap Original dependency.
48     */
49    public DescribedDependency(Dependency dependencyToWrap)
50    {
51      this.dependency = dependencyToWrap;
52    }
53  
54    //~ Methods ------------------------------------------------------------------
55  
56    /**
57     * Dependency's artifact property getter.
58     *
59     * @return dependency's artifact.
60     *
61     * @see Dependency#getArtifact()
62     */
63    public String getArtifact()
64    {
65      return dependency.getArtifact();
66    }
67  
68    /**
69     * Dependency's artifactDirectory property getter.
70     *
71     * @return dependency's artifactDirectory.
72     *
73     * @see Dependency#getArtifactDirectory()
74     */
75    public String getArtifactDirectory()
76    {
77      return dependency.getArtifactDirectory();
78    }
79  
80    /**
81     * Dependency's artifactId property getter.
82     *
83     * @return dependency's artifactId.
84     *
85     * @see Dependency#getArtifactId()
86     */
87    public String getArtifactId()
88    {
89      return dependency.getArtifactId();
90    }
91  
92    /**
93     * Property setter.
94     *
95     * @param newDescription new description for the dependency.
96     *
97     */
98    public void setDescription(String newDescription)
99    {
100     this.description = newDescription;
101   }
102 
103   /**
104    * Property getter.
105    *
106    * @return the dependency's description.
107    *
108    */
109   public String getDescription()
110   {
111     return description;
112   }
113 
114   /**
115    * Dependency's extension property getter.
116    *
117    * @return dependency's extension.
118    *
119    * @see Dependency#getExtension()
120    */
121   public String getExtension()
122   {
123     return dependency.getExtension();
124   }
125 
126   /**
127    * Dependency's groupId property getter.
128    *
129    * @return dependency's groupId.
130    *
131    * @see Dependency#getGroupId()
132    */
133   public String getGroupId()
134   {
135     return dependency.getGroupId();
136   }
137 
138   /**
139    * Dependency's id property getter.
140    *
141    * @return dependency's id.
142    *
143    * @see Dependency#getId()
144    */
145   public String getId()
146   {
147     return dependency.getId();
148   }
149 
150   /**
151    * Dependency's jar property getter.
152    *
153    * @return dependency's jar.
154    *
155    * @see Dependency#getJar()
156    */
157   public String getJar()
158   {
159     return dependency.getJar();
160   }
161 
162   /**
163    * Dependency's type property getter.
164    *
165    * @return dependency's type.
166    *
167    * @see Dependency#getType()
168    */
169   public String getType()
170   {
171     return dependency.getType();
172   }
173 
174   /**
175    * Property setter.
176    *
177    * @param newUrl the new dependency's url.
178    */
179   public void setUrl(String newUrl)
180   {
181     this.url = newUrl;
182   }
183 
184   /**
185    * Property getter.
186    *
187    * @return the dependency's url.
188    */
189   public String getUrl()
190   {
191     String retValue;
192 
193     if ((dependency.getUrl() != null) && (dependency.getUrl().length() > 0))
194     {
195       retValue = dependency.getUrl();
196     }
197     else
198     {
199       retValue = url;
200     }
201 
202     return retValue;
203   }
204 
205   /**
206    * Dependency's version property getter.
207    *
208    * @return dependency's version.
209    *
210    * @see Dependency#getVersion()
211    */
212   public String getVersion()
213   {
214     return dependency.getVersion();
215   }
216 
217   /**
218    * @see java.lang.Comparable#compareTo(java.lang.Object)
219    */
220   public int compareTo(Object obj)
221   {
222     DescribedDependency other = (DescribedDependency) obj;
223 
224     return this.getId().compareTo(other.getId());
225   }
226 
227     /**
228      * Delegate method from Dependency.getProperty("comment")
229      */
230     public String getComment() {
231         return dependency.getProperty("comment");
232     }
233 
234     /**
235      * Delegate method from Dependency.getProperty("scope")
236      */
237     public String getScope()
238     {
239         return dependency.getProperty("scope");
240     }
241 }