ruper2/src/java/core/org/krysalis/ruper2/monitor IFileMonitor.java,NONE,1.1 StatisticsMonitor.java,1.1,1.2 StandardMonitor.java,1.1,1.2 Monitor.java,1.1,1.2 IMonitor.java,1.1,NONE

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/monitor
In directory sc8-pr-cvs1:/tmp/cvs-serv23201/src/java/core/org/krysalis/ruper2/monitor

Modified Files:
	StatisticsMonitor.java StandardMonitor.java Monitor.java 
Added Files:
	IFileMonitor.java 
Removed Files:
	IMonitor.java 
Log Message:
1) Moved IMonitor -> IFileMonitor (to allow others)
2) GroupBy now works (iterated unsorted list be accindent)
3) Started on 'clean' (remove old versions from a repo)

--- NEW FILE: IFileMonitor.java ---
/*
 * Created on Aug 28, 2003
  */
package org.krysalis.ruper2.monitor;

/**
 * @author anou_mana
 */
public interface IFileMonitor {
	
	//	Filename Processing
	void ignored(Object ignored);
	void failed(Object failed);
	void parsed(Object parsed);
}

Index: StatisticsMonitor.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/monitor/StatisticsMonitor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** StatisticsMonitor.java	9 Oct 2003 20:30:27 -0000	1.1
--- StatisticsMonitor.java	12 Oct 2003 18:12:06 -0000	1.2
***************
*** 14,32 ****
   * @author anou_mana
   */
! public class StatisticsMonitor implements IMonitor, Dumpable {
  
  	private int m_failed = 0;
- 	private List m_failedObjects = null;
  	private int m_ignored = 0;
! 	private List m_ignoredObjects = null;
  	
! 	public StatisticsMonitor()
! 	{
  		initClass();
  	}
! 	
  	private void initClass() {
  		m_failedObjects = new ArrayList();
  		m_ignoredObjects = new ArrayList();
  	}
  
--- 14,35 ----
   * @author anou_mana
   */
! public class StatisticsMonitor implements IFileMonitor, Dumpable {
  
  	private int m_failed = 0;
  	private int m_ignored = 0;
! 	private int m_parsed = 0;
  	
! 	private List m_failedObjects = null;
! 	private List m_ignoredObjects = null;
! 	private List m_parsedObjects = null;
! 
! 	public StatisticsMonitor() {
  		initClass();
  	}
! 
  	private void initClass() {
  		m_failedObjects = new ArrayList();
  		m_ignoredObjects = new ArrayList();
+ 		m_parsedObjects = new ArrayList();
  	}
  
***************
*** 47,50 ****
--- 50,61 ----
  	}
  
+ 	/* (non-Javadoc)
+ 	 * @see org.krysalis.ruper2.monitor.IMonitor#parsed(java.lang.Object)
+ 	 */
+ 	public void parsed(Object parsed) {
+ 		m_parsed++;
+ 		m_parsedObjects.add(parsed);
+ 	}
+ 
  	/**
  	 * @return
***************
*** 61,85 ****
  	}
  
  	public void dump(PrintWriter out, int depth, boolean verbose) {
  		final String indent = DebugUtils.getIndent(depth);
! 		
! 		DebugUtils.printSeparator(out,depth);
  		out.print(indent);
! 		out.print("Statistics : " );
! 		DebugUtils.printSeparator(out,depth);
! 		
  		out.print(indent);
! 		out.print("Failed : " );
  		out.println(m_failed);
  
  		out.print(indent);
! 		out.print("Ignored : " );
  		out.println(m_ignored);
  
! 		DebugUtils.printSeparator(out,depth);
! 		DebugUtils.dump(out,depth,verbose, m_failedObjects);
! 		
! 		DebugUtils.printSeparator(out,depth);
! 		DebugUtils.dump(out,depth,verbose, m_ignoredObjects);
  	}
  }
--- 72,112 ----
  	}
  
+ 	/**
+ 	 * @return
+ 	 */
+ 	public int getParsed() {
+ 		return m_parsed;
+ 	}
+ 
  	public void dump(PrintWriter out, int depth, boolean verbose) {
  		final String indent = DebugUtils.getIndent(depth);
! 
! 		DebugUtils.printSeparator(out, depth);
  		out.print(indent);
! 		out.print("Statistics : ");
! 		DebugUtils.printSeparator(out, depth);
! 
  		out.print(indent);
! 		out.print("Failed  : ");
  		out.println(m_failed);
  
  		out.print(indent);
! 		out.print("Ignored : ");
  		out.println(m_ignored);
  
! 		out.print(indent);
! 		out.print("Parsed  : ");
! 		out.println(m_parsed);
! 
! 		if (verbose) {
! 			DebugUtils.printSeparator(out, depth);
! 			DebugUtils.dump(out, depth, verbose, m_parsedObjects);
! 		}
! 
! 		DebugUtils.printSeparator(out, depth);
! 		DebugUtils.dump(out, depth, verbose, m_failedObjects);
! 
! 		DebugUtils.printSeparator(out, depth);
! 		DebugUtils.dump(out, depth, verbose, m_ignoredObjects);
  	}
  }

Index: StandardMonitor.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/monitor/StandardMonitor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** StandardMonitor.java	9 Oct 2003 20:30:27 -0000	1.1
--- StandardMonitor.java	12 Oct 2003 18:12:06 -0000	1.2
***************
*** 11,15 ****
   * @author anou_mana
   */
