package djmania.sandbox.old;

import java.io.FileInputStream;
import java.util.Scanner;
import java.util.ArrayList;

import djmania.sandbox.old.FileTools;

/**
 * StepMania file reader.
 * <p>
 * Processes the <A HREF="http://www.stepmaniawiki.com/wiki/The_.SM_file_format">.sm file format</A> 
 * used by <A HREF="http://sourceforge.net/projects/stepmania/">StepMania</A>. 
 * <p>
 * Licensed under <A HREF="http://www.gnu.org/licenses/gpl.txt">GNU GPL (Version 3)</A>. 
 * <p>
 * @author	Philip Peng
 * @version	1.0 Oct 25, 2007
 * @deprecated
 * 
 */

public class SMReader {
	
	private FileInputStream smFile;
	Scanner input;
	
	private ArrayList<String> easy = new ArrayList<String>();
	private ArrayList<String> medium = new ArrayList<String>();
	private ArrayList<String> hard = new ArrayList<String>();
	
	public SMReader(FileInputStream stream) {
		smFile = stream;
		input = new Scanner(smFile);
	};
	
	public SMReader(String file) {
		try {
			smFile = FileTools.convertStringToStream(file);
			input = new Scanner(smFile);
		} catch ( java.io.FileNotFoundException e ) {
			e.getMessage();
		}
	};
	
	public void process() {
		String buffer;
		while (input.hasNextLine()) {
			buffer = input.nextLine();
			if (buffer.length()>0) { // Avoid the empty lines
				switch (buffer.charAt(0)) {
					case '#':
						// Process header
						break;
					case '/':
						// Ignore comment
						break;
					case ' ':
						// Ignore tab
						break;
					case ',':
						// New measure
						easy.add(",");
					case ';':
						// End of set
						break;
					default: // Notes
						easy.add(buffer);
						//System.out.println(lines.get(lines.size()-1));
				}
			}
		}
	}
	
	public void getLines() {
		for (int i = 0; i < easy.size(); i++) {
			System.out.println(easy.get(i));
		}
	}
	
	
	
}
