ctf: Fix some Sonar warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / ArrayDeclaration.java
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 /**
16 * A CTF array declaration
17 *
18 * Arrays are fixed-length. Their length is declared in the type
19 * declaration within the meta-data. They contain an array of "inner type"
20 * elements, which can refer to any type not containing the type of the
21 * array being declared (no circular dependency). The length is the number
22 * of elements in an array.
23 *
24 * @version 1.0
25 * @author Matthew Khouzam
26 * @author Simon Marchi
27 */
28 public class ArrayDeclaration implements IDeclaration {
29
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33
34 private final int length;
35 private final IDeclaration elemType;
36
37 // ------------------------------------------------------------------------
38 // Constructors
39 // ------------------------------------------------------------------------
40
41 /**
42 * Constructor
43 * @param length how many elements in the array
44 * @param elemType what type of element is in the array
45 */
46 public ArrayDeclaration(int length, IDeclaration elemType) {
47 this.length = length;
48 this.elemType = elemType;
49 }
50
51 // ------------------------------------------------------------------------
52 // Getters/Setters/Predicates
53 // ------------------------------------------------------------------------
54
55 /**
56 *
57 * @return the type of element in the array
58 */
59 public IDeclaration getElementType() {
60 return elemType;
61 }
62
63 /**
64 *
65 * @return how many elements in the array
66 */
67 public int getLength() {
68 return length;
69 }
70
71 @Override
72 public long getAlignment() {
73 return getElementType().getAlignment();
74 }
75 // ------------------------------------------------------------------------
76 // Operations
77 // ------------------------------------------------------------------------
78
79 @Override
80 public ArrayDefinition createDefinition(IDefinitionScope definitionScope,
81 String fieldName) {
82 return new ArrayDefinition(this, definitionScope, fieldName);
83 }
84
85 @Override
86 public String toString() {
87 /* Only used for debugging */
88 return "[declaration] array[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
89 }
90
91 }
This page took 0.032409 seconds and 6 git commands to generate.