/*******************************************************************************
- * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
+ * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
package org.eclipse.linuxtools.ctf.core.event;
import java.util.HashMap;
+import java.util.Map;
/**
* Clock description used in CTF traces
*/
public class CTFClock {
+ private static final long ONE_BILLION_L = 1000000000L;
+ private static final double ONE_BILLION_D = 1000000000.0;
+
private static final String NAME = "name"; //$NON-NLS-1$
private static final String FREQ = "freq"; //$NON-NLS-1$
private static final String OFFSET = "offset"; //$NON-NLS-1$
- private long clockOffset = 0;
- private double clockScale = 1.0;
- private double clockAntiScale = 1.0;
+ private long fClockOffset = 0;
+ private double fClockScale = 1.0;
+ private double fClockAntiScale = 1.0;
/**
* Field properties.
*/
- final private HashMap<String, Object> properties = new HashMap<String, Object>();
+ private final Map<String, Object> fProperties = new HashMap<>();
/**
* Field name.
*/
- private String name;
- private boolean isScaled = false;
+ private String fName;
+ private boolean fIsScaled = false;
/**
* Default constructor
* Object
*/
public void addAttribute(String key, Object value) {
- this.properties.put(key, value);
+ fProperties.put(key, value);
if (key.equals(NAME)) {
- this.name = (String) value;
+ fName = (String) value;
}
if (key.equals(FREQ)) {
/*
* have a system with a frequency of > 1 600 000 000 GHz with
* 200 ppm precision
*/
- isScaled = !((Long) getProperty(FREQ)).equals(1000000000L);
- clockScale = 1000000000.0 / ((Long) getProperty(FREQ)).doubleValue();
- clockAntiScale = 1.0 / clockScale;
+ fIsScaled = !((Long) getProperty(FREQ)).equals(ONE_BILLION_L);
+ fClockScale = ONE_BILLION_D / ((Long) getProperty(FREQ)).doubleValue();
+ fClockAntiScale = 1.0 / fClockScale;
}
if (key.equals(OFFSET)) {
- clockOffset = (Long) getProperty(OFFSET);
+ fClockOffset = (Long) getProperty(OFFSET);
}
}
* @return String
*/
public String getName() {
- return name;
+ return fName;
}
/**
* @return Object
*/
public Object getProperty(String key) {
- return properties.get(key);
+ return fProperties.get(key);
}
/**
* @return the clockOffset
+ * @since 2.0
*/
public long getClockOffset() {
- return clockOffset;
+ return fClockOffset;
}
/**
* @return the clockScale
+ * @since 2.0
*/
public double getClockScale() {
- return clockScale;
+ return fClockScale;
}
/**
* @return the clockAntiScale
+ * @since 2.0
*/
public double getClockAntiScale() {
- return clockAntiScale;
+ return fClockAntiScale;
}
/**
* @return is the clock in ns or cycles?
+ * @since 2.0
*/
public boolean isClockScaled() {
- return isScaled;
+ return fIsScaled;
}
}