in indexer-core/src/main/java/org/apache/maven/index/artifact/M1GavCalculator.java [43:117]
public Gav pathToGav(String str) {
try {
String s = str.startsWith("/") ? str.substring(1) : str;
int n1 = s.lastIndexOf('/');
if (n1 == -1) {
return null;
}
int n2 = s.lastIndexOf('/', n1 - 1);
if (n2 == -1) {
return null;
}
String g = s.substring(0, n2).replace('/', '.');
String middle = s.substring(n2 + 1, n1);
String n = s.substring(n1 + 1);
String classifier = null;
if ("java-sources".equals(middle)) {
classifier = "sources";
} else if ("javadocs".equals(middle)) {
classifier = "javadoc";
} else if ("ejbs".equals(middle)
&& (n.endsWith("client.jar") || n.endsWith("client.jar.sha1") || n.endsWith("client.jar.md5"))) {
classifier = "client";
}
boolean checksum = false;
Gav.HashType checksumType = null;
if (s.endsWith(".md5")) {
checksum = true;
checksumType = Gav.HashType.md5;
s = s.substring(0, s.length() - 4);
} else if (s.endsWith(".sha1")) {
checksum = true;
checksumType = Gav.HashType.sha1;
s = s.substring(0, s.length() - 5);
}
if (s.endsWith("maven-metadata.xml")) {
return null;
}
String ext = s.substring(s.lastIndexOf('.') + 1);
Matcher m = PAT1.matcher(n);
if (m.matches()) {
String a = m.group(1);
String version = m.group(2);
if (classifier != null) {
version = version.substring(0, version.length() - (classifier.length() + 1));
}
return new Gav(g, a, version, classifier, ext, null, null, n, checksum, checksumType, false, null);
} else {
m = PAT2.matcher(n);
if (m.matches()) {
String a = m.group(1);
String version = m.group(2);
if (classifier != null) {
version = version.substring(0, version.length() - (classifier.length() + 1));
}
return new Gav(g, a, version, classifier, ext, null, null, n, checksum, checksumType, false, null);
} else {
return null;
}
}
} catch (IndexOutOfBoundsException e) {
return null;
}
}