Contribute native CTF Parser (bug370499)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / IntegerDeclaration.java
CommitLineData
866e5b51
FC
1/*******************************************************************************
2 * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
3 *
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
8 *
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.ctf.core.event.types;
14
15import java.nio.ByteOrder;
16
17/**
18 * <b><u>IntegerDeclaration</u></b>
19 */
20public class IntegerDeclaration implements IDeclaration {
21
22 // ------------------------------------------------------------------------
23 // Attributes
24 // ------------------------------------------------------------------------
25
26 private int length;
27 private boolean signed;
28 private int base;
29 private ByteOrder byteOrder;
30 private Encoding encoding;
31
32 // ------------------------------------------------------------------------
33 // Constructors
34 // ------------------------------------------------------------------------
35
36 public IntegerDeclaration(int len, boolean signed, int base,
37 ByteOrder byteOrder, Encoding encoding) {
38 this.length = len;
39 this.signed = signed;
40 this.base = base;
41 this.byteOrder = byteOrder;
42 this.encoding = encoding;
43 }
44
45 // ------------------------------------------------------------------------
46 // Gettters/Setters/Predicates
47 // ------------------------------------------------------------------------
48
49 public boolean isSigned() {
50 return signed;
51 }
52
53 public void setSigned(boolean signed) {
54 this.signed = signed;
55 }
56
57 public int getBase() {
58 return base;
59 }
60
61 public void setBase(int base) {
62 this.base = base;
63 }
64
65 public ByteOrder getByteOrder() {
66 return byteOrder;
67 }
68
69 public void setByteOrder(ByteOrder byteOrder) {
70 this.byteOrder = byteOrder;
71 }
72
73 public Encoding getEncoding() {
74 return encoding;
75 }
76
77 public void setEncoding(Encoding encoding) {
78 this.encoding = encoding;
79 }
80
81 public void setLength(int length) {
82 this.length = length;
83 }
84
85 public boolean isCharacter() {
86 return (length == 8) && (encoding != Encoding.NONE);
87 }
88
89 public int getLength() {
90 return length;
91 }
92
93 // ------------------------------------------------------------------------
94 // Operations
95 // ------------------------------------------------------------------------
96
97 @Override
98 public IntegerDefinition createDefinition(IDefinitionScope definitionScope,
99 String fieldName) {
100 return new IntegerDefinition(this, definitionScope, fieldName);
101 }
102
103 @Override
104 public String toString() {
105 /* Only used for debugging */
106 return "[declaration] integer[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
107 }
108
109}
This page took 0.041953 seconds and 5 git commands to generate.