Skip to content
This repository has been archived by the owner on Nov 15, 2019. It is now read-only.

Measurements

Alin Stefanescu edited this page Sep 7, 2017 · 2 revisions

Measurement Overview

A Measurement is a data model used as input and output of SMM measure.

A measurement has to extend the IMeasurement interface. A measurement is presented as set of Java elements which can be accessed via a Map. All values are accessed using a String identifier.


public interface IMeasurement {
	public Map<String, Object> getValues();
        public String getLabel();
}

Predefined Measurements

The API provides some predefined measurements which can be used in the measure implementation :

  • IntegerMeasurement: allows to manipulate numbers in the measure implementation

        int value = 10;
        IntegerMeasurement measurement = new IntegerMeasurement();
        measurement.setValue(value);        

Custom Measurements Example

A Measure developer can define custom measurements to manage her own set of data.

The SVNMeasurement is used by a measure which collects COMMIT information provided by an SVN repository. It manages data related to the author of the commit, the message on the commit and the date of the commit.


	public SVNMeasurement(String author,String message,Date postDate){
		super();
		this.valueMap = new HashMap<>();
		if(author == null){
			author = "";
		}
		if(message == null){
			message = "";
		}
		if(postDate == null){
			postDate = new Date();
		}
		this.valueMap.put("Author", author);
		this.valueMap.put("Message", message);
		this.valueMap.put("postDate",new Date(postDate.getTime()));
	}

	@Override
	public String getLabel() {
		return valueMap.get("postDate")+ " [" + valueMap.get("Author") + "]: " +  valueMap.get("Message");
	}
}