Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //
  //  ========================================================================
  //  Copyright (c) 1995-2012 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;

A View on another buffer. Allows operations that do not change the _content or indexes of the backing buffer.
 
 public class View extends AbstractBuffer
 {
     Buffer _buffer;

    

Parameters:
buffer The Buffer on which we are presenting a View.
mark The initial value of the mark index
get The initial value of the get index
put The initial value of the put index
access The access level - one of the constants from Buffer.
 
     public View(Buffer bufferint markint getint put,int access)
     {
         super(,!buffer.isImmutable());
         =buffer.buffer();
         setPutIndex(put);
         setGetIndex(get);
         setMarkIndex(mark);
         =access;
     }
     
     public View(Buffer buffer)
     {
         super(,!buffer.isImmutable());
         =buffer.buffer();
         setPutIndex(buffer.putIndex());
         setGetIndex(buffer.getIndex());
         setMarkIndex(buffer.markIndex());
         =buffer.isReadOnly()?:;
     }
 
     public View()
     {
         super(,true);
     }
    
    
Update view to buffer
 
     public void update(Buffer buffer)
     {
         =;
         =buffer.buffer();
         setGetIndex(0);
         setPutIndex(buffer.putIndex());
         setGetIndex(buffer.getIndex());
         setMarkIndex(buffer.markIndex());
         =buffer.isReadOnly()?:;
     }
 
     public void update(int getint put)
     {
         int a=;
         =;
         setGetIndex(0);
         setPutIndex(put);
         setGetIndex(get);
         setMarkIndex(-1);
         =a;
     }

    

Returns:
The Buffer.array() from the underlying buffer.
 
     public byte[] array()
     {
         return .array();
     }

    

Returns:
The Buffer.buffer() from the underlying buffer.
 
    @Override
    public Buffer buffer()
    {
        return .buffer();
    }

    

Returns:
The Buffer.capacity() of the underlying buffer.
    public int capacity()
    {
        return .capacity();
    }

    
    @Override
    public void clear()
    {
        setMarkIndex(-1);
        setGetIndex(0);
        setPutIndex(.getIndex());
        setGetIndex(.getIndex());
    }

    
    @Override
    public void compact()
    {
        // TODO
    }
    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj)
    {
        return  this==obj ||((obj instanceof Buffer)&& obj.equals(this)) || super.equals(obj);
    }

    

Returns:
Whether the underlying buffer is read only
    @Override
    public boolean isReadOnly()
    {
        return .isReadOnly();
    }

    

Returns:
Whether the underlying buffer is volatile
    @Override
    public boolean isVolatile()
    {
        return true;
    }

    

Returns:
The result of calling Buffer.peek(int) on the underlying buffer
    public byte peek(int index)
    {
        return .peek(index);
    }

    

Returns:
The result of calling Buffer.peek(int,byte[],int,int) on the underlying buffer
    public int peek(int indexbyte[] bint offsetint length)
    {
        return .peek(index,b,offset,length);
    }

    

Returns:
The result of calling Buffer.peek(int,int) on the underlying buffer
    @Override
    public Buffer peek(int indexint length)
    {
        return .peek(indexlength);
    }
    
    

Parameters:
index
src
    @Override
    public int poke(int indexBuffer src)
    {
        return .poke(index,src); 
    }

    

Parameters:
index
b
    public void poke(int indexbyte b)
    {
        .poke(index,b);
    }

    

Parameters:
index
b
offset
length
    @Override
    public int poke(int indexbyte[] bint offsetint length)
    {
        return .poke(index,b,offset,length);
    }
    
    @Override
    public String toString()
    {
        if (==null)
            return "INVALID";
        return super.toString();
    }
    
    public static class CaseInsensitive extends View implements Buffer.CaseInsensitve
    {
        public CaseInsensitive()
        {
            super();
        }
        public CaseInsensitive(Buffer bufferint markint getint putint access)
        {
            super(buffer,mark,get,put,access);
        }
        public CaseInsensitive(Buffer buffer)
        {
            super(buffer);
        }
        
        @Override
        public boolean equals(Object obj)
        {
            return  this==obj ||((obj instanceof Buffer)&&((Buffer)obj).equalsIgnoreCase(this)) || super.equals(obj);
        }
    }
New to GrepCode? Check out our FAQ X