diff options
author | Matthew Khouzam | 2014-07-08 20:04:30 +0000 |
---|---|---|
committer | Matthew Khouzam | 2014-07-10 01:29:15 +0000 |
commit | abb1286cd2021fa1e887d4cbdb1ab8a43fc47254 (patch) | |
tree | 0aabdf1c3856cc47cff858ac8534cb642aaa51af /lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf | |
parent | cfc5cb3b9b2d1aa61c84926c02878248473121df (diff) | |
download | org.eclipse.linuxtools-abb1286cd2021fa1e887d4cbdb1ab8a43fc47254.tar.gz org.eclipse.linuxtools-abb1286cd2021fa1e887d4cbdb1ab8a43fc47254.tar.xz org.eclipse.linuxtools-abb1286cd2021fa1e887d4cbdb1ab8a43fc47254.zip |
ctf: introducing the ICompositeDefinition
This is a definition that contains subfields.
Change-Id: I347de51cb12022262891b59c00d0342c52bc7439
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/29628
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Hudson CI
Diffstat (limited to 'lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf')
3 files changed, 49 insertions, 19 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java index e56b9d6812..97e67908b5 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java +++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java @@ -69,7 +69,8 @@ public abstract class Definition implements IDefinition { } /** - * Constructor This one takes the scope and thus speeds up definition creation + * Constructor This one takes the scope and thus speeds up definition + * creation * * * @param declaration @@ -85,7 +86,7 @@ public abstract class Definition implements IDefinition { * the scope * @since 3.1 */ - public Definition(@NonNull IDeclaration declaration, IDefinitionScope definitionScope, @NonNull String fieldName, LexicalScope scope) { + public Definition(@NonNull IDeclaration declaration, IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull LexicalScope scope) { fDeclaration = declaration; fDefinitionScope = definitionScope; fFieldName = fieldName; diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ICompositeDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ICompositeDefinition.java new file mode 100644 index 0000000000..12b122ea47 --- /dev/null +++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ICompositeDefinition.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.ctf.core.event.types; + +import java.util.List; + +/** + * Interface for data definitions containing heterogenous definitions + * (subfields) + * + * @author Matthew Khouzam + * @since 3.1 + */ +public interface ICompositeDefinition extends IDefinition { + + /** + * Gets the definition of the field + * + * @param fieldName + * the fieldname + * @return The definitions of all the fields + */ + Definition getDefinition(String fieldName); + + /** + * Gets an array of the field names + * + * @return the field names array + */ + List<String> getFieldNames(); + +}
\ No newline at end of file diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java index fde0ef4431..c91b570c6c 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java +++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java @@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableMap.Builder; * @author Matthew Khouzam * @author Simon Marchi */ -public final class StructDefinition extends ScopedDefinition { +public final class StructDefinition extends ScopedDefinition implements ICompositeDefinition { // ------------------------------------------------------------------------ // Attributes @@ -130,7 +130,7 @@ public final class StructDefinition extends ScopedDefinition { super(declaration, definitionScope, structFieldName, scope); fFieldNames = ImmutableList.copyOf(fieldNames); fDefinitions = definitions; - if (fFieldNames == null) { + if (fFieldNames.isEmpty()) { fDefinitionsMap = Collections.EMPTY_MAP; } } @@ -139,14 +139,7 @@ public final class StructDefinition extends ScopedDefinition { // Getters/Setters/Predicates // ------------------------------------------------------------------------ - /** - * Gets the definition of the field - * - * @param fieldName - * the fieldname - * @return The definitions of all the fields - * @since 3.0 - */ + @Override public Definition getDefinition(String fieldName) { if (fDefinitionsMap == null) { /* Build the definitions map */ @@ -158,16 +151,10 @@ public final class StructDefinition extends ScopedDefinition { } fDefinitionsMap = mapBuilder.build(); } - return fDefinitionsMap.get(fieldName); } - /** - * Gets an array of the field names - * - * @return the field names array - * @since 3.0 - */ + @Override public List<String> getFieldNames() { return fFieldNames; } |