Package com.snowbound.rastermaster
Class SnowDoc
- java.lang.Object
-
- com.snowbound.rastermaster.SnowDoc
-
- All Implemented Interfaces:
java.lang.Runnable
public abstract class SnowDoc extends java.lang.Object implements java.lang.Runnable
-
-
Field Summary
Fields Modifier and Type Field Description protected intbitDepthprotected booleancanceledjava.lang.StringdocumentIDField for storing a user-set document identifierprotected interrorprotected Snow.SnbdFileiofileHandleintfileSizeSource file byte countintfileTypeFile type ID as specified in Snow.Definesprotected intheightPage height represented as pixels at input resolutionprotected java.util.Localelocaleprotected intpageCountprotected booleanrenderFinishedprotected booleanrenderStartedprotected intresolutionSnow.Defines.SnowExtsnowDocTypeInternal Document Typeprotected static java.util.DatesystemDateprotected intwidthPage width represented as pixels at input resolution
-
Constructor Summary
Constructors Modifier Constructor Description protectedSnowDoc()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intbitDepth()protected abstract voidcheckPage(int pageNum)protected byte[]convertToVectorFormat(int vectorFormat, int pageIndex, Snowbnd snow)abstract voiddecompress(Snow.SnbdFileio fileHandle)Parses and lays out content on all pages of the document represented by fileHandlebyte[]extractText(int pageNum)byte[]generateImage(int imgType, int pageNum)Converts the specified page to the specified formatbyte[]generateImage(int imgType, int pageNum, int localResolution)static java.util.DategetDate()intgetLastSavedImageSize()java.lang.StringgetLocale()abstract intgetNumberOfPages()java.lang.StringgetRenderState()abstract byte[]getText()booleanhasPage(int page)Check if a page exists on this Documentabstract booleanhasText()booleanhasText(int page)Check if page has textvoidinterrupt()protected voidlambdaCheckPage(int pageNum, java.lang.Runnable formatPageCheckCode)booleannumberOfPagesReduced()protected abstract voidopenRaster(Snowbnd snow, int pageNum)protected abstract byte[]openVector(int pageNum)abstract doublepageHeight()abstract doublepageHeight(int page)abstract doublepageWidth()abstract doublepageWidth(int page)byte[]redactRegex(int pageNum, java.lang.String regexPattern, int redactionColor)Searches the specified page for regular expression matches and redacts any matchesbyte[]redactText(int pageNum, java.lang.String searchString, boolean isCaseSensitive, int redactionColor)Searches the specified page for text and redacts any matchesintresolution()voidsaveImageAs(byte[] dataOutput, int imgType, int pageNum)Converts the specified page to the specified format and saves it into a provided buffervoidsaveImageAs(java.lang.String fileSave, int imgType, int pageNum)Converts the specified page to the specified format and saves it in a file systemprotected voidsaveToVectorFormat(byte[] outputBuffer, int vectorFormat, int pageIndex, Snowbnd snow)protected voidsaveToVectorFormat(java.lang.String fileSave, int vectorFormat, int pageIndex, Snowbnd snow)Snow.SNBD_SEARCH_RESULT[]searchRegex(int pageNum, java.lang.String regexPattern)Searches a page of this document for text that matches the provided regular expressionSnow.SNBD_SEARCH_RESULT[]searchRegexFromBuffer(byte[] buff, java.lang.String regexPattern, int[] error)Snow.SNBD_SEARCH_RESULT[]searchText(int pageNum, java.lang.String searchString, boolean isCaseSensitive)Searches a page of this document for a string of textSnow.SNBD_SEARCH_RESULT[]searchTextFromBuffer(byte[] buff, java.lang.String text, int case_sense, int[] error)voidsetBitDepth(int depth)voidsetPageHeight(int pgHeight)voidsetPageWidth(int pgWidth)voidsetResolution(int resolution)Sets pixels per inch for document layout.
-
-
-
Field Detail
-
snowDocType
public Snow.Defines.SnowExt snowDocType
Internal Document Type
-
documentID
public java.lang.String documentID
Field for storing a user-set document identifier
-
fileType
public int fileType
File type ID as specified in Snow.Defines
-
fileSize
public int fileSize
Source file byte count
-
resolution
protected int resolution
-
bitDepth
protected int bitDepth
-
height
protected int height
Page height represented as pixels at input resolution
-
width
protected int width
Page width represented as pixels at input resolution
-
pageCount
protected int pageCount
-
fileHandle
protected Snow.SnbdFileio fileHandle
-
locale
protected java.util.Locale locale
-
systemDate
protected static java.util.Date systemDate
-
renderStarted
protected volatile boolean renderStarted
-
renderFinished
protected volatile boolean renderFinished
-
canceled
protected volatile boolean canceled
-
error
protected int error
-
-
Method Detail
-
generateImage
public byte[] generateImage(int imgType, int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedExceptionConverts the specified page to the specified format- Parameters:
imgType- export format as specified in DefinespageNum- page to export- Returns:
- buffer containing converted page
- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
generateImage
public byte[] generateImage(int imgType, int pageNum, int localResolution) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
convertToVectorFormat
protected byte[] convertToVectorFormat(int vectorFormat, int pageIndex, Snowbnd snow) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
saveImageAs
public void saveImageAs(java.lang.String fileSave, int imgType, int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedExceptionConverts the specified page to the specified format and saves it in a file system- Parameters:
fileSave- path to save locationimgType- export format as specified in DefinespageNum- page to export- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
saveToVectorFormat
protected void saveToVectorFormat(java.lang.String fileSave, int vectorFormat, int pageIndex, Snowbnd snow) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
saveImageAs
public void saveImageAs(byte[] dataOutput, int imgType, int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedExceptionConverts the specified page to the specified format and saves it into a provided buffer- Parameters:
dataOutput- byte array to save exported page inimgType- export format as specified in DefinespageNum- page to export- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
saveToVectorFormat
protected void saveToVectorFormat(byte[] outputBuffer, int vectorFormat, int pageIndex, Snowbnd snow) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
openRaster
protected abstract void openRaster(Snowbnd snow, int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException
- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
openVector
protected abstract byte[] openVector(int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
decompress
public abstract void decompress(Snow.SnbdFileio fileHandle)
Parses and lays out content on all pages of the document represented by fileHandle- Parameters:
fileHandle- SnbdFileio object that represents the document to decompress
-
getNumberOfPages
public abstract int getNumberOfPages() throws java.lang.InterruptedException- Returns:
- number of pages in the document
- Throws:
java.lang.InterruptedException
-
pageHeight
public abstract double pageHeight() throws java.lang.InterruptedException- Returns:
- height of the first page
- Throws:
java.lang.InterruptedException
-
pageHeight
public abstract double pageHeight(int page) throws com.snowbound.rastermaster.exceptions.PageNotFoundException, java.lang.InterruptedException- Parameters:
page- index of page to get the height of- Returns:
- height of the specified page
- Throws:
java.lang.InterruptedExceptioncom.snowbound.rastermaster.exceptions.PageNotFoundException
-
pageWidth
public abstract double pageWidth() throws java.lang.InterruptedException- Returns:
- width of the first page
- Throws:
java.lang.InterruptedException
-
pageWidth
public abstract double pageWidth(int page) throws com.snowbound.rastermaster.exceptions.PageNotFoundException, java.lang.InterruptedException- Parameters:
page- index of page to get the width of- Returns:
- width of the specified page
- Throws:
java.lang.InterruptedExceptioncom.snowbound.rastermaster.exceptions.PageNotFoundException
-
hasText
public abstract boolean hasText()
- Returns:
- true if the document contains text
-
getText
public abstract byte[] getText()
- Returns:
- String (as byte[]) representation of all text in the document
-
hasText
public boolean hasText(int page)
Check if page has text- Parameters:
page- Zero-Indexed page number.- Returns:
- True if page has text. False otherwise
-
hasPage
public boolean hasPage(int page) throws java.lang.InterruptedExceptionCheck if a page exists on this Document- Parameters:
page- Zero-Indexed page number.- Returns:
- True if page exists. False otherwise
- Throws:
java.lang.InterruptedException- if snowdoc is on a thread, and that thread has been interrupted.
-
checkPage
protected abstract void checkPage(int pageNum) throws com.snowbound.rastermaster.exceptions.PageNotFoundException, java.lang.InterruptedException- Throws:
com.snowbound.rastermaster.exceptions.PageNotFoundExceptionjava.lang.InterruptedException
-
numberOfPagesReduced
public boolean numberOfPagesReduced() throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
lambdaCheckPage
protected void lambdaCheckPage(int pageNum, java.lang.Runnable formatPageCheckCode) throws com.snowbound.rastermaster.exceptions.PageNotFoundException, java.lang.InterruptedException- Throws:
com.snowbound.rastermaster.exceptions.PageNotFoundExceptionjava.lang.InterruptedException
-
searchText
public Snow.SNBD_SEARCH_RESULT[] searchText(int pageNum, java.lang.String searchString, boolean isCaseSensitive) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedExceptionSearches a page of this document for a string of text- Parameters:
pageNum- index of page to searchsearchString- string to search forisCaseSensitive- is the search string case sensitive?- Returns:
- SNBD_SEARCH_RESULT[] of any matches found
- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
redactText
public byte[] redactText(int pageNum, java.lang.String searchString, boolean isCaseSensitive, int redactionColor) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedExceptionSearches the specified page for text and redacts any matches- Parameters:
pageNum- index of page to searchsearchString- string to search forisCaseSensitive- is the search string case sensitive?redactionColor- color to use for redaction painting- Returns:
- byte[] representation of the page's redacted SNBD_EXTSTREAM
- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
searchRegex
public Snow.SNBD_SEARCH_RESULT[] searchRegex(int pageNum, java.lang.String regexPattern) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedExceptionSearches a page of this document for text that matches the provided regular expression- Parameters:
pageNum- index of page to searchregexPattern- regular expression to search for- Returns:
- SNBD_SEARCH_RESULT[] of any matches found
- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
redactRegex
public byte[] redactRegex(int pageNum, java.lang.String regexPattern, int redactionColor) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedExceptionSearches the specified page for regular expression matches and redacts any matches- Parameters:
pageNum- index of page to searchregexPattern- regular expression to search forredactionColor- color to use for redaction painting- Returns:
- byte[] representation of the page's redacted SNBD_EXTSTREAM
- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
searchTextFromBuffer
public Snow.SNBD_SEARCH_RESULT[] searchTextFromBuffer(byte[] buff, java.lang.String text, int case_sense, int[] error)- Parameters:
buff- SNBD_EXTSTREAM buffer of the page to searchtext- String to search forcase_sense- is the search string case sensitive?error- container for return values- Returns:
- SNBD_SEARCH_RESULT[] of any matches
-
searchRegexFromBuffer
public Snow.SNBD_SEARCH_RESULT[] searchRegexFromBuffer(byte[] buff, java.lang.String regexPattern, int[] error)- Parameters:
buff- SNBD_EXTSTREAM buffer of the page to searchregexPattern- regular expression to search forerror- container for return values- Returns:
- SNBD_SEARCH_RESULT[] of any matches
-
extractText
public byte[] extractText(int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException- Parameters:
pageNum- page to extract- Returns:
- SNBD_EXTSTREAM (as byte[]) representation of specified page
- Throws:
com.snowbound.rastermaster.exceptions.SnowExceptionjava.lang.InterruptedException
-
getDate
public static java.util.Date getDate()
-
getLocale
public java.lang.String getLocale()
-
setPageHeight
public void setPageHeight(int pgHeight)
- Parameters:
pgHeight- overrides internal page height during image generation
-
setPageWidth
public void setPageWidth(int pgWidth)
- Parameters:
pgWidth- overrides internal page width during image generation
-
bitDepth
public int bitDepth()
- Returns:
- number of bits per pixel in raster output
-
setBitDepth
public void setBitDepth(int depth)
- Parameters:
depth- sets number of bits per pixel to use during raster output
-
resolution
public int resolution()
- Returns:
- pixels per inch for document layout
-
setResolution
public void setResolution(int resolution)
Sets pixels per inch for document layout. Must be set before decompress() to effect output.- Parameters:
resolution- pixels per inch to use for document layout.
-
getLastSavedImageSize
public int getLastSavedImageSize()
- Returns:
- The result of the last internally performed Snowbnd operation
-
interrupt
public void interrupt()
-
getRenderState
public java.lang.String getRenderState()
-
-