Commit | Line | Data |
---|---|---|
a52fde77 | 1 | /******************************************************************************* |
11252342 | 2 | * Copyright (c) 2012, 2013 Ericsson |
5df842b3 | 3 | * |
a52fde77 AM |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
5df842b3 | 8 | * |
a52fde77 AM |
9 | * Contributors: |
10 | * Alexandre Montplaisir - Initial API | |
11 | ******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.core.statevalue; | |
14 | ||
6d08acca AM |
15 | import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException; |
16 | ||
a52fde77 AM |
17 | /** |
18 | * This is the interface for using state values and reading their contents. | |
5df842b3 | 19 | * |
2cb26548 AM |
20 | * @version 1.0 |
21 | * @author Alexandre Montplaisir | |
a52fde77 AM |
22 | */ |
23 | public interface ITmfStateValue { | |
24 | ||
b67a2540 AM |
25 | /** |
26 | * The supported types of state values | |
27 | * @since 2.0 | |
28 | */ | |
29 | public enum Type { | |
30 | /** Null value, for an interval not carrying any information */ | |
31 | NULL, | |
32 | /** 32-bit integer value */ | |
33 | INTEGER, | |
a9cdbafc AM |
34 | /** 64-bit integer value */ |
35 | LONG, | |
b67a2540 | 36 | /** Variable-length string value */ |
1cbf1a19 | 37 | STRING, |
b67a2540 | 38 | } |
0e05a268 | 39 | |
a52fde77 | 40 | /** |
b67a2540 AM |
41 | * Each implementation has to define which one (among the supported types) |
42 | * they implement. There could be more than one implementation of each type, | |
43 | * depending on the needs of the different users. | |
5df842b3 | 44 | * |
b67a2540 AM |
45 | * @return The ITmfStateValue.Type enum representing the type of this value |
46 | * @since 2.0 | |
a52fde77 | 47 | */ |
57a2a5ca | 48 | Type getType(); |
a52fde77 AM |
49 | |
50 | /** | |
51 | * Only "null values" should return true here | |
5df842b3 | 52 | * |
a52fde77 AM |
53 | * @return True if this type of SV is considered "null", false if it |
54 | * contains a real value. | |
55 | */ | |
57a2a5ca | 56 | boolean isNull(); |
a52fde77 AM |
57 | |
58 | /** | |
59 | * Read the contained value as an 'int' primitive | |
5df842b3 | 60 | * |
a52fde77 AM |
61 | * @return The integer contained in the state value |
62 | * @throws StateValueTypeException | |
63 | * If the contained value cannot be read as an integer | |
64 | */ | |
57a2a5ca | 65 | int unboxInt() throws StateValueTypeException; |
a52fde77 | 66 | |
1cbf1a19 FR |
67 | /** |
68 | * Read the contained value as a 'long' primitive | |
69 | * | |
70 | * @return The long contained in the state value | |
71 | * @throws StateValueTypeException | |
72 | * If the contained value cannot be read as a long | |
73 | * @since 2.0 | |
74 | */ | |
57a2a5ca | 75 | long unboxLong() throws StateValueTypeException; |
a9cdbafc AM |
76 | |
77 | /** | |
78 | * Read the contained value as a String | |
79 | * | |
80 | * @return The String contained in the state value | |
81 | * @throws StateValueTypeException | |
82 | * If the contained value cannot be read as a String | |
83 | */ | |
84 | String unboxStr() throws StateValueTypeException; | |
a52fde77 | 85 | } |