ctf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.ctf.core / src / org / eclipse / tracecompass / ctf / core / event / types / StringDefinition.java
1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 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.tracecompass.ctf.core.event.types;
14
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
17
18 /**
19 * A CTF string definition (similar to a C null-terminated byte array).
20 *
21 * Strings are an array of bytes of variable size and are terminated by a '\0'
22 * "NULL" character. Their encoding is described in the TSDL meta-data. In
23 * absence of encoding attribute information, the default encoding is UTF-8.
24 *
25 * @author Matthew Khouzam
26 * @author Simon Marchi
27 */
28 public final class StringDefinition extends Definition {
29
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33
34 private final String fString;
35
36 // ------------------------------------------------------------------------
37 // Constructors
38 // ------------------------------------------------------------------------
39
40 /**
41 * Constructor
42 *
43 * @param declaration
44 * the parent declaration
45 * @param definitionScope
46 * the parent scope
47 * @param fieldName
48 * the field name
49 * @param value
50 * The String value
51 */
52 public StringDefinition(@NonNull StringDeclaration declaration,
53 IDefinitionScope definitionScope, @NonNull String fieldName, String value) {
54 super(declaration, definitionScope, fieldName);
55 fString = value;
56 }
57
58 // ------------------------------------------------------------------------
59 // Getters/Setters/Predicates
60 // ------------------------------------------------------------------------
61
62 @Override
63 public StringDeclaration getDeclaration() {
64 return (StringDeclaration) super.getDeclaration();
65 }
66
67 /**
68 * Gets the string (value)
69 *
70 * @return the string
71 */
72 public String getValue() {
73 return fString;
74 }
75
76 // ------------------------------------------------------------------------
77 // Operations
78 // ------------------------------------------------------------------------
79
80 @Override
81 public String toString() {
82 return '\"' + getValue() + '\"';
83 }
84
85 }
This page took 0.053067 seconds and 5 git commands to generate.