KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > util > UrlPattern


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.util;
14
15 import java.io.Serializable JavaDoc;
16
17
18 /**
19  * Pattern interface, used to match URLs.
20  * @author Fabrizio Giustina
21  * @version $Revision: 6341 $ ($Author: philipp $)
22  */

23 public interface UrlPattern extends Serializable JavaDoc {
24
25     /**
26      * Does the patter match the given url?
27      * @param url url to match
28      * @return <code>true</code> if the given URL matches the pattern
29      */

30     boolean match(String JavaDoc url);
31
32     /**
33      * Returns the pattern length. Longer patterns have higher priority.
34      * @return pattern length
35      */

36     int getLength();
37
38     /**
39      * A pattern which matches any input.
40      */

41     UrlPattern MATCH_ALL = new MatchAllPattern();
42
43     /**
44      * A default implementation with matches any input.
45      */

46     public static final class MatchAllPattern implements UrlPattern {
47
48         /**
49          * Stable serialVersionUID.
50          */

51         private static final long serialVersionUID = 222L;
52
53         /**
54          * Instantiates a new MatchAllPattern instance. Use the MATCH_ALL constant and don't create new instances.
55          */

56         protected MatchAllPattern() {
57             // protected contructor
58
}
59
60         /**
61          * @see info.magnolia.cms.util.UrlPattern#match(java.lang.String)
62          */

63         public boolean match(String JavaDoc str) {
64             return true;
65         }
66
67         /**
68          * @see info.magnolia.cms.util.UrlPattern#getLength()
69          */

70         public int getLength() {
71             return 1;
72         }
73
74     }
75 }
76
Popular Tags