// Path: src/main/java/com/github/sunnybat/paxchecker/DataTracker.java
// public class DataTracker {
// 
// 	private static long dataUsed;
// 
// 	/**
// 	 * Adds an amount of data (in bytes) used by the program. This should be called whenever a network
// 	 * connection is made.
// 	 *
// 	 * @param data The amount of data (in bytes) to add to the total data used
// 	 */
// 	public static synchronized void addDataUsed(long data) {
// 		dataUsed += data;
// 	}
// 
// 	/**
// 	 * Gets the amount of data (in bytes) used by the program.
// 	 *
// 	 * @return The amount of data (in bytes) used by the program
// 	 */
// 	public static synchronized long getDataUsed() {
// 		return dataUsed;
// 	}
// 
// 	/**
// 	 * Gets the amount of data in megabytes used by the program. Note that the double only extends out
// 	 * two decimal places.
// 	 *
// 	 * @return The amount of data in megabytes used by the program
// 	 */
// 	public static synchronized double getDataUsedMB() {
// 		return (double) ((int) ((double) getDataUsed() / 1024 / 1024 * 100)) / 100; // *100 to make the double have two extra numbers, round with typecasting to integer, then divide that by 100 and typecast to double to get a double with two decimal places
// 	}
// }
// 
// Path: src/main/java/com/github/sunnybat/paxchecker/Expo.java
// public enum Expo {
// 
// 	WEST, EAST, SOUTH, AUS;
// 
// 	@Override
// 	public String toString() {
// 		String name = super.toString();
// 		return "PAX " + name.charAt(0) + name.toLowerCase().substring(1);
// 	}
// 
// 	public static Expo parseExpo(String expo) {
// 		expo = expo.toLowerCase();
// 		if (expo.contains("prime") || expo.contains("west")) {
// 			return WEST;
// 		} else if (expo.contains("east")) {
// 			return EAST;
// 		} else if (expo.contains("south")) {
// 			return SOUTH;
// 		} else if (expo.contains("aus")) {
// 			return AUS;
// 		} else {
// 			throw new IllegalArgumentException("No expo found");
// 		}
// 	}
// }


import com.github.sunnybat.commoncode.error.ErrorBuilder;
import com.github.sunnybat.paxchecker.DataTracker;
import com.github.sunnybat.paxchecker.Expo;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;
package com.github.sunnybat.paxchecker.browser;


/**
 *
 * @author Sunny
 */
public class PaxsiteReader {

	private Expo expoToCheck;

	/**
	 * Creates a new PaxsiteReader for the given Expo. If toCheck is null, this defaults to Expo.WEST.
	 *
	 * @param toCheck The Expo to check
	 */
	public PaxsiteReader(Expo toCheck) {
		if (toCheck == null) {
			toCheck = Expo.WEST;
		}
		expoToCheck = toCheck;
	}

	/**
	 * Gets the current Showclix link on the registration page.
	 *
	 * @return The first Showclix link found, or "[STATUS]" if an exception occurs
	 */
	public String getCurrentShowclixLink() {
		try {
			URL urlToConnectTo = new URL(getWebsiteLink(expoToCheck) + "/registration");
			String link = findShowclixLink(urlToConnectTo);
			return link;
		} catch (MalformedURLException mue) {
		}
		return "[NoConnection]";
	}

	/**
	 * Finds the first Showclix link on the given page.
	 *
	 * @param urlToConnectTo The URL to connect to
	 * @return The first Showclix link found, or "[STATUS]" if an exception occurs.
	 */
	private String findShowclixLink(URL urlToConnectTo) {
		BufferedReader lineReader = null;
		try {
			String line;
			lineReader = setUpConnection(urlToConnectTo);
			while ((line = lineReader.readLine()) != null) {
// Path: src/main/java/com/github/sunnybat/paxchecker/DataTracker.java
// public class DataTracker {
// 
// 	private static long dataUsed;
// 
// 	/**
// 	 * Adds an amount of data (in bytes) used by the program. This should be called whenever a network
// 	 * connection is made.
// 	 *
// 	 * @param data The amount of data (in bytes) to add to the total data used
// 	 */
// 	public static synchronized void addDataUsed(long data) {
// 		dataUsed += data;
// 	}
// 
// 	/**
// 	 * Gets the amount of data (in bytes) used by the program.
// 	 *
// 	 * @return The amount of data (in bytes) used by the program
// 	 */
// 	public static synchronized long getDataUsed() {
// 		return dataUsed;
// 	}
// 
// 	/**
// 	 * Gets the amount of data in megabytes used by the program. Note that the double only extends out
// 	 * two decimal places.
// 	 *
// 	 * @return The amount of data in megabytes used by the program
// 	 */
// 	public static synchronized double getDataUsedMB() {
// 		return (double) ((int) ((double) getDataUsed() / 1024 / 1024 * 100)) / 100; // *100 to make the double have two extra numbers, round with typecasting to integer, then divide that by 100 and typecast to double to get a double with two decimal places
// 	}
// }
// 
// Path: src/main/java/com/github/sunnybat/paxchecker/Expo.java
// public enum Expo {
// 
// 	WEST, EAST, SOUTH, AUS;
// 
// 	@Override
// 	public String toString() {
// 		String name = super.toString();
// 		return "PAX " + name.charAt(0) + name.toLowerCase().substring(1);
// 	}
// 
// 	public static Expo parseExpo(String expo) {
// 		expo = expo.toLowerCase();
// 		if (expo.contains("prime") || expo.contains("west")) {
// 			return WEST;
// 		} else if (expo.contains("east")) {
// 			return EAST;
// 		} else if (expo.contains("south")) {
// 			return SOUTH;
// 		} else if (expo.contains("aus")) {
// 			return AUS;
// 		} else {
// 			throw new IllegalArgumentException("No expo found");
// 		}
// 	}
// }


// Path: src/main/java/com/github/sunnybat/paxchecker/browser/PaxsiteReader.java
import com.github.sunnybat.commoncode.error.ErrorBuilder;
import com.github.sunnybat.paxchecker.DataTracker;
import com.github.sunnybat.paxchecker.Expo;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;

package com.github.sunnybat.paxchecker.browser;


/**
 *
 * @author Sunny
 */
public class PaxsiteReader {

	private Expo expoToCheck;

	/**
	 * Creates a new PaxsiteReader for the given Expo. If toCheck is null, this defaults to Expo.WEST.
	 *
	 * @param toCheck The Expo to check
	 */
	public PaxsiteReader(Expo toCheck) {
		if (toCheck == null) {
			toCheck = Expo.WEST;
		}
		expoToCheck = toCheck;
	}

	/**
	 * Gets the current Showclix link on the registration page.
	 *
	 * @return The first Showclix link found, or "[STATUS]" if an exception occurs
	 */
	public String getCurrentShowclixLink() {
		try {
			URL urlToConnectTo = new URL(getWebsiteLink(expoToCheck) + "/registration");
			String link = findShowclixLink(urlToConnectTo);
			return link;
		} catch (MalformedURLException mue) {
		}
		return "[NoConnection]";
	}

	/**
	 * Finds the first Showclix link on the given page.
	 *
	 * @param urlToConnectTo The URL to connect to
	 * @return The first Showclix link found, or "[STATUS]" if an exception occurs.
	 */
	private String findShowclixLink(URL urlToConnectTo) {
		BufferedReader lineReader = null;
		try {
			String line;
			lineReader = setUpConnection(urlToConnectTo);
			while ((line = lineReader.readLine()) != null) {
				DataTracker.addDataUsed(line.length());