1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.ctf
.core
.event
.types
;
16 * Parent of sequences and arrays
18 * @author Matthew Khouzam
20 public abstract class CompoundDeclaration
extends Declaration
{
22 private static final int BIT_MASK
= 0x03;
23 private static final int BITS_PER_BYTE
= 8;
26 * Get the element type
28 * @return the type of element in the array
30 public abstract IDeclaration
getElementType();
33 public long getAlignment() {
34 return getElementType().getAlignment();
38 * Sometimes, strings are encoded as an array of 1-byte integers (each one
39 * being an UTF-8 byte).
41 * @return true if this array is in fact an UTF-8 string. false if it's a
42 * "normal" array of generic Definition's.
44 public boolean isString() {
45 IDeclaration elementType
= getElementType();
46 if (elementType
instanceof IntegerDeclaration
) {
47 IntegerDeclaration elemInt
= (IntegerDeclaration
) elementType
;
48 return elemInt
.isCharacter();
54 * If an array contains 8 bit aligned 8 bit ints, it can be bulk read.
56 * @return true if this array 1 byte aligned. false if it's a "normal" array
57 * of generic Definition's.
60 public boolean isAlignedBytes() {
61 IDeclaration elementType
= getElementType();
62 if (elementType
instanceof IntegerDeclaration
) {
63 IntegerDeclaration elemInt
= (IntegerDeclaration
) elementType
;
64 return (elemInt
.getLength() == BITS_PER_BYTE
) && ((getAlignment() & BIT_MASK
) == 0);