public SubCache(final Cache cache, final TagType tagType) { this.cache=cache; this.tagType=tagType; array[0]=bof=new CacheEntry(0,-1,null,false,false); array[1]=eof=new CacheEntry(1,cache.getSourceLength(),null,false,false); }
public Tag getTagAt(final int pos, final boolean serverTagOnly) { // This must only be called on allTagTypesSubCache (ie tagType==null) if (cache.getSourceLength()==0) return null; if (pos<0 || pos>=cache.getSourceLength()) return null; final int index=getIndexOfPos(pos); final CacheEntry cacheEntry=array[index]; if (cacheEntry.pos==pos) { if (serverTagOnly && !cacheEntry.tag.getTagType().isServerTag()) return null; return cacheEntry.tag; } if (cacheEntry.previousCached) return null; return cache.addTagAt(pos,serverTagOnly); }
public Tag getPreviousTag(final int pos) { // Note that this method never returns tags for which tag.includInSearch() is false, so separate caching of unregistered tags won't work. if (cache.getSourceLength()==0) return null; if (pos<0 || pos>=cache.getSourceLength()) return null; int index=getIndexOfPos(pos); final CacheEntry cacheEntry=array[index]; final Tag tag; if (cacheEntry.pos==pos && cacheEntry.tag!=null && cacheEntry.tag.includeInSearch()) return cacheEntry.tag; tag=getPreviousTag(getPrevious(cacheEntry),pos,cacheEntry); addPreviousTag(pos,tag); return tag; }
public Tag getNextTag(final int pos) { // Note that this method never returns tags for which tag.includInSearch() is false, so separate caching of unregistered tags won't work. if (cache.getSourceLength()==0) return null; if (pos<0 || pos>=cache.getSourceLength()) return null; int index=getIndexOfPos(pos); final CacheEntry cacheEntry=array[index]; final Tag tag; if (cacheEntry.pos==pos) { if (cacheEntry.tag!=null && cacheEntry.tag.includeInSearch()) return cacheEntry.tag; tag=getNextTag(cacheEntry,pos,getNext(cacheEntry)); } else { tag=getNextTag(getPrevious(cacheEntry),pos,cacheEntry); } addNextTag(pos,tag); return tag; }