d57229fca04c15e75b39243c173cfd0bd0af41be
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / StringDeclaration.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 * <b><u>StringDeclaration</u></b>
17 */
18 public class StringDeclaration implements IDeclaration {
19
20 // ------------------------------------------------------------------------
21 // Attributes
22 // ------------------------------------------------------------------------
23
24 private Encoding encoding = Encoding.UTF8;
25
26 // ------------------------------------------------------------------------
27 // Constructors
28 // ------------------------------------------------------------------------
29
30 /**
31 * Generate a UTF8 string declaration
32 */
33 public StringDeclaration() {
34 }
35
36 /**
37 * generate an encoded string declaration
38 * @param encoding the encoding, utf8 or ascii
39 */
40 public StringDeclaration(Encoding encoding) {
41 this.encoding = encoding;
42 }
43
44 // ------------------------------------------------------------------------
45 // Getters/Setters/Predicates
46 // ------------------------------------------------------------------------
47
48 /**
49 *
50 * @return the character encoding.
51 */
52 public Encoding getEncoding() {
53 return encoding;
54 }
55
56 /**
57 *
58 * @param encoding the character encoding to set
59 */
60 public void setEncoding(Encoding encoding) {
61 this.encoding = encoding;
62 }
63
64 @Override
65 public long getAlignment() {
66 return 8; //FIXME: should be the elementtype.
67 }
68 // ------------------------------------------------------------------------
69 // Operations
70 // ------------------------------------------------------------------------
71
72 @Override
73 public StringDefinition createDefinition(IDefinitionScope definitionScope,
74 String fieldName) {
75 return new StringDefinition(this, definitionScope, fieldName);
76 }
77
78 @Override
79 public String toString() {
80 /* Only used for debugging */
81 return "[declaration] string[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
82 }
83
84 }
This page took 0.031282 seconds and 5 git commands to generate.