in src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java [57:102]
public SlingRequestPathInfo(Resource r) {
// ensure the resource
if (r == null) {
throw new NullPointerException("resource");
}
this.resource = r;
this.resourcePath = r.getResourceMetadata().getResolutionPath();
// the extra path in the request URI
String pathToParse = r.getResourceMetadata().getResolutionPathInfo();
if (pathToParse == null) {
pathToParse = "";
}
// separate selectors/ext from the suffix
int firstSlash = pathToParse.indexOf('/');
String pathToSplit;
if (firstSlash < 0) {
pathToSplit = pathToParse;
suffix = null;
} else {
pathToSplit = pathToParse.substring(0, firstSlash);
suffix = pathToParse.substring(firstSlash);
}
int lastDot = pathToSplit.lastIndexOf('.');
if (lastDot <= 1) {
// no selectors if only extension exists or selectors is empty
selectorString = null;
selectors = NO_SELECTORS;
} else {
// no selectors if splitting would give an empty array
String tmpSel = pathToSplit.substring(1, lastDot);
selectors = tmpSel.split("\\.");
selectorString = (selectors.length > 0) ? tmpSel : null;
}
// extension only if lastDot is not trailing
extension = (lastDot + 1 < pathToSplit.length()) ? pathToSplit.substring(lastDot + 1) : null;
}