A Better Approach
- Apr 27, 2017
- 3 min read
Parsing is a programming tool used to convert the value of one data type to a value of another data type. In other words a parser is a small part of a program that takes a physical representation of some data and converts it into a memory form which can be used in other parts of a program. The idea of a parser can be seen in a Java compiler. The Java compiler parses source code written in .java file and transforms it into a language that the computer will understand. For my program I had to figure out a method to get into an email and convert the message into a readable Java object.
My goal was to parse an e-mail message into a MySQL database and extract the required information from a Java program. Initially my idea was to use code from an IMAP (Internet Message Access Protocol) library, which is a universal protocol used by e-mail clients to receive messages from a main mail server. It also allows the client to access and manipulate mailboxes through remote message folders, functionally equivalent to local folders on a computer. The version I looked into is called IMAP4rev1. This version allows clients to manipulate mailboxes, parse through email messages, and selectively search for messages.
The IMAPrev1 works in a very interesting way. At the most basic level, a message is a series of characters, which can be interpreted in ASCII. Messages are split into lines of characters and each line is a series of characters which are limited by two special characters, the carriage return (CR) character( ASCII value 13) and the line feed (LF) character (ASCII value 10). Furthermore, messages consist of header fields, which consist of the sender/recipient information along with a time stamp, and a subject and a message body. The parser converts the information from the header and the body into CR and LF ASCII values, which the computer is able to process. Then a programmer is able to move this data into a database and use it in a program. However the problem with IMAP was getting authentication to view and manipulate mailboxes for Gmail and other email clients without actually being a developer for one of these clients.
I spent the week learning to implement an IMAP Java parser but found what I think may be a more efficient solution to parsing from the Gmail client. I found a Google Calendar API and started implementing it in an online Software Development Kit (SDK) called Firebase. Firebase is a mobile and web application development platform which can be used through a Google account. I created a project in Firebase called Senior Project, where I am able to make a web application out of my original project idea. The database I had created in MySQL Workbench is now no longer needed because the Firebase SDK provides a robust database. It also comes with other extremely useful features such as an authentication step which is already linked to my Google account, and a testing and coding platform and crash reporting step. The Firebase SDK solves the authentication problem I had with IMAP.
Currently I am trying to authenticate my own email account and see if I can access and manipulate my mailbox. However, to get authentication on Firebase, I need to have a web page, which will act as my BETA web page for testing. To make this web page I will need to use the server I had set up earlier on XAMPP and develop a simple web page in JavaScript or HTML. I will write the code for this web page in Notepad and will run it in the same folder as the localhost from XAMPP. This will give me a physical representation of what is actually happening in my program.
Also it would extremely helpful if you could email sortingalgorithms1@gmail.com saying “Hey what’s up, we should meet.” I will respond to you and hopefully we can agree upon a staged time and place to meet. This would be easier than having you sort through your personal conversations.
This would be extremely helpful! Thank you for reading!


Comments