package com.powerdata.openpa.psse;

import com.powerdata.openpa.tools.BaseObject;

public abstract class PsseModel
{
	public static PsseInputModel OpenInput(String uri) throws PsseModelException
	{
		String[] tok = uri.split(":", 1);
		switch(tok[0].toLowerCase())
		{
			case "pssecsv": 
				String dpath = tok[1].split("=")[1];
				return new com.powerdata.openpa.psse.csv.PsseInputModel(dpath);
			default:
				throw new PsseModelException("URI not supported: "+uri);
		}
	}

	public static PsseOutputModel OpenOutput(String uri) throws PsseModelException
	{
		String[] tok = uri.split(":", 1);
		switch(tok[0].toLowerCase())
		{
//			case "pssecsv": 
//				String dpath = tok[1].split("=")[1];
//				return new com.powerdata.openpa.psse.csv.PsseModelOut(dpath);
			default:
				throw new PsseModelException("URI not supported: "+uri);
		}
	}
	
	protected PsseModelLog _log = new PsseModelLog()
	{
		@Override
		public void log(LogSev severity, BaseObject obj, String msg) throws PsseModelException
		{
			String objclass = obj.getClass().getSimpleName();
			String objnm = obj.getDebugName();
			String objid = obj.getObjectID();
			((severity == LogSev.Error) ? System.err : System.out)
				.format("%s %s %s[%s] %s\n", objclass, objnm, objid, msg);
		}
	};
	
	public PsseModel() {} 
	public PsseModel(PsseModelLog log) {_log = log;} 
	
//	/** find a Bus by ID (moved to InputList)*/ 
//	public BusIn getBus(String id) throws PsseModelException {return getBuses().get(id);}
	
	
	public void log(LogSev severity, BaseObject obj, String msg) throws PsseModelException
	{
		_log.log(severity, obj, msg);
	}
	
}	



package com.powerdata.openpa.psse;

import com.powerdata.openpa.tools.BaseObject;

public abstract class PsseModel
{
	public static PsseInputModel OpenInput(String uri) throws PsseModelException
	{
		String[] tok = uri.split(":", 2);
		switch(tok[0].toLowerCase())
		{
			case "pssecsv": 
				String dpath = tok[1].split("=")[1];
				return new com.powerdata.openpa.psse.csv.PsseInputModel(dpath);
			default:
				throw new PsseModelException("URI not supported: "+uri);
		}
	}

	public static PsseOutputModel OpenOutput(String uri) throws PsseModelException
	{
		String[] tok = uri.split(":", 1);
		switch(tok[0].toLowerCase())
		{
//			case "pssecsv": 
//				String dpath = tok[1].split("=")[1];
//				return new com.powerdata.openpa.psse.csv.PsseModelOut(dpath);
			default:
				throw new PsseModelException("URI not supported: "+uri);
		}
	}
	
	protected PsseModelLog _log = new PsseModelLog()
	{
		@Override
		public void log(LogSev severity, BaseObject obj, String msg) throws PsseModelException
		{
			String objclass = obj.getClass().getSimpleName();
			String objnm = obj.getDebugName();
			String objid = obj.getObjectID();
			((severity == LogSev.Error) ? System.err : System.out)
				.format("%s %s %s[%s] %s\n", objclass, objnm, objid, msg);
		}
	};
	
	public PsseModel() {} 
	public PsseModel(PsseModelLog log) {_log = log;} 
	
//	/** find a Bus by ID (moved to InputList)*/ 
//	public BusIn getBus(String id) throws PsseModelException {return getBuses().get(id);}
	
	
	public void log(LogSev severity, BaseObject obj, String msg) throws PsseModelException
	{
		_log.log(severity, obj, msg);
	}
	
}	



split needed a count of 2