package de.eightbitboy.hijacr.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import de.eightbitboy.hijacr.data.comic.ComicData;
import de.eightbitboy.hijacr.data.comic.SimpleComicData;

public class ComicRepository {
	private static ComicRepository instance;

	private Map<String, SimpleComicData> comics = new HashMap<String, SimpleComicData>();

	private ComicRepository() {
		initializeComics();
	}

	public static synchronized ComicRepository getInstance() {
		if (instance == null) {
			instance = new ComicRepository();
		}

		return instance;
	}

	private void initializeComics() {
		comics.put("xkcd", new SimpleComicData("XKCD", "http://xkcd.com/", "http://xkcd.com/",
				"div[id=comic] img[src]"));
	}

	public static SimpleComicData getComicData(String key) {
		return getInstance().comics.get(key);
	}

	public static Map<String, SimpleComicData> getAllComicData() {
		return getInstance().comics;
	}

	public static List<SimpleComicData> getComicList() {
		return new ArrayList<SimpleComicData>(getInstance().comics.values());
	}
}

@@ -612,41 +612,264 @@
 %7D%0A%0A%09
-private void initializeComics() %7B
+//TODO a comic might start at position 0 like vgcats!%0A%09private void initializeComics() %7B%0A%09%09comics.put(%22smbc%22, new SimpleComicData(%22SMBC%22, %22http://www.smbc-comics.com/%22, %22http://www%22 +%0A%09%09%09%09%22.smbc-comics.com/index.php?id=%22, %22img%5Bid=comic%5D%22));%0A%09%09//TODO vgcats
 %0A%09%09c

Add comic