remm        2003/01/29 07:20:25

  Modified:    util/java/org/apache/tomcat/util/buf MessageBytes.java
  Log:
  - Byte based setInt.
  
  Revision  Changes    Path
  1.8       +33 -6     
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/MessageBytes.java
  
  Index: MessageBytes.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/MessageBytes.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MessageBytes.java 12 Jul 2002 18:00:14 -0000      1.7
  +++ MessageBytes.java 29 Jan 2003 15:20:25 -0000      1.8
  @@ -583,13 +583,40 @@
        *  be done in headers
        */
       public void setInt(int i) {
  -     // XXX replace it with a byte[] tool
        recycle();
  -     strValue=String.valueOf( i );
  -     intValue=i;
  -     hasIntValue=true;
  -     hasStrValue=true;
  -     type=T_STR;
  +        byteC.allocate(16, 32);
  +        int current = i;
  +        byte[] buf = byteC.getBuffer();
  +        int start = 0;
  +        int end = 0;
  +        if (i == 0) {
  +            buf[end++] = (byte) '0';
  +        }
  +        if (i < 0) {
  +            current = -i;
  +            buf[end++] = (byte) '-';
  +        }
  +        while (current > 0) {
  +            int digit = current % 10;
  +            current = current / 10;
  +            buf[end++] = HexUtils.HEX[digit];
  +        }
  +        byteC.setEnd(end);
  +        // Inverting buffer
  +        end--;
  +        if (i < 0) {
  +            start++;
  +        }
  +        while (end > start) {
  +            byte temp = buf[start];
  +            buf[start] = buf[end];
  +            buf[end] = temp;
  +            start++;
  +            end--;
  +        }
  +        intValue=i;
  +        hasIntValue=true;
  +        type=T_BYTES;
       }
   
   
  
  
  

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

Reply via email to