Package FLOTF
Class TOParser
- java.lang.Object
-
- FLOTF.TOParser
-
public class TOParser extends java.lang.ObjectThis class holds the logic to parse the Technical Order PDF- Author:
- Bernard Chan, Sonali Loomba
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringfigureDescriptionStores parsed figure descriptionprivate static java.lang.StringfigureNumberStores parsed figure numberprivate intpageStores page number entered by program argumentsprivate static java.util.ArrayList<java.lang.String[]>partsStores all parsed parts from technical order tableprivate org.apache.pdfbox.pdmodel.PDDocumenttechnicalOrderStores current PDF documentprivate static java.lang.StringtechnicalOrderNumStores parsed technical order numberprivate static java.lang.StringvolumeStores parsed volume
-
Constructor Summary
Constructors Constructor Description TOParser(int page)TOParser constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.ArrayList<java.lang.Integer>columnWidths()Creates an ArrayList of table column widths from pre-measured dimensions inUtilsprivate PDFDimensionFinderfindLean()Creates a PDFDimensionFinder object that finds page offset and row Y-coordinatesprivate voidfindTOHeader(org.apache.pdfbox.pdmodel.PDPage TOPage, org.apache.pdfbox.text.PDFTextStripperByArea pdfStripperArea)Finds technical order number and volume by creating a header rectangle that only reads above the tablestatic java.lang.StringgetFigureDescription()Gets the figure descriptionstatic java.lang.StringgetFigureNumber()Gets the figure numberstatic java.util.ArrayList<java.lang.String[]>getParts()Get the parts liststatic java.lang.StringgetTechnicalOrderNum()Gets the technical order numberstatic java.lang.StringgetVolume()Gets the volumevoidparse()Reads technical order table Method: Calculate rectangle dimensions based on X coordinates fromcolumnWidths()and Y coordinates fromPDFDimensionFinder.rowYCoordinatesFor every rectangle put the text information intopartsArrayList as a String[]static voidsetFigureDescription(java.lang.String figureDescription)Sets the figure descriptionstatic voidsetFigureNumber(java.lang.String figureNumber)Sets the figure numberstatic voidsetTechnicalOrderNum(java.lang.String technicalOrderNum)Sets the technical order numberstatic voidsetVolume(java.lang.String volume)Sets the volume
-
-
-
Field Detail
-
technicalOrder
private final org.apache.pdfbox.pdmodel.PDDocument technicalOrder
Stores current PDF document
-
page
private final int page
Stores page number entered by program arguments
-
figureNumber
private static java.lang.String figureNumber
Stores parsed figure number
-
figureDescription
private static java.lang.String figureDescription
Stores parsed figure description
-
technicalOrderNum
private static java.lang.String technicalOrderNum
Stores parsed technical order number
-
volume
private static java.lang.String volume
Stores parsed volume
-
parts
private static java.util.ArrayList<java.lang.String[]> parts
Stores all parsed parts from technical order table
-
-
Method Detail
-
parse
public void parse() throws java.io.IOExceptionReads technical order table Method: Calculate rectangle dimensions based on X coordinates fromcolumnWidths()and Y coordinates fromPDFDimensionFinder.rowYCoordinatesFor every rectangle put the text information intopartsArrayList as a String[]- Throws:
java.io.IOException- ifTOPagedoes not exist
-
findTOHeader
private void findTOHeader(org.apache.pdfbox.pdmodel.PDPage TOPage, org.apache.pdfbox.text.PDFTextStripperByArea pdfStripperArea) throws java.io.IOExceptionFinds technical order number and volume by creating a header rectangle that only reads above the table- Parameters:
TOPage- technical order page that is being parsedpdfStripperArea- instance of objectPDFTextStripperByAreathat parses the page- Throws:
java.io.IOException- if TOPage does not exist
-
findLean
private PDFDimensionFinder findLean() throws java.io.IOException
Creates a PDFDimensionFinder object that finds page offset and row Y-coordinates- Returns:
- object of type PDFDimensionFinder
- Throws:
java.io.IOException- if page does not exist
-
columnWidths
private java.util.ArrayList<java.lang.Integer> columnWidths()
Creates an ArrayList of table column widths from pre-measured dimensions inUtils- Returns:
- ArrayList containing table column width dimensions
-
getFigureNumber
public static java.lang.String getFigureNumber()
Gets the figure number- Returns:
- a String specifying the figure number
-
setFigureNumber
public static void setFigureNumber(java.lang.String figureNumber)
Sets the figure number- Parameters:
figureNumber- the figure number
-
getFigureDescription
public static java.lang.String getFigureDescription()
Gets the figure description- Returns:
- a String specifying the figure description
-
setFigureDescription
public static void setFigureDescription(java.lang.String figureDescription)
Sets the figure description- Parameters:
figureDescription- the figure description
-
getTechnicalOrderNum
public static java.lang.String getTechnicalOrderNum()
Gets the technical order number- Returns:
- a String specifying the technical order number
-
setTechnicalOrderNum
public static void setTechnicalOrderNum(java.lang.String technicalOrderNum)
Sets the technical order number- Parameters:
technicalOrderNum- the technical order number
-
getVolume
public static java.lang.String getVolume()
Gets the volume- Returns:
- a String specifying the volume
-
setVolume
public static void setVolume(java.lang.String volume)
Sets the volume- Parameters:
volume- the volume
-
getParts
public static java.util.ArrayList<java.lang.String[]> getParts()
Get the parts list- Returns:
- ArrayList of parts from TO
-
-