Package com.itextpdf.kernel.utils
Class PageRange
- java.lang.Object
-
- com.itextpdf.kernel.utils.PageRange
-
public class PageRange extends java.lang.ObjectClass representing a page range, for instance a page range can contain pages 5, then pages 10 through 15, then page 18, then page 21 and so on.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePageRange.IPageRangePartInner interface for range parts definitionstatic classPageRange.PageRangePartAfterClass for range part containing a range of pages for all pages after a given start page.static classPageRange.PageRangePartAndClass for range part based on several range parts.static classPageRange.PageRangePartOddEvenClass for range part for all even or odd pages.static classPageRange.PageRangePartSequenceClass for range part containing a range of pages represented by a start and an end page.static classPageRange.PageRangePartSingleClass for range part containing a single page.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternSEQUENCE_PATTERNprivate java.util.List<PageRange.IPageRangePart>sequencesprivate static java.util.regex.PatternSINGLE_PAGE_PATTERN
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PageRangeaddPageRangePart(PageRange.IPageRangePart part)Adds any page range part to this page range.PageRangeaddPageSequence(int startPageNumber, int endPageNumber)Adds a page sequence to the range.PageRangeaddSinglePage(int pageNumber)Adds a single page to the range.booleanequals(java.lang.Object obj)java.util.List<java.lang.Integer>getQualifyingPageNums(int nbPages)Gets the list of pages that have been added to the range so far.private static PageRange.IPageRangePartgetRangeObject(java.lang.String rangeDef)inthashCode()booleanisPageInRange(int pageNumber)Checks if a given page is present in the range built so far.
-
-
-
Field Detail
-
SEQUENCE_PATTERN
private static final java.util.regex.Pattern SEQUENCE_PATTERN
-
SINGLE_PAGE_PATTERN
private static final java.util.regex.Pattern SINGLE_PAGE_PATTERN
-
sequences
private final java.util.List<PageRange.IPageRangePart> sequences
-
-
Constructor Detail
-
PageRange
public PageRange()
Constructs an emptyPageRangeinstance.
-
PageRange
public PageRange(java.lang.String pageRange)
Constructs aPageRangeinstance from a range in a string form, for example: "1-12, 15, 45-66". More advanced forms are also available, for example: - "3-" to indicate from page 3 to the last page - "odd" for all odd pages - "even" for all even pages - "3- & odd" for all odd pages starting from page 3 A complete example for pages 1 to 5, page 8 then odd pages starting from page 9: "1-5, 8, odd & 9-".- Parameters:
pageRange- a String of page ranges
-
-
Method Detail
-
getRangeObject
private static PageRange.IPageRangePart getRangeObject(java.lang.String rangeDef)
-
addPageRangePart
public PageRange addPageRangePart(PageRange.IPageRangePart part)
Adds any page range part to this page range. Users may define and plug in custom implementations for behavior not found in the standard library.- Parameters:
part- a custom implementation ofPageRange.IPageRangePart- Returns:
- this range, already modified
-
addPageSequence
public PageRange addPageSequence(int startPageNumber, int endPageNumber)
Adds a page sequence to the range.- Parameters:
startPageNumber- the starting page number of the sequenceendPageNumber- the finishing page number of the sequence- Returns:
- this range, already modified
-
addSinglePage
public PageRange addSinglePage(int pageNumber)
Adds a single page to the range.- Parameters:
pageNumber- the page number to add- Returns:
- this range, already modified
-
getQualifyingPageNums
public java.util.List<java.lang.Integer> getQualifyingPageNums(int nbPages)
Gets the list of pages that have been added to the range so far.- Parameters:
nbPages- number of pages of the document to get the pages, to list only the pages eligible for this document.- Returns:
- the list containing page numbers added to the range matching this document
-
isPageInRange
public boolean isPageInRange(int pageNumber)
Checks if a given page is present in the range built so far.- Parameters:
pageNumber- the page number to check- Returns:
trueif the page is present in this range,falseotherwise
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-