Package FLOTF

Class 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 description
      private static java.lang.String figureNumber
      Stores parsed figure number
      private int page
      Stores page number entered by program arguments
      private static java.util.ArrayList<java.lang.String[]> parts
      Stores all parsed parts from technical order table
      private org.apache.pdfbox.pdmodel.PDDocument technicalOrder
      Stores current PDF document
      private static java.lang.String technicalOrderNum
      Stores parsed technical order number
      private 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 in Utils
      private PDFDimensionFinder findLean()
      Creates a PDFDimensionFinder object that finds page offset and row Y-coordinates
      private 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 table
      static java.lang.String getFigureDescription()
      Gets the figure description
      static java.lang.String getFigureNumber()
      Gets the figure number
      static java.util.ArrayList<java.lang.String[]> getParts()
      Get the parts list
      static java.lang.String getTechnicalOrderNum()
      Gets the technical order number
      static java.lang.String getVolume()
      Gets the volume
      void parse()
      Reads technical order table Method: Calculate rectangle dimensions based on X coordinates from columnWidths() and Y coordinates from PDFDimensionFinder.rowYCoordinates For every rectangle put the text information into parts ArrayList as a String[]
      static void setFigureDescription​(java.lang.String figureDescription)
      Sets the figure description
      static void setFigureNumber​(java.lang.String figureNumber)
      Sets the figure number
      static void setTechnicalOrderNum​(java.lang.String technicalOrderNum)
      Sets the technical order number
      static void setVolume​(java.lang.String volume)
      Sets the volume
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • TOParser

        public TOParser​(int page)
                 throws java.io.IOException
        TOParser constructor
        Parameters:
        page - page number of technical order
        Throws:
        java.io.IOException - in case of error opening PDDocument
    • Method Detail

      • parse

        public void parse()
                   throws java.io.IOException
        Reads technical order table Method: Calculate rectangle dimensions based on X coordinates from columnWidths() and Y coordinates from PDFDimensionFinder.rowYCoordinates For every rectangle put the text information into parts ArrayList as a String[]
        Throws:
        java.io.IOException - if TOPage 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 parsed
        pdfStripperArea - instance of object PDFTextStripperByArea 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 in Utils
        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