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;
 
 
 
 
 /* ------------------------------------------------------------ */
ByteArrayEndPoint.
 
 public class ByteArrayEndPoint implements ConnectedEndPoint
 {
     protected byte[] _inBytes;
     protected ByteArrayBuffer _in;
     protected ByteArrayBuffer _out;
     protected boolean _closed;
     protected boolean _nonBlocking;
     protected boolean _growOutput;
     protected Connection _connection;
     protected int _maxIdleTime;
 
 
     /* ------------------------------------------------------------ */
    
 
     public ByteArrayEndPoint()
     {
     }
 
     /* ------------------------------------------------------------ */
    
 
     public Connection getConnection()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    
 
     public void setConnection(Connection connection)
     {
         =connection;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
the nonBlocking
 
     public boolean isNonBlocking()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
nonBlocking the nonBlocking to set
 
     public void setNonBlocking(boolean nonBlocking)
     {
         =nonBlocking;
     }
 
     /* ------------------------------------------------------------ */
    
 
     public ByteArrayEndPoint(byte[] inputint outputSize)
     {
         =input;
         =new ByteArrayBuffer(input);
         =new ByteArrayBuffer(outputSize);
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the in.
    public ByteArrayBuffer getIn()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    

Parameters:
in The in to set.
    public void setIn(ByteArrayBuffer in)
    {
         = in;
    }
    /* ------------------------------------------------------------ */
    

Returns:
Returns the out.
    public ByteArrayBuffer getOut()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    

Parameters:
out The out to set.
    public void setOut(ByteArrayBuffer out)
    {
         = out;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#isOpen()
     */
    public boolean isOpen()
    {
        return !;
    }
    /* ------------------------------------------------------------ */
    /*
     *  @see org.eclipse.jetty.io.EndPoint#isInputShutdown()
     */
    public boolean isInputShutdown()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    /*
     *  @see org.eclipse.jetty.io.EndPoint#isOutputShutdown()
     */
    public boolean isOutputShutdown()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#isBlocking()
     */
    public boolean isBlocking()
    {
        return !;
    }
    /* ------------------------------------------------------------ */
    public boolean blockReadable(long millisecs)
    {
        return true;
    }
    /* ------------------------------------------------------------ */
    public boolean blockWritable(long millisecs)
    {
        return true;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#shutdownOutput()
     */
    public void shutdownOutput() throws IOException
    {
        close();
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#shutdownInput()
     */
    public void shutdownInput() throws IOException
    {
        close();
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#close()
     */
    public void close() throws IOException
    {
        =true;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#fill(org.eclipse.io.Buffer)
     */
    public int fill(Buffer bufferthrows IOException
    {
        if ()
            throw new IOException("CLOSED");
        if (!=null && .length()>0)
        {
            int len = buffer.put();
            .skip(len);
            return len;
        }
        if (!=null && .length()==0 && )
            return 0;
        close();
        return -1;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#flush(org.eclipse.io.Buffer)
     */
    public int flush(Buffer bufferthrows IOException
    {
        if ()
            throw new IOException("CLOSED");
        if ( && buffer.length()>.space())
        {
            .compact();
            if (buffer.length()>.space())
            {
                ByteArrayBuffer n = new ByteArrayBuffer(.putIndex()+buffer.length());
                n.put(.peek(0,.putIndex()));
                if (.getIndex()>0)
                {
                    n.mark();
                    n.setGetIndex(.getIndex());
                }
                =n;
            }
        }
        int len = .put(buffer);
        if (!buffer.isImmutable())
            buffer.skip(len);
        return len;
    }
    /* ------------------------------------------------------------ */
    /*
     * @see org.eclipse.io.EndPoint#flush(org.eclipse.io.Buffer, org.eclipse.io.Buffer, org.eclipse.io.Buffer)
     */
    public int flush(Buffer headerBuffer bufferBuffer trailerthrows IOException
    {
        if ()
            throw new IOException("CLOSED");
        int flushed=0;
        if (header!=null && header.length()>0)
            flushed=flush(header);
        if (header==null || header.length()==0)
        {
            if (buffer!=null && buffer.length()>0)
                flushed+=flush(buffer);
            if (buffer==null || buffer.length()==0)
            {
                if (trailer!=null && trailer.length()>0)
                {
                    flushed+=flush(trailer);
                }
            }
        }
        return flushed;
    }
    /* ------------------------------------------------------------ */
    
    public void reset()
    {
        =false;
        .clear();
        .clear();
        if (!=null)
            .setPutIndex(.);
    }
    /* ------------------------------------------------------------ */
    /*
     * @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 ;
    }
    /* ------------------------------------------------------------ */
    public void flush() throws IOException
    {
    }
    
    /* ------------------------------------------------------------ */
    

Returns:
the growOutput
    public boolean isGrowOutput()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    

Parameters:
growOutput the growOutput to set
    public void setGrowOutput(boolean growOutput)
    {
        =growOutput;
    }
    /* ------------------------------------------------------------ */
    
    public int getMaxIdleTime()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    
    public void setMaxIdleTime(int timeMsthrows IOException
    {
        =timeMs;
    }
New to GrepCode? Check out our FAQ X