KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > util > matcher > PathToken


1 package org.sapia.soto.util.matcher;
2
3 import java.util.Stack JavaDoc;
4
5
6 /**
7  * @author Yanick Duchesne
8  * <dl>
9  * <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>
10  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
11  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
12  * </dl>
13  */

14 public class PathToken extends AbstractPatternElement {
15   /**
16    * Constructor for PathPattern.
17    */

18   public PathToken() {
19     super();
20   }
21
22   /**
23    * @see org.sapia.soto.util.matcher.PatternElement#matches(Stack)
24    */

25   public boolean matches(Stack JavaDoc tokens) {
26     while (tokens.size() > 0) {
27       if (_next == null) {
28         return true;
29       }
30
31       if (tokens.size() <= 1) {
32         return _next.matches(tokens);
33       }
34
35       Stack JavaDoc newStack = new Stack JavaDoc();
36       newStack.addAll(tokens);
37
38       if (_next.matches(newStack)) {
39         return true;
40       } else {
41         tokens.pop();
42       }
43     }
44
45     return true;
46   }
47 }
48
Popular Tags