package org.maskat.demo;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;

import javax.servlet.http.HttpServletRequest;

public abstract class AbstractValueObj {
	public AbstractValueObj(HttpServletRequest req) {
	};

	public abstract String tempGetXML();

	public String readXMLFromFile(String fileName) {
		URL url = AbstractValueObj.class.getClassLoader().getResource(fileName);
		BufferedReader bfReader = null;
		try {
			bfReader = new BufferedReader(new FileReader(url.getFile()));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		if (bfReader == null)
			return null;
		String result = "";
		String ln = null;
		try {
			ln = bfReader.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}

		while (ln != null) {
			result += ln;
			try {
				ln = bfReader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return result;
	}
}
