// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   SignalStream.java

package drm.signal.neuro;

import drm.util.UString;
import java.io.*;
import java.util.Vector;

public class SignalStream
{

	public SignalStream()
	{
	}

	public static Vector loadLearnFile(String fileName)
		throws FileNotFoundException
	{
		return loadLearnFile(((Reader) (new FileReader(fileName))));
	}

	public static Vector loadLearnFile(Reader stream)
	{
		BufferedReader lr = new BufferedReader(stream);
		boolean testi = true;
		Vector out = new Vector();
		try
		{
			Vector sig[];
			for(; lr.ready(); out.add(sig))
			{
				sig = new Vector[2];
				sig[0] = readSignals("INPUTS:", lr);
				sig[1] = readSignals("OUTPUTS:", lr);
			}

		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
		return out;
	}

	private static Vector readSignals(String label, BufferedReader lr)
	{
		boolean testi = true;
		Vector sig = new Vector(25);
		while(testi) 
		{
			String text = null;
			try
			{
				text = lr.readLine();
			}
			catch(IOException ex)
			{
				testi = false;
			}
			if(testi && text.compareTo(label) == 0)
				while(testi) 
				{
					String cols[] = null;
					try
					{
						cols = UString.parse(lr.readLine());
					}
					catch(Exception ex)
					{
						testi = false;
					}
					if(testi)
					{
						for(int i = 0; i < cols.length; i++)
						{
							try
							{
								Double d = Double.valueOf(cols[i]);
								sig.add(d);
								continue;
							}
							catch(Exception ex)
							{
								testi = false;
							}
							break;
						}

					}
				}
		}
		return sig;
	}
}
