public Tag addTagAt(final int pos, final boolean serverTagOnly) { final Tag tag=Tag.getTagAtUncached(source,pos,serverTagOnly); if (serverTagOnly && tag==null) return null; // don't add null to cache if we were only looking for server tags allTagTypesSubCache.addTagAt(pos,tag); if (tag==null) return null; final TagType tagType=tag.getTagType(); for (int i=1; i<subCaches.length; i++) { if (tagType==subCaches[i].tagType) { subCaches[i].addTagAt(pos,tag); return tag; } } return tag; }
private Tag getPreviousTag(CacheEntry previousCacheEntry, int pos, CacheEntry nextCacheEntry) { // previousCacheEntry.pos < pos <= nextCacheEntry.pos while (true) { if (!nextCacheEntry.previousCached) { final Tag tag=Tag.getPreviousTagUncached(cache.source,pos,tagType,previousCacheEntry.pos); // if useAllTypesCache is true, automatically adds tag to all caches if one is found, and maybe some unregistered tags along the way. if (tag!=null) { if (!cache.source.useAllTypesCache) addTagAt(tag.begin,tag); // have to add tag manually if useAllTypesCache is false return tag; } } if (previousCacheEntry==bof) return null; if (previousCacheEntry.tag!=null && previousCacheEntry.tag.includeInSearch()) return previousCacheEntry.tag; pos=previousCacheEntry.pos-1; previousCacheEntry=getPrevious(nextCacheEntry=previousCacheEntry); } }
private Tag getNextTag(CacheEntry previousCacheEntry, int pos, CacheEntry nextCacheEntry) { // previousCacheEntry.pos <= pos < nextCacheEntry.pos while (true) { if (!previousCacheEntry.nextCached) { final Tag tag=Tag.getNextTagUncached(cache.source,pos,tagType,nextCacheEntry.pos); // if useAllTypesCache is true, automatically adds tag to caches if one is found, and maybe some unregistered tags along the way. if (tag!=null) { if (!cache.source.useAllTypesCache) addTagAt(tag.begin,tag); // have to add tag manually if useAllTypesCache is false return tag; } } if (nextCacheEntry==eof) return null; if (nextCacheEntry.tag!=null && nextCacheEntry.tag.includeInSearch()) return nextCacheEntry.tag; pos=nextCacheEntry.pos+1; nextCacheEntry=getNext(previousCacheEntry=nextCacheEntry); } }
cache.addTagAt(pos,false); // this pos has never been checked before, so add it to all relevant SubCaches (a null or unregistered tag entry is always added to this SubCache) else addTagAt(pos,null); // all we know is that the pos doesn't contain a tag of this SubCache's type, so add a null entry to this SubCache only.
cache.addTagAt(pos,false); // this pos has never been checked before, so add it to all relevant SubCaches (a null or unregistered tag entry is always added to this SubCache) else addTagAt(pos,null); // all we know is that the pos doesn't contain a tag of this SubCache's type, so add a null entry to this SubCache only.