Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //
  //  ========================================================================
  //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
  //  ------------------------------------------------------------------------
  //  All rights reserved. This program and the accompanying materials
  //  are made available under the terms of the Eclipse Public License v1.0
  //  and Apache License v2.0 which accompanies this distribution.
  //
  //      The Eclipse Public License is available at
 //      http://www.eclipse.org/legal/epl-v10.html
 //
 //      The Apache License v2.0 is available at
 //      http://www.opensource.org/licenses/apache2.0.php
 //
 //  You may elect to redistribute this code under either of these licenses.
 //  ========================================================================
 //
 
 
 package org.eclipse.jetty.io.bio;
 
 
 
 public class StreamEndPoint implements EndPoint
 {
     InputStream _in;
     OutputStream _out;
     int _maxIdleTime;
     boolean _ishut;
     boolean _oshut;

    
 
     public StreamEndPoint(InputStream inOutputStream out)
     {
         =in;
         =out;
     }
 
     public boolean isBlocking()
     {
         return true;
     }
 
     public boolean blockReadable(long millisecsthrows IOException
     {
         return true;
     }
 
     public boolean blockWritable(long millisecsthrows IOException
     {
         return true;
     }
 
     /*
      * @see org.eclipse.io.BufferIO#isOpen()
      */
     public boolean isOpen()
     {
         return !=null;
     }
 
     /*
      * @see org.eclipse.io.BufferIO#isOpen()
      */
     public final boolean isClosed()
     {
         return !isOpen();
     }
 
     public void shutdownOutput() throws IOException
     {
          = true;
         if ( && !=null)
             .close();
     }
 
     public boolean isInputShutdown()
     {
         return ;
     }
 
     public void shutdownInput() throws IOException
     {
          = true;
         if (&&!=null)
             .close();
     }
 
     public boolean isOutputShutdown()
     {
         return ;
    }
    /*
     * @see org.eclipse.io.BufferIO#close()
     */
    public void close() throws IOException
    {
        if (!=null)
            .close();
        =null;
        if (!=null)
            .close();
        =null;
    }
    protected void idleExpired() throws IOException
    {
        if (!=null)
            .close();
    }
    /* (non-Javadoc)
     * @see org.eclipse.io.BufferIO#fill(org.eclipse.io.Buffer)
     */
    public int fill(Buffer bufferthrows IOException
    {
        if ()
            return -1;
        if (==null)
            return 0;
        int space=buffer.space();
        if (space<=0)
        {
            if (buffer.hasContent())
                return 0;
            throw new IOException("FULL");
        }
        try
        {
            int filled=buffer.readFrom(space);
            if (filled<0)
                shutdownInput();
            return filled;
        }
        catch(SocketTimeoutException e)
        {
            idleExpired();
            return -1;
        }
    }
    /* (non-Javadoc)
     * @see org.eclipse.io.BufferIO#flush(org.eclipse.io.Buffer)
     */
    public int flush(Buffer bufferthrows IOException
    {
        if ()
            return -1;
        if (==null)
            return 0;
        int length=buffer.length();
        if (length>0)
            buffer.writeTo();
        if (!buffer.isImmutable())
            buffer.clear();
        return length;
    }
    /* (non-Javadoc)
     * @see org.eclipse.io.BufferIO#flush(org.eclipse.io.Buffer, org.eclipse.io.Buffer, org.eclipse.io.Buffer)
     */
    public int flush(Buffer headerBuffer bufferBuffer trailerthrows IOException
    {
        int len=0;
        if (header!=null)
        {
            int tw=header.length();
            if (tw>0)
            {
                int f=flush(header);
                len=f;
                if (f<tw)
                    return len;
            }
        }
        if (buffer!=null)
        {
            int tw=buffer.length();
            if (tw>0)
            {
                int f=flush(buffer);
                if (f<0)
                    return len>0?len:f;
                len+=f;
                if (f<tw)
                    return len;
            }
        }
        if (trailer!=null)
        {
            int tw=trailer.length();
            if (tw>0)
            {
                int f=flush(trailer);
                if (f<0)
                    return len>0?len:f;
                len+=f;
            }
        }
        return len;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#getLocalAddr()
     */
    public String getLocalAddr()
    {
        return null;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#getLocalHost()
     */
    public String getLocalHost()
    {
        return null;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#getLocalPort()
     */
    public int getLocalPort()
    {
        return 0;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#getRemoteAddr()
     */
    public String getRemoteAddr()
    {
        return null;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#getRemoteHost()
     */
    public String getRemoteHost()
    {
        return null;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#getRemotePort()
     */
    public int getRemotePort()
    {
        return 0;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#getConnection()
     */
    public Object getTransport()
    {
        return null;
    }
    /* ------------------------------------------------------------ */
    public InputStream getInputStream()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    public void setInputStream(InputStream in)
    {
        =in;
    }
    /* ------------------------------------------------------------ */
    public OutputStream getOutputStream()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    public void setOutputStream(OutputStream out)
    {
        =out;
    }
    /* ------------------------------------------------------------ */
    public void flush()
        throws IOException
    {
        if ( != null)
            .flush();
    }
    /* ------------------------------------------------------------ */
    public int getMaxIdleTime()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    public void setMaxIdleTime(int timeMsthrows IOException
    {
        =timeMs;
    }
New to GrepCode? Check out our FAQ X