Commit | Line | Data |
---|---|---|
5d10d135 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2010 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made 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: | |
10 | * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | package org.eclipse.linuxtools.lttng.model; | |
13 | ||
14 | import org.eclipse.core.runtime.IAdaptable; | |
15 | ||
16 | /** | |
17 | * @author alvaro | |
18 | * | |
19 | */ | |
20 | public interface ILTTngTreeNode<E extends ILTTngTreeNode<E>> extends IAdaptable { | |
21 | // ======================================================================== | |
22 | // Methods | |
23 | // ======================================================================== | |
24 | /** | |
25 | * Return the unique id of this resource | |
26 | * | |
27 | * @return | |
28 | */ | |
29 | public Long getId(); | |
30 | ||
31 | /** | |
32 | * Types are defined by the user application | |
33 | * | |
34 | * @return | |
35 | */ | |
36 | public Object getType(); | |
37 | ||
38 | /** | |
39 | * Return this resource name | |
40 | * | |
41 | * @return | |
42 | */ | |
43 | public E getChildByName(String name); | |
44 | ||
45 | /** | |
46 | * @param k | |
47 | * k needed for the creation of the generic array | |
48 | * @return | |
49 | */ | |
50 | public E[] getChildren(); | |
51 | ||
52 | /** | |
53 | * Get the child by its unique id | |
54 | * | |
55 | * @param id | |
56 | * @return | |
57 | */ | |
58 | public E getChildById(Long id); | |
59 | ||
60 | /** | |
61 | * Get the parent of this resource | |
62 | * | |
63 | * @return | |
64 | */ | |
65 | public E getParent(); | |
66 | ||
67 | /** | |
68 | * @return | |
69 | */ | |
70 | public boolean hasChildren(); | |
71 | ||
72 | /** | |
73 | * Return the name of this resource | |
74 | * | |
75 | * @return | |
76 | */ | |
77 | public String getName(); | |
78 | ||
79 | /** | |
80 | * <p> | |
81 | * Get the path from parent resources to this resource | |
82 | * </p> | |
83 | * <p> | |
84 | * e.g. /root/name1/name2 | |
85 | * </p> | |
86 | * | |
87 | * @return | |
88 | */ | |
89 | public String getPath(); | |
90 | ||
91 | /** | |
92 | * Return the reference value associated to this tree node | |
93 | * | |
94 | * @return | |
95 | */ | |
96 | public Object getValue(); | |
97 | ||
98 | /** | |
99 | * returns the next value to be used as unique id in reference to this | |
100 | * instance e.g. can be used to construct children unique ids. | |
101 | */ | |
102 | public Long getNextUniqueId(); | |
103 | ||
104 | /** | |
105 | * Returns an attribute by name and casts the attribute value to the | |
106 | * specified type, returns null if the attribute itself is null, not and | |
107 | * instance of the specified class or the attribute has not been added | |
108 | * | |
109 | * @return | |
110 | */ | |
111 | public <T> T getAttribute(String name, Class<T> type); | |
112 | ||
113 | /** | |
114 | * Adds an attribute by name and which is not a tree node element | |
115 | * | |
116 | * @return true if the element was not added e.g. invalid input | |
117 | */ | |
118 | public boolean addAttribute(String name, Object attribute); | |
119 | } |