From 50678114fc2daee0edf1046491f1d713464bb9a8 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Fri, 27 Apr 2012 17:20:15 -0400 Subject: [PATCH] tmf: Expose a method to retrieve an attribute's name In the past, the only way to retrieve quarks was to pass its exact name, so it implied we knew the name in the first place... But with wildcard methods like getQuarks(), we won't necessarily know the name of the quarks we receive. This new method will allow the user to do a reverse lookup on the name. Signed-off-by: Alexandre Montplaisir --- .../tmf/core/statesystem/AttributeTree.java | 4 ++++ .../tmf/core/statesystem/StateSystem.java | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java index 2bcbd7d65d..cf36172940 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java @@ -336,6 +336,10 @@ final class AttributeTree { } } + String getAttributeName(int quark) { + return attributeList.get(quark).getName(); + } + String getFullAttributeName(int quark) { if (quark >= attributeList.size() || quark < 0) { return null; diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystem.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystem.java index 3e8d060bf1..dab7ab0bf1 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystem.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystem.java @@ -476,9 +476,9 @@ public class StateSystem { transState.processStateChange(t, TmfStateValue.nullValue(), attributeQuark); } catch (StateValueTypeException e) { - /* - * Will not happen since we're inserting null values only, but - * poor compiler has no way of knowing this... + /* + * Will not happen since we're inserting null values only, but poor + * compiler has no way of knowing this... */ e.printStackTrace(); } @@ -531,6 +531,18 @@ public class StateSystem { transState.changeOngoingStateValue(attributeQuark, newValue); } + /** + * Return the name assigned to this quark. This returns only the "basename", + * not the complete path to this attribute. + * + * @param attributeQuark + * The quark for which we want the name + * @return The name of the quark + */ + public String getAttributeName(int attributeQuark) { + return attributeTree.getAttributeName(attributeQuark); + } + /** * @name Debugging methods */ -- 2.34.1