in src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java [1738:1798]
private void seek() {
if (this.nextGlobal == null && this.globalListIterator.hasNext()) {
this.nextGlobal = this.globalListIterator.next();
}
if (this.nextSpecial == null) {
if (specialIterator != null && !specialIterator.hasNext()) {
specialIterator = null;
}
while (specialIterator == null && key != null) {
// remove selectors and extension
final int lastSlashPos = key.lastIndexOf('/');
final int lastDotPos = key.indexOf('.', lastSlashPos);
if (lastDotPos != -1) {
key = key.substring(0, lastDotPos);
}
final List<MapEntry> special;
if (MapEntries.this.isAllVanityPathEntriesCached() && MapEntries.this.vanityPathsProcessed.get()) {
special = this.resolveMapsMap.get(key);
} else {
special = MapEntries.this.getMapEntryList(key);
}
if (special != null) {
specialIterator = special.iterator();
}
// recurse to the parent
if (key.length() > 1) {
final int lastSlash = key.lastIndexOf("/");
if (lastSlash == 0) {
key = null;
} else {
key = key.substring(0, lastSlash);
}
} else {
key = null;
}
}
if (this.specialIterator != null && this.specialIterator.hasNext()) {
this.nextSpecial = this.specialIterator.next();
}
}
if (this.nextSpecial == null) {
this.next = this.nextGlobal;
this.nextGlobal = null;
} else if (!this.vanityPathPrecedence){
if (this.nextGlobal == null) {
this.next = this.nextSpecial;
this.nextSpecial = null;
} else if (this.nextGlobal.getPattern().length() >= this.nextSpecial.getPattern().length()) {
this.next = this.nextGlobal;
this.nextGlobal = null;
}else {
this.next = this.nextSpecial;
this.nextSpecial = null;
}
} else {
this.next = this.nextSpecial;
this.nextSpecial = null;
}
}