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 | /** | |
19 | * This is the interface for using state values and reading their contents. | |
5df842b3 | 20 | * |
2cb26548 AM |
21 | * @version 1.0 |
22 | * @author Alexandre Montplaisir | |
a52fde77 AM |
23 | */ |
24 | public interface ITmfStateValue { | |
25 | ||
b67a2540 AM |
26 | /** |
27 | * The supported types of state values | |
28 | * @since 2.0 | |
29 | */ | |
30 | public enum Type { | |
31 | /** Null value, for an interval not carrying any information */ | |
32 | NULL, | |
33 | /** 32-bit integer value */ | |
34 | INTEGER, | |
35 | /** Variable-length string value */ | |
1cbf1a19 FR |
36 | STRING, |
37 | /** 64-bit integer value */ | |
38 | LONG | |
b67a2540 | 39 | } |
0e05a268 | 40 | |
a52fde77 | 41 | /** |
b67a2540 AM |
42 | * Each implementation has to define which one (among the supported types) |
43 | * they implement. There could be more than one implementation of each type, | |
44 | * depending on the needs of the different users. | |
5df842b3 | 45 | * |
b67a2540 AM |
46 | * @return The ITmfStateValue.Type enum representing the type of this value |
47 | * @since 2.0 | |
a52fde77 | 48 | */ |
57a2a5ca | 49 | Type getType(); |
a52fde77 AM |
50 | |
51 | /** | |
52 | * Only "null values" should return true here | |
5df842b3 | 53 | * |
a52fde77 AM |
54 | * @return True if this type of SV is considered "null", false if it |
55 | * contains a real value. | |
56 | */ | |
57a2a5ca | 57 | boolean isNull(); |
a52fde77 AM |
58 | |
59 | /** | |
60 | * Read the contained value as an 'int' primitive | |
5df842b3 | 61 | * |
a52fde77 AM |
62 | * @return The integer contained in the state value |
63 | * @throws StateValueTypeException | |
64 | * If the contained value cannot be read as an integer | |
65 | */ | |
57a2a5ca | 66 | int unboxInt() throws StateValueTypeException; |
a52fde77 AM |
67 | |
68 | /** | |
69 | * Read the contained value as a String | |
5df842b3 | 70 | * |
a52fde77 AM |
71 | * @return The String contained in the state value |
72 | * @throws StateValueTypeException | |
73 | * If the contained value cannot be read as a String | |
74 | */ | |
57a2a5ca | 75 | String unboxStr() throws StateValueTypeException; |
1cbf1a19 FR |
76 | |
77 | /** | |
78 | * Read the contained value as a 'long' primitive | |
79 | * | |
80 | * @return The long contained in the state value | |
81 | * @throws StateValueTypeException | |
82 | * If the contained value cannot be read as a long | |
83 | * @since 2.0 | |
84 | */ | |
57a2a5ca | 85 | long unboxLong() throws StateValueTypeException; |
a52fde77 | 86 | } |