! public class StandardMonitor implements IMonitor {
  
  	/* (non-Javadoc)
--- 11,15 ----
   * @author anou_mana
   */
! public class StandardMonitor implements IFileMonitor {
  
  	/* (non-Javadoc)
***************
*** 27,30 ****
--- 27,38 ----
  		Logger.getLog().debug(
  			Messages.getString(MessageConstants.IGNORE, ignored));
+ 	}
+ 
+ 	/* (non-Javadoc)
+ 	 * @see org.krysalis.ruper2.monitor.IMonitor#ignored(java.lang.Object)
+ 	 */
+ 	public void parsed(Object parsed) {	
+ 		Logger.getLog().debug(
+ 			Messages.getString(MessageConstants.PARSED, parsed));
  	}
  

Index: Monitor.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/monitor/Monitor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Monitor.java	9 Oct 2003 20:30:27 -0000	1.1
--- Monitor.java	12 Oct 2003 18:12:06 -0000	1.2
***************
*** 15,18 ****
--- 15,23 ----
   */
  public class Monitor {
+ 	
+ 	// File Interface
+ 	public final static int FAILED	=	1;
+ 	public final static int IGNORED	=	2;
+ 	public final static int PARSED	=	3;
  
  	// Monitor Table...
***************
*** 94,98 ****
  	}
  
! 	public static Monitor pushContext(IMonitor monitor) {
  		Monitor newMonitor = pushContext();
  		// :TODO: Fix level, ask monitor what they want...
--- 99,107 ----
  	}
  
! 	//
! 	//	--------------------------------------------------------------------
! 	//	Context Interface
! 	//
! 	public static Monitor pushContext(IFileMonitor monitor) {
  		Monitor newMonitor = pushContext();
  		// :TODO: Fix level, ask monitor what they want...
***************
*** 117,125 ****
  	}
  
! 	public void addMonitor(IMonitor monitor) {
  		m_monitors.add(monitor);
  	}
  
! 	public void removemonitor(IMonitor monitor) {
  		m_monitors.remove(monitor);
  	}
--- 126,134 ----
  	}
  
! 	public void addMonitor(IFileMonitor monitor) {
  		m_monitors.add(monitor);
  	}
  
! 	public void removeMonitor(IFileMonitor monitor) {
  		m_monitors.remove(monitor);
  	}
***************
*** 129,135 ****
  		return !m_monitors.isEmpty();
  	}
  
  	public void ignored(Object message) {
! 		notify(m_monitors, false, message);
  		if (null != m_next)
  			m_next.ignored(message);
--- 138,149 ----
  		return !m_monitors.isEmpty();
  	}
+ 	
+ 	//
+ 	//	-------------------------------------------------------------------------------
+ 	//	File interface
+ 	//
  
  	public void ignored(Object message) {
! 		notify(m_monitors, IGNORED, message);
  		if (null != m_next)
  			m_next.ignored(message);
***************
*** 137,155 ****
  
  	public void failed(Object failed) {
! 		notify(m_monitors, true, failed);
  		if (null != m_next)
  			m_next.failed(failed);
  	}
  
! 	private void notify(List Monitors, boolean failed, Object obj) {
  
  		for (Iterator i = Monitors.iterator(); i.hasNext();) {
  			try {
! 				IMonitor monitor = ((IMonitor) i.next());
  
! 				if (!failed)
! 					monitor.ignored(obj);
! 				else
! 					monitor.failed(obj);
  			}
  			catch (Throwable t) {
--- 151,191 ----
  
  	public void failed(Object failed) {
! 		notify(m_monitors, FAILED, failed);
  		if (null != m_next)
  			m_next.failed(failed);
  	}
+ 	
+ 	public void parsed(Object parsed) {
+ 		notify(m_monitors, PARSED, parsed);
+ 		if (null != m_next)
+ 			m_next.parsed(parsed);
+ 	}
  
! /**
!  * Notify interfaces that are single parameter only 
!  * 
!  * @param Monitors
!  * @param notificationType
!  * @param obj
!  */
! 	private void notify(List Monitors, int notificationType, Object obj) {
  
  		for (Iterator i = Monitors.iterator(); i.hasNext();) {
  			try {
! 				IFileMonitor monitor = ((IFileMonitor) i.next());
  
! 				switch(notificationType) {
! 					case PARSED:
! 						monitor.parsed(obj);
! 						break;
! 
! 					case FAILED:
! 						monitor.failed(obj);
! 						break;
! 						
! 					case IGNORED:
! 						monitor.ignored(obj);
! 						break;
! 				}
  			}
  			catch (Throwable t) {
***************
*** 158,161 ****
--- 194,224 ----
  		}
  	}
+ 	
+ 	/**
+ 	 * Notify interfaes that are multipe parameter.
+ 	 * @param Monitors
+ 	 * @param notificationType
+ 	 * @param objs
+ 	 */
+ 	
+ 	private void notify(List Monitors, int notificationType, Object objs[]) {
+ 
+ 	for (Iterator i = Monitors.iterator(); i.hasNext();) {
+ 		try {
+ 			IFileMonitor monitor = ((IFileMonitor) i.next());
+ 
+ 			switch(notificationType) {
+ 				
+ 						
+ 				//case IGNORED:
+ 				//	monitor.ignored(objs);
+ 				//	break;
+ 			}
+ 		}
+ 		catch (Throwable t) {
+ 			// Their problems are not ours...
+ 		}
+ 	}
+ }
  
  	public static void monitorToLog() {

--- IMonitor.java DELETED ---




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.