853605248cef2d94bcec81441cfb9cde5f184cbd
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / StringDefinition.java
1 /*******************************************************************************
2 * Copyright (c) 2011, 2013 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 org.eclipse.jdt.annotation.NonNull;
16 import org.eclipse.linuxtools.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 * @version 1.0
26 * @author Matthew Khouzam
27 * @author Simon Marchi
28 */
29 public final class StringDefinition extends Definition {
30
31 // ------------------------------------------------------------------------
32 // Attributes
33 // ------------------------------------------------------------------------
34
35 private final String fString;
36
37 // ------------------------------------------------------------------------
38 // Constructors
39 // ------------------------------------------------------------------------
40
41 /**
42 * Constructor
43 *
44 * @param declaration
45 * the parent declaration
46 * @param definitionScope
47 * the parent scope
48 * @param fieldName
49 * the field name
50 * @param value
51 * The String value
52 * @since 3.0
53 */
54 public StringDefinition(@NonNull StringDeclaration declaration,
55 IDefinitionScope definitionScope, @NonNull String fieldName, String value) {
56 super(declaration, definitionScope, fieldName);
57 fString = value;
58 }
59
60 // ------------------------------------------------------------------------
61 // Getters/Setters/Predicates
62 // ------------------------------------------------------------------------
63
64 @Override
65 public StringDeclaration getDeclaration() {
66 return (StringDeclaration) super.getDeclaration();
67 }
68
69 /**
70 * Gets the string (value)
71 *
72 * @return the string
73 */
74 public String getValue() {
75 return fString;
76 }
77
78 // ------------------------------------------------------------------------
79 // Operations
80 // ------------------------------------------------------------------------
81
82 @Override
83 public String toString() {
84 return '\"' + getValue() + '\"';
85 }
86
87 }
This page took 0.038761 seconds and 4 git commands to generate.