1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
4 * All rights reserved. This program and the accompanying materials are made
5 * 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
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.ctf
.core
.event
.types
;
15 import org
.eclipse
.jdt
.annotation
.NonNull
;
16 import org
.eclipse
.tracecompass
.ctf
.core
.event
.scope
.IDefinitionScope
;
19 * A CTF enum definition.
21 * The definition of a enum point basic data type. It will take the data from a
22 * trace and store it (and make it fit) as an integer and a string.
25 * @author Matthew Khouzam
26 * @author Simon Marchi
28 public final class EnumDefinition
extends SimpleDatatypeDefinition
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
34 private final long fIntegerValue
;
36 private final String fValue
;
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
46 * the parent declaration
47 * @param definitionScope
52 * the value of the enum
54 public EnumDefinition(@NonNull EnumDeclaration declaration
,
55 IDefinitionScope definitionScope
, @NonNull String fieldName
, IntegerDefinition intValue
) {
56 super(declaration
, definitionScope
, fieldName
);
58 fIntegerValue
= intValue
.getValue();
59 fValue
= declaration
.query(fIntegerValue
);
62 // ------------------------------------------------------------------------
63 // Getters/Setters/Predicates
64 // ------------------------------------------------------------------------
67 * Gets the value of the enum in string format so
68 * "Enum a{DAY="0", NIGHT="1"}; will return "DAY"
70 * @return the value of the enum.
72 public String
getValue() {
77 public String
getStringValue() {
82 * Gets the value of the enum in string format so
83 * "Enum a{DAY="0", NIGHT="1"}; will return 0
85 * @return the value of the enum.
88 public Long
getIntegerValue() {
93 public EnumDeclaration
getDeclaration() {
94 return (EnumDeclaration
) super.getDeclaration();
97 // ------------------------------------------------------------------------
99 // ------------------------------------------------------------------------
102 public String
toString() {
103 return "{ value = " + getValue() + //$NON-NLS-1$
104 ", container = " + fIntegerValue
+ //$NON-NLS-1$