Skip to content

Measurements

Antonin Abherve edited this page Feb 16, 2017 · 3 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. Each values ares accessed using a String identifier.


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

Predefined Measurements

The api provide some predefined measurements which can be used on Measure implementation :

  • IntegerMeasurement : allow to manipulate numbers in measure implementation

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

Custom Measurements Example

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

The SVNMeasurement is used by a measure which collect COMMIT information provided by an SVN repository. It manage data related to th Autor of the commit, the Meassage onf the commit and the dante 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");
	}
}