cleanup in AccountsText

This commit is contained in:
millmanorama 2017-09-24 21:17:39 +02:00
parent 838ae0901a
commit e7cc636e17

View File

@ -55,6 +55,8 @@ class AccountsText implements IndexedText {
private static final Logger logger = Logger.getLogger(AccountsText.class.getName()); private static final Logger logger = Logger.getLogger(AccountsText.class.getName());
private static final boolean DEBUG = (Version.getBuildType() == Version.Type.DEVELOPMENT); private static final boolean DEBUG = (Version.getBuildType() == Version.Type.DEVELOPMENT);
private static final String CCN_REGEX = "(%?)(B?)([0-9][ \\-]*?){12,19}(\\^?)";
private static final String HIGHLIGHT_PRE = "<span style='background:yellow'>"; //NON-NLS private static final String HIGHLIGHT_PRE = "<span style='background:yellow'>"; //NON-NLS
private static final String ANCHOR_NAME_PREFIX = AccountsText.class.getName() + "_"; private static final String ANCHOR_NAME_PREFIX = AccountsText.class.getName() + "_";
@ -80,23 +82,24 @@ class AccountsText implements IndexedText {
private int numberPagesForFile = 0; private int numberPagesForFile = 0;
private Integer currentPage = 0; private Integer currentPage = 0;
/* /**
* map from page/chunk to number of hits. value is 0 if not yet known. * map from page/chunk to number of hits. value is 0 if not yet known.
*/ */
private final TreeMap<Integer, Integer> numberOfHitsPerPage = new TreeMap<>(); private final TreeMap<Integer, Integer> numberOfHitsPerPage = new TreeMap<>();
/*
/**
* set of pages, used for iterating back and forth. Only stores pages with * set of pages, used for iterating back and forth. Only stores pages with
* hits * hits
*/ */
private final Set<Integer> pages = numberOfHitsPerPage.keySet(); private final Set<Integer> pages = numberOfHitsPerPage.keySet();
/*
/**
* map from page/chunk number to current hit on that page. * map from page/chunk number to current hit on that page.
*/ */
private final HashMap<Integer, Integer> currentHitPerPage = new HashMap<>(); private final HashMap<Integer, Integer> currentHitPerPage = new HashMap<>();
AccountsText(long objectID, BlackboardArtifact artifact) { AccountsText(long objectID, BlackboardArtifact artifact) {
this(objectID, Arrays.asList(artifact)); this(objectID, Arrays.asList(artifact));
} }
@NbBundle.Messages({ @NbBundle.Messages({
@ -201,11 +204,7 @@ class AccountsText implements IndexedText {
@Override @Override
public int currentItem() { public int currentItem() {
if (this.currentHitPerPage.containsKey(currentPage)) { currentHitPerPage.getOrDefault(currentPage, 0);
return currentHitPerPage.get(currentPage);
} else {
return 0;
}
} }
/** /**
@ -261,10 +260,11 @@ class AccountsText implements IndexedText {
isPageInfoLoaded = true; isPageInfoLoaded = true;
} }
private static final String CCN_REGEX = "(%?)(B?)([0-9][ \\-]*?){12,19}(\\^?)";
/** /**
* Load the paging info from the QueryResults object. * Load the paging info from the QueryResults object.
*
* @param hits The QueryResults to load the paging info from.
*/ */
synchronized private void loadPageInfoFromHits(QueryResults hits) { synchronized private void loadPageInfoFromHits(QueryResults hits) {
//organize the hits by page, filter as needed //organize the hits by page, filter as needed
@ -370,9 +370,6 @@ class AccountsText implements IndexedText {
@Override @Override
public int getNumberHits() { public int getNumberHits() {
if (!this.numberOfHitsPerPage.containsKey(this.currentPage)) { return numberOfHitsPerPage.getOrDefault(currentPage, 0);
return 0;
}
return this.numberOfHitsPerPage.get(this.currentPage);
} }
} }