All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.headlessintrace.client.connection.command.ClassInstrumentationCommand Maven / Gradle / Ivy

Go to download

A headless java API that collects events from other JVMs. Events=method invocations. Initial code taken from http://mchr3k.github.io/org.intrace/. Intended for building diagnostic applications.

There is a newer version: 0.0.4
Show newest version
package org.headlessintrace.client.connection.command;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import org.headlessintrace.shared.AgentConfigConstants;


public class ClassInstrumentationCommand extends AbstractDefaultCommand {

	private String m_includeClassRegEx = null;
	private String m_excludeClassRegEx = null;
	private static final String NEW_LINE_DELIMS = "\n\r";
	
	@Override
	public String getMessage() {
		// TODO Auto-generated method stub
		return 
			AgentConfigConstants.EXCLUDE_CLASS_REGEX+getExcludeClassRegEx()
			+AgentConfigConstants.CLASS_REGEX+this.getIncludeClassRegEx();
	}

	public String getIncludeClassRegEx() {
		return m_includeClassRegEx;
	}

	public void setIncludeClassRegEx(String includeClassRegEx) {
		this.m_includeClassRegEx = includeClassRegEx;
	}

	public String getExcludeClassRegEx() {
		return m_excludeClassRegEx;
	}

	public void setExcludeClassRegEx(String excludeClassRegEx) {
		this.m_excludeClassRegEx = excludeClassRegEx;
	}
	private static List rawTextToList(String rawMultiLineText) {
		List al = new ArrayList();
		StringTokenizer st = new StringTokenizer(rawMultiLineText,NEW_LINE_DELIMS);
		String currentLine = null;
		while(st.hasMoreTokens()) {
			currentLine = (String)st.nextToken();
			al.add(currentLine);
		}
		return al;
	}
	
	/**
	 * Designed to take the text straight from the list box.
	 * @param rawMultiLineText
	 * @return
	 */
	public static ClassInstrumentationCommand create(String rawMultiLineText) {
		
		List list = rawTextToList(rawMultiLineText);
		String classesIncludeRegEx = getStringFromList(list);
		
		ClassInstrumentationCommand cic = new ClassInstrumentationCommand();
		cic.setIncludeClassRegEx(classesIncludeRegEx);
		return cic;
	}
	
	  private static String getStringFromList(List list)
	  {
	    StringBuilder str = new StringBuilder();
	
	    for (int ii = 0; ii < list.size(); ii++)
	    {
	      String item = list.get(ii);
	      str.append(item);
	      if (ii < (list.size() - 1))
	      {
	        str.append("|");
	      }
	    }
	    return str.toString();
	  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy