KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > za > org > coefficient > core > HardURLConverter


1 /*
2  * Coefficient - facilitates project based collaboration
3  * Copyright (C) 2003, Dylan Etkin, CSIR icomtek
4  * PO Box 395
5  * Pretoria 0001, RSA
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package za.org.coefficient.core;
21
22 /**
23  *
24  * @version $Revision: 1.1 $ $Date: 2004/09/28 15:17:05 $
25  * @author <a HREF="mailto:detkin@csir.co.za">Dylan Etkin</a>
26  */

27 public abstract class HardURLConverter {
28
29     //~ Instance fields ========================================================
30

31     /** The sibling of this interceptor */
32     private HardURLConverter sibling;
33
34     //~ Methods ================================================================
35

36     public void setSibling(HardURLConverter val) {
37         this.sibling = val;
38     }
39
40     public HardURLConverter getSibling() {
41         return sibling;
42     }
43
44     public void append(HardURLConverter val) {
45         last().setSibling(val);
46     }
47
48     public String JavaDoc invoke(String JavaDoc url) throws Exception JavaDoc {
49
50         // Do the work of the invoke
51
String JavaDoc result = handleInvoke(url);
52         
53         // And do the next sibling, as necessary
54
if(result == null) {
55             if (sibling != null) {
56                 result = sibling.invoke(url);
57             }
58         }
59
60         return result;
61     }
62
63     public HardURLConverter last() {
64         HardURLConverter result = this;
65         if (sibling != null) {
66             do {
67                 result = result.sibling;
68             } while (result.sibling != null);
69         }
70
71         return result;
72     }
73
74     protected String JavaDoc handleInvoke(String JavaDoc url) throws Exception JavaDoc {
75         return null;
76     }
77 }
78
Popular Tags