Coverage Report - ca.uhn.hl7v2.hoh.util.ByteUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
ByteUtils
90%
10/11
83%
5/6
2.5
 
 1  
 package ca.uhn.hl7v2.hoh.util;
 2  
 
 3  
 public class ByteUtils {
 4  
 
 5  
         // non instantiable
 6  0
         private ByteUtils() {}
 7  
         
 8  
         /**
 9  
          * Formats a byte array for logging
 10  
          */
 11  
         public static String formatBytesForLogging(int numBytes, int theOffset, byte... theBytes) {
 12  20
                 StringBuilder b = new StringBuilder();
 13  20
                 int end = numBytes + theOffset;
 14  1849
                 for (int i = theOffset; i < end; i++) {
 15  1829
                         byte nextByte = theBytes[i];
 16  1829
                         if (nextByte < ' ' || nextByte > 126) {
 17  301
                                 b.append('[');
 18  301
                                 b.append((int) nextByte);
 19  301
                                 b.append(']');
 20  
                         } else {
 21  1528
                                 b.append((char) nextByte);
 22  
                         }
 23  
                 }
 24  
 
 25  20
                 return (b.toString());
 26  
         }
 27  
         
 28  
 }