ss: Expose method to get an attribute's path as a string array
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 24 Mar 2015 22:26:55 +0000 (18:26 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 24 Mar 2015 23:34:41 +0000 (19:34 -0400)
Most attribute-creation methods use string arrays (or varargs
parameters), it'd be nice to be able to get the same array back.

Change-Id: I8948d0d2120e24be5ba0ed72d0cb951d278f4e14
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/44543
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Hudson CI
org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/Attribute.java
org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java
org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java
org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java

index acdd8d74849c05b291589815f165d65c1b61a7ba..6d2350b96d17310bddd5a63e58996a0401541e72 100644 (file)
@@ -196,9 +196,9 @@ public final class Attribute {
      * Return a String array composed of the full (absolute) path representing
      * this attribute
      *
-     * @return
+     * @return The full attribute path elements
      */
-    private String[] getFullAttribute() {
+    public @NonNull String[] getFullAttribute() {
         LinkedList<String> list = new LinkedList<>();
         Attribute curNode = this;
 
@@ -208,7 +208,7 @@ public final class Attribute {
             curNode = curNode.parent;
         }
 
-        return list.toArray(new String[0]);
+        return checkNotNull(list.toArray(new String[0]));
     }
 
     /**
index e6bad64d3d6c4e91652ead22229f158c3578063d..ad3682c18a540e5b43a6ad4a633de3d9b37d74c4 100644 (file)
@@ -394,6 +394,18 @@ public final class AttributeTree {
         return attributeList.get(quark).getFullAttributeName();
     }
 
+    /**
+     * Get the full path name (as an array of path elements) of an attribute
+     * specified by a quark.
+     *
+     * @param quark
+     *            The quark of the attribute
+     * @return The path elements of the full path
+     */
+    public @NonNull String[] getFullAttributePathArray(int quark) {
+        return attributeList.get(quark).getFullAttribute();
+    }
+
     /**
      * Debug-print all the attributes in the tree.
      *
index 2ab23007590920479a728e809fabcb2eb0df9a68..09ce7cbef3cdc3b0a3372e306df3fed70516d5f4 100644 (file)
@@ -180,6 +180,11 @@ public class StateSystem implements ITmfStateSystemBuilder {
         return getAttributeTree().getFullAttributeName(attributeQuark);
     }
 
+    @Override
+    public String[] getFullAttributePathArray(int attributeQuark) {
+        return getAttributeTree().getFullAttributePathArray(attributeQuark);
+    }
+
     //--------------------------------------------------------------------------
     //        Methods related to the storage backend
     //--------------------------------------------------------------------------
index 593f67f78355ec671c63f9b1378942dcb416f7b7..9cb4c23772c38d8bd4ced6f02c447655bd9acb15 100644 (file)
@@ -104,6 +104,10 @@ public interface ITmfStateSystem {
      */
     void dispose();
 
+    // ------------------------------------------------------------------------
+    // Read-only quark-getting methods
+    // ------------------------------------------------------------------------
+
     /**
      * Return the current total amount of attributes in the system. This is also
      * equal to the quark that will be assigned to the next attribute that's
@@ -113,10 +117,6 @@ public interface ITmfStateSystem {
      */
     int getNbAttributes();
 
-    /**
-     * @name Read-only quark-getting methods
-     */
-
     /**
      * Basic quark-retrieving method. Pass an attribute in parameter as an array
      * of strings, the matching quark will be returned.
@@ -248,6 +248,19 @@ public interface ITmfStateSystem {
      */
     @NonNull String getFullAttributePath(int attributeQuark);
 
+    /**
+     * Return the full attribute path, as an array of strings representing each
+     * element.
+     *
+     * @param attributeQuark
+     *            The quark of the attribute we want.
+     * @return The array of path elements
+     * @throws IndexOutOfBoundsException
+     *             If the attribute quark is out of range
+     * @since 1.0
+     */
+    @NonNull String[] getFullAttributePathArray(int attributeQuark);
+
     /**
      * Returns the parent quark of the attribute.
      *
@@ -260,9 +273,9 @@ public interface ITmfStateSystem {
      */
     int getParentAttributeQuark(int attributeQuark);
 
-    /**
-     * @name Query methods
-     */
+    // ------------------------------------------------------------------------
+    // Query methods
+    // ------------------------------------------------------------------------
 
     /**
      * Returns the current state value we have (in the Transient State) for the
This page took 0.0442979999999999 seconds and 5 git commands to generate.