• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *    Marc R. Hoffmann - initial API and implementation
10  *
11  *******************************************************************************/
12 package org.jacoco.core.runtime;
13 
14 import java.util.Random;
15 
16 /**
17  * Base {@link IRuntime} implementation.
18  */
19 public abstract class AbstractRuntime implements IRuntime {
20 
21 	/** access to the runtime data */
22 	protected RuntimeData data;
23 
24 	/**
25 	 * Subclasses must call this method when overwriting it.
26 	 */
startup(final RuntimeData data)27 	public void startup(final RuntimeData data) throws Exception {
28 		this.data = data;
29 	}
30 
31 	private static final Random RANDOM = new Random();
32 
33 	/**
34 	 * Creates a random session identifier.
35 	 *
36 	 * @return random session identifier
37 	 */
createRandomId()38 	public static String createRandomId() {
39 		return Integer.toHexString(RANDOM.nextInt());
40 	}
41 
42 }
43