costin      02/04/09 13:39:06

  Modified:    util/java/org/apache/tomcat/util/buf C2BConverter.java
  Log:
  Backward-compatible change to C2BConverter.
  Needed by jk - this would avoid duplicating the code.
  
  The duplicated class was needed to allow jk to work with unmodified
  versions of tomcat3.3, but since now tomcat3.3 includes tomcat-util
  and we expect people to upgrade tomcat-util to get coyote to
  run ( and we use coyote for jk instead of a webapp ) - we can
  remove the old one.
  
  Revision  Changes    Path
  1.2       +40 -1     
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/C2BConverter.java
  
  Index: C2BConverter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/C2BConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- C2BConverter.java 29 May 2001 06:22:53 -0000      1.1
  +++ C2BConverter.java 9 Apr 2002 20:39:06 -0000       1.2
  @@ -75,13 +75,15 @@
       private IntermediateOutputStream ios;
       private WriteConvertor conv;
       private ByteChunk bb;
  -
  +    private String enc;
  +    
       /** Create a converter, with bytes going to a byte buffer
        */
       public C2BConverter(ByteChunk output, String encoding) throws IOException {
        this.bb=output;
        ios=new IntermediateOutputStream( output );
        conv=new WriteConvertor( ios, encoding );
  +        this.enc=encoding;
       }
   
       /** Create a converter
  @@ -94,6 +96,10 @@
        return bb;
       }
   
  +    public String getEncoding() {
  +        return enc;
  +    }
  +
       public void setByteChunk(ByteChunk bb) {
        this.bb=bb;
        ios.setByteChunk( bb );
  @@ -115,8 +121,41 @@
   
       /** Generate the bytes using the specified encoding
        */
  +    public  final void convert(String s ) throws IOException {
  +     conv.write( s );
  +    }
  +
  +    /** Generate the bytes using the specified encoding
  +     */
       public  final void convert(char c ) throws IOException {
        conv.write( c );
  +    }
  +
  +    /** Convert a message bytes chars to bytes
  +     */
  +    public final void convert(MessageBytes mb ) throws IOException {
  +        int type=mb.getType();
  +        if( type==MessageBytes.T_BYTES )
  +            return;
  +        ByteChunk orig=bb;
  +        setByteChunk( mb.getByteChunk());
  +        bb.recycle();
  +        bb.allocate( 32, -1 );
  +        
  +        if( type==MessageBytes.T_STR ) {
  +            convert( mb.getString() );
  +            // System.out.println("XXX Converting " + mb.getString() );
  +        } else if( type==MessageBytes.T_CHARS ) {
  +            CharChunk charC=mb.getCharChunk();
  +            convert( charC.getBuffer(),
  +                                charC.getOffset(), charC.getLength());
  +            //System.out.println("XXX Converting " + mb.getCharChunk() );
  +        } else {
  +            System.out.println("XXX unknowon type " + type );
  +        }
  +        flushBuffer();
  +        //System.out.println("C2B: XXX " + bb.getBuffer() + bb.getLength()); 
  +        setByteChunk(orig);
       }
   
       /** Flush any internal buffers into the ByteOutput or the internal
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to