001    /*
002     * Copyright (C) 2012 eXo Platform SAS.
003     *
004     * This is free software; you can redistribute it and/or modify it
005     * under the terms of the GNU Lesser General Public License as
006     * published by the Free Software Foundation; either version 2.1 of
007     * the License, or (at your option) any later version.
008     *
009     * This software is distributed in the hope that it will be useful,
010     * but WITHOUT ANY WARRANTY; without even the implied warranty of
011     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012     * Lesser General Public License for more details.
013     *
014     * You should have received a copy of the GNU Lesser General Public
015     * License along with this software; if not, write to the Free
016     * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
017     * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
018     */
019    
020    package org.crsh.lang.groovy.closure;
021    
022    import org.crsh.command.CommandInvoker;
023    import org.crsh.command.InvocationContext;
024    import org.crsh.command.ScriptException;
025    import org.crsh.text.Chunk;
026    import org.crsh.text.RenderPrintWriter;
027    
028    import java.io.IOException;
029    import java.util.Map;
030    
031    class PipeLineInvocationContext implements InvocationContext<Object> {
032    
033      /** . */
034      final InvocationContext<Object> outter;
035    
036      /** . */
037      private final boolean piped;
038    
039      PipeLineInvocationContext(
040          InvocationContext<Object> outter,
041          boolean piped) {
042    
043        //
044        this.outter = outter;
045        this.piped = piped;
046      }
047    
048      public boolean isPiped() {
049        return piped;
050      }
051    
052      public CommandInvoker<?, ?> resolve(String s) throws ScriptException, IOException {
053        return outter.resolve(s);
054      }
055    
056      public int getWidth() {
057        return outter.getWidth();
058      }
059    
060      public int getHeight() {
061        return outter.getHeight();
062      }
063    
064      public boolean takeAlternateBuffer() throws IOException {
065        return outter.takeAlternateBuffer();
066      }
067    
068      public boolean releaseAlternateBuffer() throws IOException {
069        return outter.releaseAlternateBuffer();
070      }
071    
072      public String getProperty(String propertyName) {
073        return outter.getProperty(propertyName);
074      }
075    
076      public String readLine(String msg, boolean echo) {
077        return outter.readLine(msg, echo);
078      }
079    
080      public RenderPrintWriter getWriter() {
081        return outter.getWriter();
082      }
083    
084      public Class<Object> getConsumedType() {
085        return Object.class;
086      }
087    
088      public void write(Chunk chunk) throws IOException {
089        outter.write(chunk);
090      }
091    
092      public void provide(Object element) throws IOException {
093        outter.provide(element);
094      }
095    
096      public void flush() throws IOException {
097        outter.flush();
098      }
099    
100      public void close() throws IOException {
101        // Nothing to do
102      }
103    
104      public Map<String, Object> getSession() {
105        return outter.getSession();
106      }
107    
108      public Map<String, Object> getAttributes() {
109        return outter.getAttributes();
110      }
111    }