FileDocCategorySizeDatePackage
CoyoteInputStream.javaAPI DocGlassfish v2 API9799Fri May 04 22:32:42 BST 2007org.apache.coyote.tomcat5

CoyoteInputStream

public class CoyoteInputStream extends ServletInputStream
This class handles reading bytes.
author
Remy Maucherat
author
Jean-Francois Arcand

Fields Summary
private static final org.apache.catalina.util.StringManager
sm
The string manager for this package.
protected InputBuffer
ib
Constructors Summary
public CoyoteInputStream(InputBuffer ib)



    // ----------------------------------------------------------- Constructors


       
        this.ib = ib;
    
Methods Summary
public intavailable()

        // Disallow operation if the object has gone out of scope
        if (ib == null) {
            throw new IllegalStateException(
                sm.getString("object.invalidScope"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                Integer result = 
                    (Integer)AccessController.doPrivileged(
                        new PrivilegedExceptionAction(){

                            public Object run() throws IOException{
                                Integer integer = Integer.valueOf(ib.available());
                                return integer;
                            }

                });
                return result.intValue();
            } catch(PrivilegedActionException pae){
                Exception e = pae.getException();
                if (e instanceof IOException){
                    throw (IOException)e;
                } else {
                    throw new RuntimeException(e.getMessage());
                }
            }
        } else {
           return ib.available();
        }           
    
voidclear()
Clear facade.

        ib = null;
    
protected java.lang.Objectclone()
Prevent cloning the facade.

        throw new CloneNotSupportedException();
    
public voidclose()
Close the stream Since we re-cycle, we can't allow the call to super.close() which would permantely disable us.

        // Disallow operation if the object has gone out of scope
        if (ib == null) {
            throw new IllegalStateException(
                sm.getString("object.invalidScope"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                AccessController.doPrivileged(
                    new PrivilegedExceptionAction(){

                        public Object run() throws IOException{
                            ib.close();
                            return null;
                        }

                });
            } catch(PrivilegedActionException pae){
                Exception e = pae.getException();
                if (e instanceof IOException){
                    throw (IOException)e;
                } else {
                    throw new RuntimeException(e.getMessage());
                }
            }
        } else {
             ib.close();
        }            
    
public intread()

      

        // Disallow operation if the object has gone out of scope
        if (ib == null) {
            throw new IllegalStateException(
                sm.getString("object.invalidScope"));
        }
    
        if (SecurityUtil.isPackageProtectionEnabled()){
            
            try{
                Integer result = 
                    (Integer)AccessController.doPrivileged(
                        new PrivilegedExceptionAction(){

                            public Object run() throws IOException{
                                Integer integer = Integer.valueOf(ib.readByte());
                                return integer;
                            }

                });
                return result.intValue();
            } catch(PrivilegedActionException pae){
                Exception e = pae.getException();
                if (e instanceof IOException){
                    throw (IOException)e;
                } else {
                    throw new RuntimeException(e.getMessage());
                }
            }
        } else {
            return ib.readByte();
        }   
    
public intread(byte[] b)

        // Disallow operation if the object has gone out of scope
        if (ib == null) {
            throw new IllegalStateException(
                sm.getString("object.invalidScope"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                Integer result = 
                    (Integer)AccessController.doPrivileged(
                        new PrivilegedExceptionAction(){

                            public Object run() throws IOException{
                                Integer integer = 
                                    Integer.valueOf(ib.read(b, 0, b.length));
                                return integer;
                            }

                });
                return result.intValue();
            } catch(PrivilegedActionException pae){
                Exception e = pae.getException();
                if (e instanceof IOException){
                    throw (IOException)e;
                } else {
                    throw new RuntimeException(e.getMessage());
                }
            }
        } else {
            return ib.read(b, 0, b.length);
        }          
    
public intread(byte[] b, int off, int len)


        // Disallow operation if the object has gone out of scope
        if (ib == null) {
            throw new IllegalStateException(
                sm.getString("object.invalidScope"));
        }
        
        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                Integer result = 
                    (Integer)AccessController.doPrivileged(
                        new PrivilegedExceptionAction(){

                            public Object run() throws IOException{
                                Integer integer = 
                                    Integer.valueOf(ib.read(b, off, len));
                                return integer;
                            }

                });
                return result.intValue();
            } catch(PrivilegedActionException pae){
                Exception e = pae.getException();
                if (e instanceof IOException){
                    throw (IOException)e;
                } else {
                    throw new RuntimeException(e.getMessage());
                }
            }
        } else {
            return ib.read(b, off, len);
        }        
    
public intreadLine(byte[] b, int off, int len)

        // Disallow operation if the object has gone out of scope
        if (ib == null) {
            throw new IllegalStateException(
                sm.getString("object.invalidScope"));
        }

        return super.readLine(b, off, len);