KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > resource > TestIncludeContext


1 package org.sapia.resource;
2
3 import java.io.IOException JavaDoc;
4 import java.io.InputStream JavaDoc;
5 import java.util.StringTokenizer JavaDoc;
6
7 import org.sapia.resource.include.IncludeContext;
8 import org.sapia.resource.include.IncludeState;
9
10 public class TestIncludeContext extends IncludeContext{
11   
12   TestIncludedObject obj = new TestIncludedObject();
13   
14   protected Object JavaDoc doInclude(InputStream JavaDoc is, Object JavaDoc o) throws IOException JavaDoc, Exception JavaDoc {
15     String JavaDoc txt = Utils.textStreamToString(is);
16     obj.uri = getUri();
17     StringTokenizer JavaDoc tk = new StringTokenizer JavaDoc(txt);
18     while(tk.hasMoreTokens()){
19       String JavaDoc token = tk.nextToken();
20       if(token.startsWith("#") && token.endsWith("#")){
21         String JavaDoc uri = token.substring(1, token.length() - 1);
22         obj.children.add(IncludeState.createContext(uri, getConfig()).include());
23       }
24     }
25     return obj;
26     
27   }
28
29 }
30
Popular Tags