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 int
bitDepth
protected boolean
canceled
java.lang.String
documentID
Field for storing a user-set document identifierprotected Snow.SnbdFileio
fileHandle
int
fileSize
Source file byte countint
fileType
File type ID as specified in Snow.Definesprotected int
height
Page height represented as pixels at input resolutionprotected java.util.Locale
locale
protected int
pageCount
protected boolean
renderFinished
protected boolean
renderStarted
protected int
resolution
Snow.Defines.SnowExt
snowDocType
Internal Document Typeprotected static java.util.Date
systemDate
protected int
width
Page width represented as pixels at input resolution
-
Constructor Summary
Constructors Modifier Constructor Description protected
SnowDoc()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
bitDepth()
protected abstract void
checkPage(int pageNum)
abstract void
decompress(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 formatstatic java.util.Date
getDate()
int
getLastSavedImageSize()
java.lang.String
getLocale()
abstract int
getNumberOfPages()
java.lang.String
getRenderState()
abstract byte[]
getText()
boolean
hasPage(int page)
Check if a page exists on this Documentabstract boolean
hasText()
void
interrupt()
protected void
lambdaCheckPage(int pageNum, java.lang.Runnable formatPageCheckCode)
boolean
numberOfPagesReduced()
protected abstract void
openRaster(Snowbnd snow, int pageNum)
protected abstract byte[]
openVector(int pageNum)
abstract double
pageHeight()
abstract double
pageHeight(int page)
abstract double
pageWidth()
abstract double
pageWidth(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 matchesint
resolution()
void
saveImageAs(byte[] dataOutput, int imgType, int pageNum)
Converts the specified page to the specified format and saves it into a provided buffervoid
saveImageAs(java.lang.String fileSave, int imgType, int pageNum)
Converts the specified page to the specified format and saves it in a file systemSnow.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)
void
setBitDepth(int depth)
void
setPageHeight(int pgHeight)
void
setPageWidth(int pgWidth)
void
setResolution(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
-
-
Method Detail
-
generateImage
public byte[] generateImage(int imgType, int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException
Converts 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.SnowException
java.lang.InterruptedException
-
saveImageAs
public void saveImageAs(java.lang.String fileSave, int imgType, int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException
Converts 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.SnowException
java.lang.InterruptedException
-
saveImageAs
public void saveImageAs(byte[] dataOutput, int imgType, int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException
Converts 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.SnowException
java.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.SnowException
java.lang.InterruptedException
-
openVector
protected abstract byte[] openVector(int pageNum) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException
- Throws:
com.snowbound.rastermaster.exceptions.SnowException
java.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.InterruptedException
com.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.InterruptedException
com.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
-
hasPage
public boolean hasPage(int page) throws java.lang.InterruptedException
Check 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.PageNotFoundException
java.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.PageNotFoundException
java.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.InterruptedException
Searches 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.SnowException
java.lang.InterruptedException
-
redactText
public byte[] redactText(int pageNum, java.lang.String searchString, boolean isCaseSensitive, int redactionColor) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException
Searches 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.SnowException
java.lang.InterruptedException
-
searchRegex
public Snow.SNBD_SEARCH_RESULT[] searchRegex(int pageNum, java.lang.String regexPattern) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException
Searches 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.SnowException
java.lang.InterruptedException
-
redactRegex
public byte[] redactRegex(int pageNum, java.lang.String regexPattern, int redactionColor) throws com.snowbound.rastermaster.exceptions.SnowException, java.lang.InterruptedException
Searches 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.SnowException
java.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.SnowException
java.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()
-
-