| 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 | final private int length; |
| 27 | final private boolean signed; |
| 28 | final private int base; |
| 29 | final private ByteOrder byteOrder; |
| 30 | final private Encoding encoding; |
| 31 | final private long alignment; |
| 32 | final private String clock; |
| 33 | |
| 34 | // ------------------------------------------------------------------------ |
| 35 | // Constructors |
| 36 | // ------------------------------------------------------------------------ |
| 37 | |
| 38 | public IntegerDeclaration(int len, boolean signed, int base, |
| 39 | ByteOrder byteOrder, Encoding encoding, String clock, long alignment) { |
| 40 | this.length = len; |
| 41 | this.signed = signed; |
| 42 | this.base = base; |
| 43 | this.byteOrder = byteOrder; |
| 44 | this.encoding = encoding; |
| 45 | this.clock = clock; |
| 46 | this.alignment = alignment; |
| 47 | } |
| 48 | |
| 49 | // ------------------------------------------------------------------------ |
| 50 | // Gettters/Setters/Predicates |
| 51 | // ------------------------------------------------------------------------ |
| 52 | |
| 53 | public boolean isSigned() { |
| 54 | return signed; |
| 55 | } |
| 56 | |
| 57 | public int getBase() { |
| 58 | return base; |
| 59 | } |
| 60 | |
| 61 | public ByteOrder getByteOrder() { |
| 62 | return byteOrder; |
| 63 | } |
| 64 | |
| 65 | public Encoding getEncoding() { |
| 66 | return encoding; |
| 67 | } |
| 68 | |
| 69 | public boolean isCharacter() { |
| 70 | return (length == 8) && (encoding != Encoding.NONE); |
| 71 | } |
| 72 | |
| 73 | public int getLength() { |
| 74 | return length; |
| 75 | } |
| 76 | |
| 77 | public long getAlignment(){ |
| 78 | return alignment; |
| 79 | } |
| 80 | |
| 81 | public String getClock(){ |
| 82 | return clock; |
| 83 | } |
| 84 | // ------------------------------------------------------------------------ |
| 85 | // Operations |
| 86 | // ------------------------------------------------------------------------ |
| 87 | |
| 88 | @Override |
| 89 | public IntegerDefinition createDefinition(IDefinitionScope definitionScope, |
| 90 | String fieldName) { |
| 91 | return new IntegerDefinition(this, definitionScope, fieldName); |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public String toString() { |
| 96 | /* Only used for debugging */ |
| 97 | return "[declaration] integer[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$ |
| 98 | } |
| 99 | |
| 100 | } |