1 package net.sourceforge.argval.packageinfo.impl;
2
3
4 import java.util.Set;
5 import java.util.TreeSet;
6
7 import net.sourceforge.argval.packageinfo.AbstractPackageInfo;
8
9
10 /**
11 * A helper class which stores once the <code>Package</code> details and contains a Set
12 * containing all the related Java language package names (the dot separated package name
13 * like <code>net.sourceforge.argval.packageinfo</code> ).
14 *
15 * @author <a href="http://sourceforge.net/users/verhagent/">T. Verhagen</a>
16 */
17 public class PackageInfoImpl extends AbstractPackageInfo {
18 private String specTitle;
19 private String specVendor;
20 private String specVersion;
21 private String implTitle;
22 private String implVendor;
23 private String implVersion;
24 /** This Set contains all the package names associated with this <code>Package</code>. */
25 private Set<String> packageNameSet;
26
27
28 /**
29 * Default constructor.
30 */
31 public PackageInfoImpl() {
32 super();
33 packageNameSet = new TreeSet<String>();
34 }
35 /**
36 * Main constructor.
37 *
38 * @param specTitle The specification title.
39 * @param specVendor The specification vendor.
40 * @param specVersion The specification version.
41 * @param implTitle The implementation title.
42 * @param implVendor The implementation vendor.
43 * @param implVersion The implementation version.
44 */
45 public PackageInfoImpl(String specTitle, String specVendor, String specVersion, String implTitle, String implVendor, String implVersion) {
46 this();
47 this.specTitle = specTitle;
48 this.specVendor = specVendor;
49 this.specVersion = specVersion;
50 this.implTitle = implTitle;
51 this.implVendor = implVendor;
52 this.implVersion = implVersion;
53 }
54 /**
55 * Creates PackageInfo based on the given <code>Package</code>, and
56 * adds the package name to the internal Set of package names.
57 *
58 * @param pckg The <code>Package</code> instance.
59 */
60 public PackageInfoImpl(Package pckg) {
61 this(pckg.getSpecificationTitle(), pckg.getSpecificationVendor(), pckg.getSpecificationVersion(),
62 pckg.getImplementationTitle(), pckg.getImplementationVendor(), pckg.getImplementationVersion());
63 addPackageName(pckg.getName());
64 }
65
66 // public PackageInfoImpl(Manifest manifest) {
67 // this(
68 // manifest.getMainAttributes().getValue(Attributes.Name.SPECIFICATION_TITLE),
69 // manifest.getMainAttributes().getValue(Attributes.Name.SPECIFICATION_VENDOR),
70 // manifest.getMainAttributes().getValue(Attributes.Name.SPECIFICATION_VERSION),
71 // manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_TITLE),
72 // manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VENDOR),
73 // manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION)
74 // );
75 // }
76
77
78 /**
79 * Returns the implementation title.
80 *
81 * @return The implementation title.
82 */
83 public String getImplementationTitle() {
84 return implTitle;
85 }
86 /**
87 * Returns the implementation vendor.
88 *
89 * @return The implementation vendor.
90 */
91 public String getImplementationVendor() {
92 return implVendor;
93 }
94 /**
95 * Returns the implementation version.
96 *
97 * @return The implementation version.
98 */
99 public String getImplementationVersion() {
100 return implVersion;
101 }
102
103
104 /**
105 * Returns the specification title.
106 *
107 * @return The specification title.
108 */
109 public String getSpecificationTitle() {
110 return specTitle;
111 }
112 /**
113 * Returns the specification vendor.
114 *
115 * @return The specification vendor.
116 */
117 public String getSpecificationVendor() {
118 return specVendor;
119 }
120 /**
121 * Returns the specification version.
122 *
123 * @return The specification version.
124 */
125 public String getSpecificationVersion() {
126 return specVersion;
127 }
128
129
130 /**
131 * Returns all the package names assosiated with this <code>Package</code>.
132 *
133 * @return The set with all package names assosiated with this <code>Package</code>.
134 */
135 public Set<String> getNameSet() {
136 return packageNameSet;
137 }
138 /**
139 * Adds the name of the package from the Java language dot notation
140 * ( <code>net.sourceforge.argval.packageinfo</code> ).
141 *
142 * @param name The name of the package.
143 */
144 public void addPackageName(String name) {
145 packageNameSet.add(name);
146 }
147
148 }