KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > archie > strategy > DefaultLookupStrategy


1 package org.sapia.archie.strategy;
2
3 import org.sapia.archie.Name;
4 import org.sapia.archie.NamePart;
5 import org.sapia.archie.Node;
6 import org.sapia.archie.NotFoundException;
7 import org.sapia.archie.ProcessingException;
8
9
10 /**
11  * Looks up a value, given a name. Searches from a given node, following
12  * the path evaluated from that node.
13  *
14  * @author Yanick Duchesne
15  *
16  * <dl>
17  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
18  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
19  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
20  * </dl>
21  */

22 public class DefaultLookupStrategy extends DefaultLookupNodeStrategy {
23   public DefaultLookupStrategy() {
24     super(false);
25   }
26
27   /**
28    * @see LookupStrategy#lookup(Name, Node)
29    */

30   public Object JavaDoc lookup(Name n, Node from)
31                 throws NotFoundException, ProcessingException {
32     NamePart last = n.chopLast();
33     Node node = (Node) super.lookup(n, from);
34
35     Object JavaDoc value = node.getValue(last);
36
37     if (value == null) {
38       throw new NotFoundException(n.toString());
39     }
40
41     return value;
42   }
43 }
44
Popular Tags