1 /*******************************************************************************
2 * Copyright (c) 2011-2012 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
.linuxtools
.ctf
.core
.event
.types
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.event
.io
.BitBuffer
;
18 * <b><u>IntegerDefinition</u></b>
20 * TODO: Reading integers with an endianness different from the trace endianness
23 public class IntegerDefinition
extends Definition
{
25 // ------------------------------------------------------------------------
27 // ------------------------------------------------------------------------
29 private final IntegerDeclaration declaration
;
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 public IntegerDefinition(IntegerDeclaration declaration
,
37 IDefinitionScope definitionScope
, String fieldName
) {
38 super(definitionScope
, fieldName
);
39 this.declaration
= declaration
;
42 // ------------------------------------------------------------------------
43 // Gettters/Setters/Predicates
44 // ------------------------------------------------------------------------
46 public long getValue() {
50 public void setValue(long val
) {
54 public IntegerDeclaration
getDeclaration() {
58 // ------------------------------------------------------------------------
60 // ------------------------------------------------------------------------
63 public void read(BitBuffer input
) {
64 boolean signed
= declaration
.isSigned();
65 int length
= declaration
.getLength();
68 // TODO: use the eventual getLong from BitBuffer
71 long low
= input
.getInt(32, false);
72 low
= low
& 0x00000000FFFFFFFFL
;
73 long high
= input
.getInt(32, false);
74 high
= high
& 0x00000000FFFFFFFFL
;
76 bits
= (high
<< 32) | low
;
78 bits
= input
.getInt(length
, signed
);
79 bits
= bits
& 0x00000000FFFFFFFFL
;
86 public String
toString() {
87 if (declaration
.isCharacter()) {
88 char c
= (char) value
;
89 return Character
.toString(c
);
91 return String
.valueOf(value
);