Commit | Line | Data |
---|---|---|
a52fde77 | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2012, 2014 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 | ||
bcec0116 | 13 | package org.eclipse.linuxtools.statesystem.core.statevalue; |
a52fde77 | 14 | |
bcec0116 | 15 | import org.eclipse.linuxtools.statesystem.core.exceptions.StateValueTypeException; |
6d08acca | 16 | |
a52fde77 AM |
17 | /** |
18 | * This is the interface for using state values and reading their contents. | |
5df842b3 | 19 | * |
2cb26548 | 20 | * @author Alexandre Montplaisir |
bcec0116 | 21 | * @since 3.0 |
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, | |
c4767854 AM |
36 | /** IEEE 754 double precision number |
37 | * @since 3.0*/ | |
a3c22e8e | 38 | DOUBLE, |
b67a2540 | 39 | /** Variable-length string value */ |
1cbf1a19 | 40 | STRING, |
b67a2540 | 41 | } |
0e05a268 | 42 | |
a52fde77 | 43 | /** |
b67a2540 AM |
44 | * Each implementation has to define which one (among the supported types) |
45 | * they implement. There could be more than one implementation of each type, | |
46 | * depending on the needs of the different users. | |
5df842b3 | 47 | * |
b67a2540 AM |
48 | * @return The ITmfStateValue.Type enum representing the type of this value |
49 | * @since 2.0 | |
a52fde77 | 50 | */ |
57a2a5ca | 51 | Type getType(); |
a52fde77 AM |
52 | |
53 | /** | |
54 | * Only "null values" should return true here | |
5df842b3 | 55 | * |
a52fde77 AM |
56 | * @return True if this type of SV is considered "null", false if it |
57 | * contains a real value. | |
58 | */ | |
57a2a5ca | 59 | boolean isNull(); |
a52fde77 AM |
60 | |
61 | /** | |
62 | * Read the contained value as an 'int' primitive | |
5df842b3 | 63 | * |
a52fde77 AM |
64 | * @return The integer contained in the state value |
65 | * @throws StateValueTypeException | |
66 | * If the contained value cannot be read as an integer | |
67 | */ | |
6dd46830 | 68 | int unboxInt(); |
a52fde77 | 69 | |
1cbf1a19 FR |
70 | /** |
71 | * Read the contained value as a 'long' primitive | |
72 | * | |
73 | * @return The long contained in the state value | |
74 | * @throws StateValueTypeException | |
75 | * If the contained value cannot be read as a long | |
76 | * @since 2.0 | |
77 | */ | |
6dd46830 | 78 | long unboxLong(); |
a9cdbafc | 79 | |
a3c22e8e AM |
80 | /** |
81 | * Read the contained value as a 'double' primitive | |
82 | * | |
83 | * @return The double contained in the state value | |
84 | * @throws StateValueTypeException | |
85 | * If the contained value cannot be read as a double | |
c4767854 | 86 | * @since 3.0 |
a3c22e8e | 87 | */ |
6dd46830 | 88 | double unboxDouble(); |
a3c22e8e | 89 | |
a9cdbafc AM |
90 | /** |
91 | * Read the contained value as a String | |
92 | * | |
93 | * @return The String contained in the state value | |
94 | * @throws StateValueTypeException | |
95 | * If the contained value cannot be read as a String | |
96 | */ | |
6dd46830 | 97 | String unboxStr(); |
a52fde77 | 98 | } |