Debian Codegraph @

net/sf/saxon/trans/packages/VersionedPackageName.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.trans.packages;
9
10 import net.sf.saxon.style.PackageVersion;
11 import net.sf.saxon.trans.XPathException;
12
13 /**
14 * This class represents the combination of an XSLT package name (that is, a URI) and a version
15 * number
16 */
17 public class VersionedPackageName {
18
19 public String packageName;
20 public PackageVersion packageVersion;
21
22 public VersionedPackageName(String packageName, PackageVersion version) {
23 this.packageName = packageName;
24 this.packageVersion = version;
25 }
26
27 public VersionedPackageName(String packageName, String version) throws XPathException {
28 this.packageName = packageName;
29 this.packageVersion = new PackageVersion(version);
30 }
31
32 @Override
33 public String toString() {
34 return packageName + " (" + packageVersion.toString() + ")";
35 }
36
37 /**
38 * Compare two package name/version pairs for equality, ignoring the suffix part
39 * of the version number. For example (http://package-one/, 2.1-alpha) compares equal
40 * to (http://package-one/, 2.1-beta)
41 * @param other the other name/version pair
42 * @return true if the values are equal in all respects other than the alphanumeric
43 * suffix of the version number.
44 */
45
46 public boolean equalsIgnoringSuffix(VersionedPackageName other) {
47 return packageName.equals(other.packageName) &&
48 packageVersion.equalsIgnoringSuffix(other.packageVersion);
49 }
50
51 @Override
52 public boolean equals(Object obj) {
53 return obj instanceof VersionedPackageName &&
54 packageName.equals(((VersionedPackageName)obj).packageName) &&
55 packageVersion.equals(((VersionedPackageName)obj).packageVersion);
56 }
57
58 @Override
59 public int hashCode() {
60 return packageName.hashCode() ^ packageVersion.hashCode();
61 }
62 }
63