KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > regis > Node


1 package org.sapia.regis;
2
3 import java.util.Collection JavaDoc;
4 import java.util.Map JavaDoc;
5
6 /**
7  * A instance of this class holds configuration properties (consisting
8  * of name/value pairs). It has a composite, recursive structure: it
9  * can potentially contain other nodes, and so on.
10  * <p>
11  * In addition, an instance of this class supports the concepts of
12  * links and includes.
13  *
14  * @author yduchesne
15  *
16  */

17 public interface Node {
18   
19   public static final String JavaDoc ROOT_NAME = "";
20   
21   /**
22    * @return this instance's name.
23    */

24   public String JavaDoc getName();
25   
26   /**
27    * @return the type of this node.
28    */

29   public String JavaDoc getType();
30   
31   /**
32    * @return this instance's absolute <code>Path</code>.
33    */

34   public Path getAbsolutePath();
35   
36   /**
37    * This method returns a checksum based on the last modification time of this
38    * instance and of this parents and links, if any.
39    *
40    * @return a <code>long</code> corresponding to a checksum.
41    */

42   public long lastModifChecksum();
43   
44   /**
45    * @return this instance's parent - or <code>null</code> if this instance is the root.
46    */

47   public Node getParent();
48   
49   /**
50    * @return <code>true</code> if this instance is the root.
51    */

52   public boolean isRoot();
53   
54   /**
55    * @return <code>true</code> if this instance inherits its parent node (if any).
56    */

57   public boolean isInheritsParent();
58
59   /**
60    * @param prepended if <code>true</code>, returns this instance's prepended links, else,
61    * returns this instance's appended links.
62    * @return a <code>Collection</code> of <code>Node</code>s.
63    */

64   public Collection JavaDoc getLinks(boolean prepended);
65   
66   /**
67    * @return the <code>Collection</code> of <code>Node</code>s that have been included
68    * in this instance.
69    */

70   public Collection JavaDoc getIncludes();
71   
72   /**
73    * @param key a property key.
74    * @return a <code>Property</code> corresponding to the given key (if no corresponding property
75    * corresponds to the given key, the returned property's <code>isNull()</code> method returns
76    * <code>true</code>).
77    */

78   public Property getProperty(String JavaDoc key);
79   
80   /**
81    * This method returns the property corresponding to the given key. If the
82    * property's value holds a variable or many variables (in the ${varName} notation), these
83    * variables are rendered prior to the property being returned - the client application
84    * will thus not "see" the variables.
85    * <p>
86    * Variable values are search as follows:
87    * <ul>
88    * <li>First, if this instance inherits from its parent, the variable is
89    * </ul>
90    * <p>
91    * If any variable could not be rendered, then it is left in its original notation.
92    *
93    * @param key a property key.
94    * @return a <code>Property</code> corresponding to the given key (if no corresponding property
95    * corresponds to the given key, the returned property's <code>isNull()</code> method returns
96    * <code>true</code>).
97    */

98   public Property renderProperty(String JavaDoc key);
99   
100   /**
101    * @param values a <code>Map</code> of properties (name/value pairs) to be used internally
102    * by this method's interpolation logic.
103    * @see #renderProperty(String)
104    */

105   public Property renderProperty(String JavaDoc key, Map JavaDoc values);
106   
107   /**
108    * @return the <code>Collection</code> of keys of the properties held by this instance.
109    */

110   public Collection JavaDoc getPropertyKeys();
111   
112   /**
113    * Returns this instance's properties. Variable interpolation is performed prior to returning the
114    * properties.
115    *
116    * @return the <code>Map</code> holding a copy of the configuration properties held by this instance.
117    */

118   public Map JavaDoc getProperties();
119   
120   /**
121    * @param values a <code>Map</code> of properties (name/value pairs) to be used internally
122    * by this method's interpolation logic.
123    * @see #getProperties()
124    */

125   public Map JavaDoc getProperties(Map JavaDoc values);
126   
127   /**
128    * @param name the name of the child to acquire.
129    * @return the child <code>Node</code>, or <code>null</code> if no such child exists.
130    */

131   public Node getChild(String JavaDoc name);
132   
133   /**
134    * @param path the <code>Path</code> corresponding to the child to create.
135    * @return the child <code>Node</code>, or <code>null</code> if no such child exists.
136    */

137   public Node getChild(Path path);
138   
139   /**
140    * @return the <code>Collection</code> of child <code>Node</code>s of this instance.
141    */

142   public Collection JavaDoc getChildren();
143   
144   /**
145    * @param query a <code>Query</code>
146    * @return a <code>Collection</code> of <code>Node</code>s that match
147    * the given query.
148    */

149   public Collection JavaDoc getNodes(Query query);
150   
151 }
152
Popular Tags