Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JJARPackage |
|
| 1.5714285714285714;1.571 |
1 | /* | |
2 | * Copyright 2001,2004 The Apache Software Foundation. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | package org.apache.commons.jjar; | |
18 | ||
19 | import java.util.HashMap; | |
20 | ||
21 | /** | |
22 | * little class to handle the | |
23 | * package/version duple. | |
24 | * | |
25 | * the intent was to extend to carry more | |
26 | * information, but the repository seems to | |
27 | * be doing ok for that. | |
28 | * | |
29 | * It might be nice to continue here though | |
30 | * and make the repository surface area smaller | |
31 | * | |
32 | * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a> | |
33 | * @version $Id: JJARPackage.java 155454 2005-02-26 13:23:34Z dirkv $ | |
34 | */ | |
35 | public class JJARPackage | |
36 | { | |
37 | private String name; | |
38 | private Version version; | |
39 | private HashMap properties; | |
40 | ||
41 | 0 | private static String DESC = "desc"; |
42 | 0 | private static String JAR = "jar"; |
43 | 0 | private static String HREF = "href"; |
44 | ||
45 | /** | |
46 | * usual CTOR | |
47 | */ | |
48 | public JJARPackage( String name, String version ) | |
49 | 0 | { |
50 | 0 | this.name = name; |
51 | 0 | this.version = new Version(version); |
52 | 0 | } |
53 | ||
54 | /** | |
55 | * ctor for <package>:<version> unispec | |
56 | */ | |
57 | public JJARPackage( String onepiece ) | |
58 | 0 | { |
59 | 0 | int i = onepiece.indexOf(":"); |
60 | ||
61 | 0 | if (i != -1 ) |
62 | { | |
63 | 0 | this.name = onepiece.substring(0, i ); |
64 | 0 | this.version = new Version( onepiece.substring( i + 1 ) ); |
65 | } | |
66 | 0 | } |
67 | ||
68 | public String getName() | |
69 | { | |
70 | 0 | return name; |
71 | } | |
72 | ||
73 | public Version getVersion() | |
74 | { | |
75 | 0 | return version; |
76 | } | |
77 | ||
78 | public String getVersionString() | |
79 | { | |
80 | 0 | return version.toString(); |
81 | } | |
82 | ||
83 | public boolean equals( JJARPackage jpack ) | |
84 | { | |
85 | 0 | return equals( jpack.getName(), jpack.getVersionString() ); |
86 | } | |
87 | ||
88 | public boolean equals( String pkg, String ver ) | |
89 | { | |
90 | 0 | if ( pkg != null && this.name.equals( pkg ) ) |
91 | { | |
92 | // do something better here ? | |
93 | ||
94 | 0 | if ( ver != null && version.equals( ver ) ) |
95 | { | |
96 | 0 | return true; |
97 | } | |
98 | } | |
99 | ||
100 | 0 | return false; |
101 | } | |
102 | } | |
103 | ||
104 | ||
105 |