| author | Alexandre Montplaisir | 2012-03-20 13:00:34 (EDT) |
|---|---|---|
| committer | Francois Chouinard | 2012-03-27 13:52:19 (EDT) |
| commit | b3a1756d657675294e3e1eb4c0c458237f73271a (patch) (side-by-side diff) | |
| tree | d846da108140413db844ad430a525066ce78520c | |
| parent | a4b430044e55df80cdca1ece717968a5c7e0da99 (diff) | |
| download | org.eclipse.linuxtools-b3a1756d657675294e3e1eb4c0c458237f73271a.zip org.eclipse.linuxtools-b3a1756d657675294e3e1eb4c0c458237f73271a.tar.gz org.eclipse.linuxtools-b3a1756d657675294e3e1eb4c0c458237f73271a.tar.bz2 | |
Expose the getSubAttributes() method through the StateSystem
Signed-off-by: Alexandre Montplaisir <alexandre.montplaisir@polymtl.ca>
2 files changed, 43 insertions, 5 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java index 7cbb7a0..baa4528 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AttributeTree.java @@ -64,7 +64,7 @@ final class AttributeTree { /* Message for exceptions, shouldn't be externalized */ final String errorMessage = "The attribute tree file section is either invalid or corrupted."; //$NON-NLS-1$ - + ArrayList<String[]> list = new ArrayList<String[]>(); byte[] curByteArray; String curFullString; @@ -281,12 +281,35 @@ final class AttributeTree { return attributeList.get(quark).getSubAttributesList().size(); } - ArrayList<Integer> getSubAttributes(int attributeQuark) { - ArrayList<Integer> listOfChildren = new ArrayList<Integer>(); - - for (Attribute childNode : attributeList.get(attributeQuark).getSubAttributesList()) { + /** + * Returns the sub-attributes of the quark passed in parameter + * + * @param attributeQuark + * @return + * @throws AttributeNotFoundException + */ + List<Integer> getSubAttributes(int attributeQuark) + throws AttributeNotFoundException { + List<Integer> listOfChildren = new ArrayList<Integer>(); + Attribute startingAttribute; + + /* Check if the quark is valid */ + if ( attributeQuark < 0 || attributeQuark >= attributeList.size()) { + throw new AttributeNotFoundException(); + } + + /* Set up the node from which we'll start the search */ + if ( attributeQuark == -1 ) { + startingAttribute = attributeTreeRoot; + } else { + startingAttribute = attributeList.get(attributeQuark); + } + + /* Iterate through the sub-attributes and add them to the list */ + for (Attribute childNode : startingAttribute.getSubAttributesList()) { listOfChildren.add(childNode.getQuark()); } + return listOfChildren; } diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystem.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystem.java index 0d24cb7..5608e34 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystem.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystem.java @@ -136,6 +136,21 @@ public class StateSystem { } /** + * Return the sub-attributes of the target attribute, as a List of quarks. + * + * @param quark + * The attribute of which you want to sub-attributes. You can use + * "-1" here to specify the root node. + * @return A List of integers, matching the quarks of the sub-attributes. + * @throws AttributeNotFoundException + * If the quark was not existing or invalid. + */ + public List<Integer> getSubAttributes(int quark) + throws AttributeNotFoundException { + return attributeTree.getSubAttributes(quark); + } + + /** * @name External methods related to insertions in the history - */ |

