Package org.stringtree

Examples of org.stringtree.Fetcher


            query = req.getContent();
            req.put(Tract.CONTENT, "");
        }
        String url = req.get(MojasefConstants.REQUEST_URI);
        put(MojasefConstants.REQUEST_SELF, withoutQuery(url));
        Fetcher headers = req.getUnderlyingFetcher();
        if (headers instanceof Listable) {
            Listable<String> listable = (Listable<String>)headers;
            Iterator<String> it = listable.list();
            while (it.hasNext()) {
                String key = it.next();
                Object object = headers.getObject(key);
                if (object instanceof String) {
                    String value = (String)object;
                    if (key.startsWith(HTTPConstants.REQUEST_HEADER)) {
                        key = key.substring(HTTPConstants.REQUEST_HEADER.length());
                    }
View Full Code Here


public class CommonContextFallbackTest extends TestCase {
   
    public void testGetFromContext() throws IOException {
        CommonContext context = new RemoteSpecCommonContext("src/test/files/fb/fa.spec");
        Fetcher tpls = (Fetcher)context.getObject(MojasefConstants.TEMPLATE_SOURCE);
        assertEquals("I am aa: ${*hello}", tpls.getObject("home"));
        assertEquals("Hello, ${value}!", tpls.getObject("hello"));
    }
View Full Code Here

      new TractDirectoryRepository(pageDir, false, context),
      new TractDirectoryRepository(tplDir, false, context));
  }

  public void setup(StringFinder context, Fetcher tracts, Fetcher templates) {
    Fetcher oldTemplates = (Fetcher)context.getObject(Templater.TEMPLATE);
    if (oldTemplates != null) {
      templates = new FallbackFetcher(
            templates, oldTemplates);
    } else {
      templates = oldTemplates;
View Full Code Here

  }

    private static Object getTemplate(StringFinder context, String name) {
        Object ret = null;
       
        Fetcher fetcher = (Fetcher) context.getObject(Templater.TEMPLATE_SOURCE);
        if (null != fetcher) ret = fetcher.getObject(name);
        if (null != ret) return ret;
       
        String fullname = Templater.TEMPLATE + "." + name;
        return FetcherHelper.getPeelback(context.getUnderlyingFetcher(), fullname);
    }
View Full Code Here

        return context.get(MojasefConstants.REQUEST_PATHOBJECT);
  }

  public static StringFinder createSubcontext(StringFinder context, String path, String mountpoint) {
      MapFetcher repository = new MapFetcher();
      Fetcher subcontext = new FallbackFetcher(repository, context.getUnderlyingFetcher());
      repository.put(MojasefConstants.MOUNTCONTEXT, getMountContext(context));
      repository.put(MojasefConstants.MOUNTPOINT, mountpoint);
        repository.put(MojasefConstants.REQUEST_LOCALPATH, path);
      return new FetcherStringKeeper(subcontext);
  }
View Full Code Here

      StringFinder context, Object application, Object dfl) throws IOException {
   
    String content = null;
    Token token = Token.CONTINUE;

    Fetcher underlying = context.getUnderlyingFetcher();
    Storer storer = StorerHelper.find(context);
        storer.put(Templater.BASE, context);
       
    if (application != null) {
      StringCollector buffer = new ByteArrayStringCollector();
View Full Code Here

        context.put("value", "thing");
    }
   
    public void select(StringKeeper context) {
        String type = context.get("type");
        Fetcher source = (Fetcher) context.getObject(MojasefConstants.TEMPLATE_SOURCE + "." + type);
        context.put(Templater.TEMPLATE_SOURCE, source);
        context.put("value", "wotsit");
        context.put(MojasefConstants.PAGE_TEMPLATE, "home");
    }
View Full Code Here

  private String getString(String name) {
        return FetcherStringHelper.getString(this, name);
    }

    private Iterator<String> listCookies() {
    Fetcher cookies = ListableHelper.subset(this, new StringPrefixFilter(HTTPConstants.RESPONSE_COOKIE));
    return ListableHelper.list(cookies);
  }
View Full Code Here

    Fetcher cookies = ListableHelper.subset(this, new StringPrefixFilter(HTTPConstants.RESPONSE_COOKIE));
    return ListableHelper.list(cookies);
  }

  private Iterator<String> listHeaders() {
    Fetcher headers = ListableHelper.subset(this, new StringPrefixFilter(HTTPConstants.RESPONSE_HEADER));
    return ListableHelper.list(headers);
  }
View Full Code Here

            System.err.println("Server.appCall unable to locate " + MojasefConstants.HTTP_APPLICATION);
        }
    }
   
    public void request(RequestContext req, OutputCollector res, Object dfl) {
        Fetcher context = new FallbackFetcher(req, common);
       
        try {
            Object file = null;
            res.start();
            String leaf = (String)context.getObject(MojasefConstants.REQUEST_LOCALPATH);
            if (leaf.indexOf(".") > 0) {
                Fetcher pub = (Fetcher)context.getObject(MojasefConstants.FILE_FETCHER);
                file = pub.getObject(leaf);
            }
            if (file != null) {
                String type = mimetype(leaf);
                req.put(HTTPConstants.RESPONSE_CONTENT_TYPE, type);
                res.write((byte[])file);
View Full Code Here

TOP

Related Classes of org.stringtree.Fetcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.