Package FLOTF
Class TOParser
- java.lang.Object
-
- FLOTF.TOParser
-
public class TOParser extends java.lang.Object
This 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.String
figureDescription
Stores parsed figure descriptionprivate static java.lang.String
figureNumber
Stores parsed figure numberprivate int
page
Stores page number entered by program argumentsprivate static java.util.ArrayList<java.lang.String[]>
parts
Stores all parsed parts from technical order tableprivate org.apache.pdfbox.pdmodel.PDDocument
technicalOrder
Stores current PDF documentprivate static java.lang.String
technicalOrderNum
Stores parsed technical order numberprivate static java.lang.String
volume
Stores 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 inUtils
private PDFDimensionFinder
findLean()
Creates a PDFDimensionFinder object that finds page offset and row Y-coordinatesprivate void
findTOHeader(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.String
getFigureDescription()
Gets the figure descriptionstatic java.lang.String
getFigureNumber()
Gets the figure numberstatic java.util.ArrayList<java.lang.String[]>
getParts()
Get the parts liststatic java.lang.String
getTechnicalOrderNum()
Gets the technical order numberstatic java.lang.String
getVolume()
Gets the volumevoid
parse()
Reads technical order table Method: Calculate rectangle dimensions based on X coordinates fromcolumnWidths()
and Y coordinates fromPDFDimensionFinder.rowYCoordinates
For every rectangle put the text information intoparts
ArrayList as a String[]static void
setFigureDescription(java.lang.String figureDescription)
Sets the figure descriptionstatic void
setFigureNumber(java.lang.String figureNumber)
Sets the figure numberstatic void
setTechnicalOrderNum(java.lang.String technicalOrderNum)
Sets the technical order numberstatic void
setVolume(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.IOException
Reads technical order table Method: Calculate rectangle dimensions based on X coordinates fromcolumnWidths()
and Y coordinates fromPDFDimensionFinder.rowYCoordinates
For every rectangle put the text information intoparts
ArrayList as a String[]- Throws:
java.io.IOException
- ifTOPage
does not exist
-
findTOHeader
private void findTOHeader(org.apache.pdfbox.pdmodel.PDPage TOPage, org.apache.pdfbox.text.PDFTextStripperByArea pdfStripperArea) throws java.io.IOException
Finds 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 objectPDFTextStripperByArea
that 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
-
-