Package org.stringtree.template

Examples of org.stringtree.template.StreamStringCollector


    //context.put(MojasefConstants.TEMPLATE_FINDER, this.templates);
  }

  public void request(StringFinder context) {
    OutputStream outstream = (OutputStream)context.getObject(MojasefConstants.RESPONSE_STREAM);
    StreamStringCollector collector = new StreamStringCollector(outstream);

      Tract page = null;
      String filename = context.get(MojasefConstants.REQUEST_LOCALPATH);
      page = (Tract)tracts.getObject(filename);

    if (page == null && ("".equals(filename) || filename.endsWith("/"))) {
        page = (Tract)tracts.getObject(filename+context.get(MojasefConstants.DEFAULT_LEAFNAME));
    }

    if (page == null) {
        page = (Tract)templates.getObject("404");
    }

    if (page == null) {
        page = new MapTract("Oops, 404: ${mojasef.request.path.URI}");
        StorerHelper.put(context, HTTPConstants.RESPONSE_CODE, "404");
    }

    StringFinder result = new FetcherStringFinder(
        new FallbackFetcher(page.getUnderlyingFetcher(), context.getUnderlyingFetcher()));
    Tract template = findTemplate(result);
    engine.expandTemplate(context, template, collector);
    collector.flush();
  }
View Full Code Here

TOP

Related Classes of org.stringtree.template.StreamStringCollector

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.