gt:             byte mode = stream.readByte();
context: // **********************************************************************
  //
  // Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
  //
  // This copy of Ice is licensed to you under the terms described in the
  // ICE_LICENSE file included in this distribution.
  //
  // **********************************************************************
  
  package IceInternal;
  
  public final class TraceUtil
  {
      public static void
      traceSend(BasicStream str, Ice.Logger logger, TraceLevels tl)
      {
          if(tl.protocol >= 1)
          {
              int p = str.pos();
              str.pos(0);
              
              java.io.StringWriter s = new java.io.StringWriter();
              byte type = printMessage(s, str);
  
              logger.trace(tl.protocolCat, "sending " + getMessageTypeAsString(type) + " " + s.toString());
  
              str.pos(p);
          }
      }
  
      public static void
      traceRecv(BasicStream str, Ice.Logger logger, TraceLevels tl)
      {
          if(tl.protocol >= 1)
          {
              int p = str.pos();
              str.pos(0);
              
              java.io.StringWriter s = new java.io.StringWriter();
              byte type = printMessage(s, str);
  
              logger.trace(tl.protocolCat, "received " + getMessageTypeAsString(type) + " " + s.toString());
  
              str.pos(p);
          }
      }
  
      public static void
      trace(String heading, BasicStream str, Ice.Logger logger, TraceLevels tl)
      {
          if(tl.protocol >= 1)
          {
              int p = str.pos();
              str.pos(0);
  
              java.io.StringWriter s = new java.io.StringWriter();
              s.write(heading);
              printMessage(s, str);
  
              logger.trace(tl.protocolCat, s.toString());
              str.pos(p);
          }
      }
  
      private static java.util.Set<String> slicingIds = new java.util.HashSet<String>();
  
      synchronized static void
      traceSlicing(String kind, String typeId, String slicingCat, Ice.Logger logger)
      {
          if(slicingIds.add(typeId))
          {
              java.io.StringWriter s = new java.io.StringWriter();
              s.write("unknown " + kind + " type `" + typeId + "'");
              logger.trace(slicingCat, s.toString());
          }
      }
  
      public static void
      dumpStream(BasicStream stream)
      {
          int pos = stream.pos();
          stream.pos(0);
  
          byte[] data = stream.readBlob(stream.size());
          dumpOctets(data);
  
          stream.pos(pos);
      }
  
      public static void
      dumpOctets(byte[] data)
      {
          final int inc = 8;
  
          for(int i = 0; i < data.length; i += inc)
          {
              for(int j = i; j - i < inc; j++)
              {
                  if(j < data.length)
                  {
                      int n = (int)data[j];
                      if(n < 0)
                      {
                          n += 256;
                      }
                      String s;
                      if(n < 10)
                      {
                          s = "  " + n;
                      }
                      else if(n < 100)
                      {
                          s = " " + n;
                      }
                      else
                      {
                          s = "" + n;
                      }
                      System.out.print(s + " ");
                  }
                  else
                  {
                      System.out.print("    ");
                  }
              }
  
              System.out.print('"');
  
              for(int j = i; j < data.length && j - i < inc; j++)
              {
                  if(data[j] >= (byte)32 && data[j] < (byte)127)
                  {
                      System.out.print((char)data[j]);
                  }
                  else
                  {
                      System.out.print('.');
                  }
              }
  
              System.out.println('"');
          }
      }
  
      private static void
      printIdentityFacetOperation(java.io.Writer out, BasicStream stream)
      {
          try
          {
              Ice.Identity identity = new Ice.Identity();
              identity.__read(stream);
              out.write("\nidentity = " + stream.instance().identityToString(identity));
  
              String[] facet = stream.readStringSeq();
              out.write("\nfacet = ");
              if(facet.length > 0)
              {
                  out.write(IceUtilInternal.StringUtil.escapeString(facet[0], ""));
              }
  
              String operation = stream.readString();
              out.write("\noperation = " + operation);
          }
          catch(java.io.IOException ex)
          {
              assert(false);
          }
      }
  
      private static void
      printRequest(java.io.StringWriter s, BasicStream str)
      {
          int requestId = str.readInt();
          s.write("\nrequest id = " + requestId);
          if(requestId == 0)
          {
              s.write(" (oneway)");
          }
          
          printRequestHeader(s, str);
      }
  
      private static void
      printBatchRequest(java.io.StringWriter s, BasicStream str)
      {
          int batchRequestNum = str.readInt();
          s.write("\nnumber of requests = " + batchRequestNum);
          
          for(int i = 0; i < batchRequestNum; ++i)
          {
              s.write("\nrequest #" + i + ':');
              printRequestHeader(s, str);
          }
      }
  
      private static void
      printReply(java.io.StringWriter s, BasicStream str)
      {
          int requestId = str.readInt();
          s.write("\nrequest id = " + requestId);
          
          byte replyStatus = str.readByte();
          s.write("\nreply status = " + (int)replyStatus + ' ');
          
          switch(replyStatus)
          {
          case ReplyStatus.replyOK:
          {
              s.write("(ok)");
              break;
          }
          
          case ReplyStatus.replyUserException:
          {
              s.write("(user exception)");
              break;
          }
          
          case ReplyStatus.replyObjectNotExist:
          case ReplyStatus.replyFacetNotExist:
          case ReplyStatus.replyOperationNotExist:
          {
              switch(replyStatus)
              {
              case ReplyStatus.replyObjectNotExist:
              {
                  s.write("(object not exist)");
                  break;
              }
                          
              case ReplyStatus.replyFacetNotExist:
              {
                  s.write("(facet not exist)");
                  break;
              }
                          
              case ReplyStatus.replyOperationNotExist:
              {
                  s.write("(operation not exist)");
                  break;
              }
                          
              default:
              {
                  assert(false);
                  break;
              }
              }
                      
              printIdentityFacetOperation(s, str);
              break;
          }
  
          case ReplyStatus.replyUnknownException:
          case ReplyStatus.replyUnknownLocalException:
          case ReplyStatus.replyUnknownUserException:
          {
              switch(replyStatus)
              {
              case ReplyStatus.replyUnknownException:
              {
                  s.write("(unknown exception)");
                  break;
              }
  
              case ReplyStatus.replyUnknownLocalException:
              {
                  s.write("(unknown local exception)");
                  break;
              }
                          
              case ReplyStatus.replyUnknownUserException:
              {
                  s.write("(unknown user exception)");
                  break;
              }
                          
              default:
              {
                  assert(false);
                  break;
              }
              }
  
              String unknown = str.readString();
              s.write("\nunknown = " + unknown);
              break;
          }
  
          default:
          {
              s.write("(unknown)");
              break;
          }
          }
      }
  
      private static void
      printRequestHeader(java.io.Writer out, BasicStream stream)
      {
          printIdentityFacetOperation(out, stream);
  
          try
          {
  