com.sun.jini.jeri.internal.runtime
Class HexDumpEncoder

java.lang.Object
  extended by com.sun.jini.jeri.internal.runtime.CharacterEncoder
      extended by com.sun.jini.jeri.internal.runtime.HexDumpEncoder

public class HexDumpEncoder
extends CharacterEncoder

This class encodes a buffer into the classic: "Hexadecimal Dump" format of the past. It is useful for analyzing the contents of binary buffers. The format produced is as follows:

 xxxx: 00 11 22 33 44 55 66 77   88 99 aa bb cc dd ee ff ................
 
Where xxxx is the offset into the buffer in 16 byte chunks, followed by ascii coded hexadecimal bytes followed by the ASCII representation of the bytes or '.' if they are not valid bytes.

Author:
Sun Microsystems, Inc.

Field Summary
private  int currentByte
           
private  int offset
           
private  byte[] thisLine
           
private  int thisLineLength
           
 
Fields inherited from class com.sun.jini.jeri.internal.runtime.CharacterEncoder
pStream
 
Constructor Summary
HexDumpEncoder()
           
 
Method Summary
protected  int bytesPerAtom()
          Return the number of bytes per atom of encoding
protected  int bytesPerLine()
          Return the number of bytes that can be encoded per line
protected  void encodeAtom(OutputStream o, byte[] buf, int off, int len)
          Encode one "atom" of information into characters.
protected  void encodeBufferPrefix(OutputStream o)
          Encode the prefix for the entire buffer.
protected  void encodeLinePrefix(OutputStream o, int len)
          Encode the prefix that starts every output line.
protected  void encodeLineSuffix(OutputStream o)
          Encode the suffix that ends every output line.
(package private) static void hexDigit(PrintStream p, byte x)
           
 
Methods inherited from class com.sun.jini.jeri.internal.runtime.CharacterEncoder
encode, encode, encode, encodeBuffer, encodeBuffer, encodeBuffer, encodeBufferSuffix, readFully
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offset

private int offset

thisLineLength

private int thisLineLength

currentByte

private int currentByte

thisLine

private byte[] thisLine
Constructor Detail

HexDumpEncoder

public HexDumpEncoder()
Method Detail

hexDigit

static void hexDigit(PrintStream p,
                     byte x)

bytesPerAtom

protected int bytesPerAtom()
Description copied from class: CharacterEncoder
Return the number of bytes per atom of encoding

Specified by:
bytesPerAtom in class CharacterEncoder

bytesPerLine

protected int bytesPerLine()
Description copied from class: CharacterEncoder
Return the number of bytes that can be encoded per line

Specified by:
bytesPerLine in class CharacterEncoder

encodeBufferPrefix

protected void encodeBufferPrefix(OutputStream o)
                           throws IOException
Description copied from class: CharacterEncoder
Encode the prefix for the entire buffer. By default is simply opens the PrintStream for use by the other functions.

Overrides:
encodeBufferPrefix in class CharacterEncoder
Throws:
IOException

encodeLinePrefix

protected void encodeLinePrefix(OutputStream o,
                                int len)
                         throws IOException
Description copied from class: CharacterEncoder
Encode the prefix that starts every output line.

Overrides:
encodeLinePrefix in class CharacterEncoder
Throws:
IOException

encodeAtom

protected void encodeAtom(OutputStream o,
                          byte[] buf,
                          int off,
                          int len)
                   throws IOException
Description copied from class: CharacterEncoder
Encode one "atom" of information into characters.

Specified by:
encodeAtom in class CharacterEncoder
Throws:
IOException

encodeLineSuffix

protected void encodeLineSuffix(OutputStream o)
                         throws IOException
Description copied from class: CharacterEncoder
Encode the suffix that ends every output line. By default this method just prints a into the output stream.

Overrides:
encodeLineSuffix in class CharacterEncoder
Throws:
IOException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.