1 16 17 package org.apache.jk.core; 18 19 import java.io.IOException ; 20 21 import org.apache.tomcat.util.buf.ByteChunk; 22 import org.apache.tomcat.util.buf.MessageBytes; 23 24 25 38 public abstract class Msg { 39 40 41 42 47 public abstract void reset(); 48 49 54 public abstract void end(); 55 56 public abstract void appendInt( int val ); 57 58 public abstract void appendByte( int val ); 59 60 public abstract void appendLongInt( int val ); 61 62 64 public abstract void appendBytes(MessageBytes mb) throws IOException ; 65 66 public abstract void appendByteChunk(ByteChunk bc) throws IOException ; 67 68 79 public abstract void appendBytes( byte b[], int off, int numBytes ); 80 81 87 public abstract int getInt(); 88 89 public abstract int peekInt(); 90 91 public abstract byte getByte(); 92 93 public abstract byte peekByte(); 94 95 public abstract void getBytes(MessageBytes mb); 96 97 104 public abstract int getBytes(byte dest[]); 105 106 112 public abstract int getLongInt(); 113 114 public abstract int getHeaderLength(); 115 116 public abstract int processHeader(); 117 118 public abstract byte[] getBuffer(); 119 120 public abstract int getLen(); 121 122 public abstract void dump(String msg); 123 124 125 127 public static String hexLine( byte buf[], int start, int len ) { 128 StringBuffer sb=new StringBuffer (); 129 for( int i=start; i< start+16 ; i++ ) { 130 if( i < len + 4) 131 sb.append( hex( buf[i] ) + " "); 132 else 133 sb.append( " " ); 134 } 135 sb.append(" | "); 136 for( int i=start; i < start+16 && i < len + 4; i++ ) { 137 if( ! Character.isISOControl( (char)buf[i] )) 138 sb.append( new Character ((char)buf[i]) ); 139 else 140 sb.append( "." ); 141 } 142 return sb.toString(); 143 } 144 145 private static String hex( int x ) { 146 String h=Integer.toHexString( x ); 148 if( h.length() == 1 ) h = "0" + h; 149 return h.substring( h.length() - 2 ); 150 } 151 152 153 } 154 | Popular Tags |