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, | |
a3c22e8e AM |
36 | /** IEEE 754 double precision number */ |
37 | DOUBLE, | |
b67a2540 | 38 | /** Variable-length string value */ |
1cbf1a19 | 39 | STRING, |
b67a2540 | 40 | } |
0e05a268 | 41 | |
a52fde77 | 42 | /** |
b67a2540 AM |
43 | * Each implementation has to define which one (among the supported types) |
44 | * they implement. There could be more than one implementation of each type, | |
45 | * depending on the needs of the different users. | |
5df842b3 | 46 | * |
b67a2540 AM |
47 | * @return The ITmfStateValue.Type enum representing the type of this value |
48 | * @since 2.0 | |
a52fde77 | 49 | */ |
57a2a5ca | 50 | Type getType(); |
a52fde77 AM |
51 | |
52 | /** | |
53 | * Only "null values" should return true here | |
5df842b3 | 54 | * |
a52fde77 AM |
55 | * @return True if this type of SV is considered "null", false if it |
56 | * contains a real value. | |
57 | */ | |
57a2a5ca | 58 | boolean isNull(); |
a52fde77 AM |
59 | |
60 | /** | |
61 | * Read the contained value as an 'int' primitive | |
5df842b3 | 62 | * |
a52fde77 AM |
63 | * @return The integer contained in the state value |
64 | * @throws StateValueTypeException | |
65 | * If the contained value cannot be read as an integer | |
66 | */ | |
57a2a5ca | 67 | int unboxInt() throws StateValueTypeException; |
a52fde77 | 68 | |
1cbf1a19 FR |
69 | /** |
70 | * Read the contained value as a 'long' primitive | |
71 | * | |
72 | * @return The long contained in the state value | |
73 | * @throws StateValueTypeException | |
74 | * If the contained value cannot be read as a long | |
75 | * @since 2.0 | |
76 | */ | |
57a2a5ca | 77 | long unboxLong() throws StateValueTypeException; |
a9cdbafc | 78 | |
a3c22e8e AM |
79 | /** |
80 | * Read the contained value as a 'double' primitive | |
81 | * | |
82 | * @return The double contained in the state value | |
83 | * @throws StateValueTypeException | |
84 | * If the contained value cannot be read as a double | |
85 | */ | |
86 | double unboxDouble() throws StateValueTypeException; | |
87 | ||
a9cdbafc AM |
88 | /** |
89 | * Read the contained value as a String | |
90 | * | |
91 | * @return The String contained in the state value | |
92 | * @throws StateValueTypeException | |
93 | * If the contained value cannot be read as a String | |
94 | */ | |
95 | String unboxStr() throws StateValueTypeException; | |
a52fde77 | 96 | } |