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 java.nio.ByteOrder;
18
* A CTF integer declaration.
20
* The declaration of a integer basic data type.
23
* @author Matthew Khouzam
24
* @author Simon Marchi
26
public class IntegerDeclaration implements IDeclaration {
28
// ------------------------------------------------------------------------
30
// ------------------------------------------------------------------------
32
final private int length;
33
final private boolean signed;
34
final private int base;
35
final private ByteOrder byteOrder;
36
final private Encoding encoding;
37
final private long alignment;
38
final private String clock;
40
// ------------------------------------------------------------------------
42
// ------------------------------------------------------------------------
46
* @param len the length in bits
47
* @param signed is the integer signed? false == unsigned
48
* @param base the base (10-16 are most common)
49
* @param byteOrder Big endian little endian or other
50
* @param encoding ascii, utf8 or none.
51
* @param clock the clock path, can be null
52
* @param alignment the minimum alignment
54
public IntegerDeclaration(int len, boolean signed, int base,
55
ByteOrder byteOrder, Encoding encoding, String clock, long alignment) {
59
this.byteOrder = byteOrder;
60
this.encoding = encoding;
62
this.alignment = alignment;
65
// ------------------------------------------------------------------------
66
// Gettters/Setters/Predicates
67
// ------------------------------------------------------------------------
70
* Is the integer signed?
71
* @return the is the integer signed
73
public boolean isSigned() {
78
* get the integer base commonly decimal or hex
79
* @return the integer base
81
public int getBase() {
87
* @return the byte order
89
public ByteOrder getByteOrder() {
94
* get encoding, chars are 8 bit ints
95
* @return the encoding
97
public Encoding getEncoding() {
102
* is the integer a character (8 bits and encoded?)
103
* @return is the integer a char
105
public boolean isCharacter() {
106
return (length == 8) && (encoding != Encoding.NONE);
110
* How many bits is this int
111
* @return the length of the int
113
public int getLength() {
118
public long getAlignment(){
123
* The integer's clock, since timestamps are stored in ints
124
* @return the integer's clock, can be null. (most often it is)
126
public String getClock(){
129
// ------------------------------------------------------------------------
131
// ------------------------------------------------------------------------
134
public IntegerDefinition createDefinition(IDefinitionScope definitionScope,
136
return new IntegerDefinition(this, definitionScope, fieldName);
140
public String toString() {
141
/* Only used for debugging */
142
return "[declaration] integer[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$