package de.eightbitboy.hijacr.data.comic;

//TODO use getters and stuff

/**
 * Contains data for a comic whose page URLs can be counted easily.
 */
public class ComicData {
	/**
	 * The comic's title.
	 */
	private String title;

	/**
	 * The comic's website URL.
	 */
	private String url;

	/**
	 * The URL to the first page of the comic.
	 */
	private String firstUrl;

	/**
	 * The URL for a simple comic page, without the page number.
	 * http://www.examplecomic.com/comicId=
	 */
	private String baseUrl;

	/**
	 * The number of the first comic. It is only used when baseUrl is given.
	 */
	private int firstNumber;

	/**
	 * The jsoup query for getting the comic img element.
	 */
	private String imageQuery;

	/**
	 * The jsoup query for getting the anchor with the href to the previous page.
	 */
	private String previousQuery;

	/**
	 * The jsoup query for getting the anchor with the href to the next page.
	 */
	private String nextQuery;

	private boolean simple = false;

	//TODO for simple
	public ComicData(String title, String url, String baseUrl, int firstNumber, String
			imageQuery) {
		this.title = title;
		this.url = url;
		this.baseUrl = baseUrl;
		this.firstNumber = firstNumber;
		this.imageQuery = imageQuery;
		this.simple = true;
	}

	//TODO for full
	public ComicData() {
		this.simple = false;
	}

	public String getTitle() {
		return title;
	}

	public String getUrl() {
		return url;
	}

	public String getFirstUrl() {
		return firstUrl;
	}

	public String getBaseUrl() {
		return baseUrl;
	}

	public int getFirstNumber() {
		return firstNumber;
	}

	public String getImageQuery() {
		return imageQuery;
	}

	public String getPreviousQuery() {
		return previousQuery;
	}

	public String getNextQuery() {
		return nextQuery;
	}

	public boolean isSimple() {
		return simple;
	}

	//TODO improve cleanup
	public String getCleanUrl() {
		String cleanUrl;
		cleanUrl = url.replaceAll("/", "");
		cleanUrl = cleanUrl.replaceAll("http", "");
		cleanUrl = cleanUrl.replaceAll(":", "");
		cleanUrl = cleanUrl.replaceAll("www.", "");
		return cleanUrl;
	}

	@Override
	public boolean equals(Object o) {
		return o instanceof ComicData && title.equals(((ComicData) o).getTitle());
	}
}

@@ -984,24 +984,253 @@
 %0A%0A%09/
-/TODO for simple
+**%0A%09 * Define %22simple%22 a comic which uses an URL which ends with a%0A%09 * number that can be counted and incremented for accessing comic pages.%0A%09 *%0A%09 * @param title%0A%09 * @param url%0A%09 * @param baseUrl%0A%09 * @param firstNumber%0A%09 * @param imageQuery%0A%09 */
 %0A%09pu
@@ -1491,44 +1491,515 @@
 %0A%0A%09/
-/TODO for full%0A%09public ComicData() %7B
+**%0A%09 * Define a comic. The URLs for accessing comic pages must be parsed from a page.%0A%09 *%0A%09 * @param title%0A%09 * @param url%0A%09 * @param firstUrl%0A%09 * @param imageQuery%0A%09 * @param previousQuery%0A%09 * @param nextQuery%0A%09 */%0A%09public ComicData(String title, String url, String firstUrl, String imageQuery, String%0A%09%09%09previousQuery, String nextQuery) %7B%0A%09%09this.title = title;%0A%09%09this.url = url;%0A%09%09this.firstUrl = firstUrl;%0A%09%09this.imageQuery = imageQuery;%0A%09%09this.previousQuery = previousQuery;%0A%09%09this.nextQuery = nextQuery;
 %0A%09%09t

Implement new constructor