Commit | Line | Data |
---|---|---|
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 | ||
13 | package org.eclipse.linuxtools.ctf.core.event.types; | |
14 | ||
15 | import java.nio.ByteOrder; | |
16 | ||
17 | /** | |
18 | * <b><u>IntegerDeclaration</u></b> | |
19 | */ | |
20 | public 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; | |
284fdee8 | 31 | private final String clock; |
866e5b51 FC |
32 | |
33 | // ------------------------------------------------------------------------ | |
34 | // Constructors | |
35 | // ------------------------------------------------------------------------ | |
36 | ||
37 | public IntegerDeclaration(int len, boolean signed, int base, | |
284fdee8 | 38 | ByteOrder byteOrder, Encoding encoding, String clock) { |
866e5b51 FC |
39 | this.length = len; |
40 | this.signed = signed; | |
41 | this.base = base; | |
42 | this.byteOrder = byteOrder; | |
43 | this.encoding = encoding; | |
284fdee8 | 44 | this.clock = clock; |
866e5b51 FC |
45 | } |
46 | ||
47 | // ------------------------------------------------------------------------ | |
48 | // Gettters/Setters/Predicates | |
49 | // ------------------------------------------------------------------------ | |
50 | ||
51 | public boolean isSigned() { | |
52 | return signed; | |
53 | } | |
54 | ||
55 | public void setSigned(boolean signed) { | |
56 | this.signed = signed; | |
57 | } | |
58 | ||
59 | public int getBase() { | |
60 | return base; | |
61 | } | |
62 | ||
63 | public void setBase(int base) { | |
64 | this.base = base; | |
65 | } | |
66 | ||
67 | public ByteOrder getByteOrder() { | |
68 | return byteOrder; | |
69 | } | |
70 | ||
71 | public void setByteOrder(ByteOrder byteOrder) { | |
72 | this.byteOrder = byteOrder; | |
73 | } | |
74 | ||
75 | public Encoding getEncoding() { | |
76 | return encoding; | |
77 | } | |
78 | ||
79 | public void setEncoding(Encoding encoding) { | |
80 | this.encoding = encoding; | |
81 | } | |
82 | ||
83 | public void setLength(int length) { | |
84 | this.length = length; | |
85 | } | |
86 | ||
87 | public boolean isCharacter() { | |
88 | return (length == 8) && (encoding != Encoding.NONE); | |
89 | } | |
90 | ||
91 | public int getLength() { | |
92 | return length; | |
93 | } | |
94 | ||
95 | // ------------------------------------------------------------------------ | |
96 | // Operations | |
97 | // ------------------------------------------------------------------------ | |
98 | ||
99 | @Override | |
100 | public IntegerDefinition createDefinition(IDefinitionScope definitionScope, | |
101 | String fieldName) { | |
102 | return new IntegerDefinition(this, definitionScope, fieldName); | |
103 | } | |
104 | ||
105 | @Override | |
106 | public String toString() { | |
107 | /* Only used for debugging */ | |
108 | return "[declaration] integer[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$ | |
109 | } | |
110 | ||
111 | } |