Commit | Line | Data |
---|---|---|
866e5b51 | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2011, 2013 Ericsson, Ecole Polytechnique de Montreal and others |
866e5b51 FC |
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 | ||
a4fa4e36 MK |
15 | import org.eclipse.jdt.annotation.NonNull; |
16 | import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope; | |
866e5b51 FC |
17 | |
18 | /** | |
d37aaa7f | 19 | * A CTF string definition (similar to a C null-terminated byte array). |
486efb2e | 20 | * |
d37aaa7f FC |
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 | |
866e5b51 | 28 | */ |
a4fa4e36 | 29 | public final class StringDefinition extends Definition { |
866e5b51 FC |
30 | |
31 | // ------------------------------------------------------------------------ | |
32 | // Attributes | |
33 | // ------------------------------------------------------------------------ | |
34 | ||
a4fa4e36 | 35 | private final String fString; |
866e5b51 FC |
36 | |
37 | // ------------------------------------------------------------------------ | |
38 | // Constructors | |
39 | // ------------------------------------------------------------------------ | |
40 | ||
9ac2eb62 MK |
41 | /** |
42 | * Constructor | |
d6205f97 MK |
43 | * |
44 | * @param declaration | |
45 | * the parent declaration | |
46 | * @param definitionScope | |
47 | * the parent scope | |
48 | * @param fieldName | |
49 | * the field name | |
a4fa4e36 MK |
50 | * @param value |
51 | * The String value | |
52 | * @since 3.0 | |
9ac2eb62 | 53 | */ |
a4fa4e36 MK |
54 | public StringDefinition(@NonNull StringDeclaration declaration, |
55 | IDefinitionScope definitionScope, @NonNull String fieldName, String value) { | |
56 | super(declaration, definitionScope, fieldName); | |
57 | fString = value; | |
866e5b51 FC |
58 | } |
59 | ||
60 | // ------------------------------------------------------------------------ | |
61 | // Getters/Setters/Predicates | |
62 | // ------------------------------------------------------------------------ | |
63 | ||
9ac2eb62 | 64 | @Override |
866e5b51 | 65 | public StringDeclaration getDeclaration() { |
a4fa4e36 | 66 | return (StringDeclaration) super.getDeclaration(); |
866e5b51 FC |
67 | } |
68 | ||
9ac2eb62 | 69 | /** |
4f4b6212 | 70 | * Gets the string (value) |
d6205f97 | 71 | * |
4f4b6212 | 72 | * @return the string |
9ac2eb62 | 73 | */ |
4f4b6212 EB |
74 | public String getValue() { |
75 | return fString; | |
866e5b51 FC |
76 | } |
77 | ||
866e5b51 FC |
78 | // ------------------------------------------------------------------------ |
79 | // Operations | |
80 | // ------------------------------------------------------------------------ | |
81 | ||
866e5b51 FC |
82 | @Override |
83 | public String toString() { | |
84 | return '\"' + getValue() + '\"'; | |
85 | } | |
86 | ||
87 | } |