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.impl.groovy.closure;
021    
022    import org.crsh.shell.impl.command.AbstractInvocationContext;
023    import org.crsh.shell.impl.command.spi.CommandException;
024    import org.crsh.text.Screenable;
025    import org.crsh.shell.impl.command.spi.CommandInvoker;
026    import org.crsh.command.InvocationContext;
027    import org.crsh.text.RenderPrintWriter;
028    import org.crsh.text.Style;
029    
030    import java.io.IOException;
031    import java.util.Map;
032    
033    class PipeLineInvocationContext extends AbstractInvocationContext<Object> {
034    
035      /** . */
036      final InvocationContext<Object> outter;
037    
038      PipeLineInvocationContext(InvocationContext<Object> outter) {
039    
040        //
041        this.outter = outter;
042      }
043    
044      public CommandInvoker<?, ?> resolve(String s) throws CommandException {
045        return outter.resolve(s);
046      }
047    
048      public int getWidth() {
049        return outter.getWidth();
050      }
051    
052      public int getHeight() {
053        return outter.getHeight();
054      }
055    
056      public boolean takeAlternateBuffer() throws IOException {
057        return outter.takeAlternateBuffer();
058      }
059    
060      public boolean releaseAlternateBuffer() throws IOException {
061        return outter.releaseAlternateBuffer();
062      }
063    
064      public String getProperty(String propertyName) {
065        return outter.getProperty(propertyName);
066      }
067    
068      public String readLine(String msg, boolean echo) throws IOException, InterruptedException {
069        return outter.readLine(msg, echo);
070      }
071    
072      public RenderPrintWriter getWriter() {
073        return outter.getWriter();
074      }
075    
076      public Class<Object> getConsumedType() {
077        return Object.class;
078      }
079    
080      public Screenable append(CharSequence s) throws IOException {
081        outter.append(s);
082        return this;
083      }
084    
085      public Appendable append(char c) throws IOException {
086        outter.append(c);
087        return this;
088      }
089    
090      public Appendable append(CharSequence csq, int start, int end) throws IOException {
091        outter.append(csq, start, end);
092        return this;
093      }
094    
095      public Screenable append(Style style) throws IOException {
096        outter.append(style);
097        return this;
098      }
099    
100      public Screenable cls() throws IOException {
101        outter.cls();
102        return  this;
103      }
104    
105      public void provide(Object element) throws Exception {
106        outter.provide(element);
107      }
108    
109      public void flush() throws IOException {
110        outter.flush();
111      }
112    
113      public void close() {
114        // Nothing to do
115      }
116    
117      public Map<String, Object> getSession() {
118        return outter.getSession();
119      }
120    
121      public Map<String, Object> getAttributes() {
122        return outter.getAttributes();
123      }
124    }