1 package org.sapia.resource; 2 3 import java.io.IOException ; 4 import java.io.InputStream ; 5 import java.util.StringTokenizer ; 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 doInclude(InputStream is, Object o) throws IOException , Exception { 15 String txt = Utils.textStreamToString(is); 16 obj.uri = getUri(); 17 StringTokenizer tk = new StringTokenizer (txt); 18 while(tk.hasMoreTokens()){ 19 String token = tk.nextToken(); 20 if(token.startsWith("#") && token.endsWith("#")){ 21 String 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 |