/** * Returns a mapping with 0-based page indices as keys and corresponding * page labels as values as an array. The array will have exactly as much * entries as the document has pages. * * @return an array mapping from 0-based page indices to labels. */ public String[] getLabelsByPageIndices() { final String[] map = new String[doc.getNumberOfPages()]; computeLabels(new LabelHandler() { @Override public void newLabel(int pageIndex, String label) { if(pageIndex < doc.getNumberOfPages()) { map[pageIndex] = label; } } }); return map; }
/** * Returns a mapping with computed page labels as keys and corresponding * 0-based page indices as values. The returned map will contain at most as * much entries as the document has pages. * * <p> * <strong>NOTE:</strong> If the document contains duplicate page labels, * the returned map will contain <em>less</em> entries than the document has * pages. The page index returned in this case is the <em>highest</em> index * among all pages sharing the same label. * </p> * * @return a mapping from labels to 0-based page indices. */ public Map<String, Integer> getPageIndicesByLabels() { final Map<String, Integer> labelMap = new HashMap<>(doc.getNumberOfPages()); computeLabels(new LabelHandler() { @Override public void newLabel(int pageIndex, String label) { labelMap.put(label, pageIndex); } }); return labelMap; }
/** * Returns a mapping with 0-based page indices as keys and corresponding * page labels as values as an array. The array will have exactly as much * entries as the document has pages. * * @return an array mapping from 0-based page indices to labels. */ public String[] getLabelsByPageIndices() { final String[] map = new String[doc.getNumberOfPages()]; computeLabels(new LabelHandler() { @Override public void newLabel(int pageIndex, String label) { if(pageIndex < doc.getNumberOfPages()) { map[pageIndex] = label; } } }); return map; }
/** * Returns a mapping with 0-based page indices as keys and corresponding * page labels as values as an array. The array will have exactly as much * entries as the document has pages. * * @return an array mapping from 0-based page indices to labels. */ public String[] getLabelsByPageIndices() { final String[] map = new String[doc.getNumberOfPages()]; computeLabels(new LabelHandler() { @Override public void newLabel(int pageIndex, String label) { if(pageIndex < doc.getNumberOfPages()) { map[pageIndex] = label; } } }); return map; }
/** * Returns a mapping with computed page labels as keys and corresponding * 0-based page indices as values. The returned map will contain at most as * much entries as the document has pages. * * <p> * <strong>NOTE:</strong> If the document contains duplicate page labels, * the returned map will contain <em>less</em> entries than the document has * pages. The page index returned in this case is the <em>highest</em> index * among all pages sharing the same label. * </p> * * @return a mapping from labels to 0-based page indices. */ public Map<String, Integer> getPageIndicesByLabels() { final Map<String, Integer> labelMap = new HashMap<String, Integer>(doc.getNumberOfPages()); computeLabels(new LabelHandler() { @Override public void newLabel(int pageIndex, String label) { labelMap.put(label, pageIndex); } }); return labelMap; }
/** * Returns a mapping with computed page labels as keys and corresponding * 0-based page indices as values. The returned map will contain at most as * much entries as the document has pages. * * <p> * <strong>NOTE:</strong> If the document contains duplicate page labels, * the returned map will contain <em>less</em> entries than the document has * pages. The page index returned in this case is the <em>highest</em> index * among all pages sharing the same label. * </p> * * @return a mapping from labels to 0-based page indices. */ public Map<String, Integer> getPageIndicesByLabels() { final Map<String, Integer> labelMap = new HashMap<>(doc.getNumberOfPages()); computeLabels(new LabelHandler() { @Override public void newLabel(int pageIndex, String label) { labelMap.put(label, pageIndex); } }); return labelMap; }