PTLog API - 1.0

jp.ne.dti.lares.foozy.ptlog.format
Class DefaultByteFormatter

java.lang.Object
  extended byjp.ne.dti.lares.foozy.ptlog.format.DefaultByteFormatter
All Implemented Interfaces:
ByteFormatter

public class DefaultByteFormatter
extends java.lang.Object
implements ByteFormatter

Default implementation.

This uses Integer#toString(int value, int radix), which is used invoked from Byte#toString in fact, to format specified value.


Field Summary
static DefaultByteFormatter S_DEC
          For convenience to format decimal radix as signed byte.
static DefaultByteFormatter S_HEX
          For convenience to format hexadecimal radix as signed byte.
static DefaultByteFormatter S_OCT
          For convenience to format in octal radix as signed byte.
static DefaultByteFormatter U_DEC
          For convenience to format decimal radix as unsigned byte.
static DefaultByteFormatter U_HEX
          For convenience to format hexadecimal radix as unsigned byte.
static DefaultByteFormatter U_OCT
          For convenience to format in octal radix as unsigned byte.
 
Constructor Summary
DefaultByteFormatter(int radix, boolean useSign)
          Constructor.
 
Method Summary
 java.lang.String format(byte value)
          Format specified value.
 java.lang.String format(java.lang.Byte value)
          Format specified value.
 ObjectFormatter forObject()
          Get object which adapts "this" to ObjectFormatter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

S_OCT

public static final DefaultByteFormatter S_OCT
For convenience to format in octal radix as signed byte.

This returns "-1" for 0xFF.


U_OCT

public static final DefaultByteFormatter U_OCT
For convenience to format in octal radix as unsigned byte.

This returns "377" for 0xFF.


S_DEC

public static final DefaultByteFormatter S_DEC
For convenience to format decimal radix as signed byte.

This returns "-1" for 0xFF.


U_DEC

public static final DefaultByteFormatter U_DEC
For convenience to format decimal radix as unsigned byte.

This returns "255" for 0xFF.


S_HEX

public static final DefaultByteFormatter S_HEX
For convenience to format hexadecimal radix as signed byte.

This returns "-1" for 0xFF.


U_HEX

public static final DefaultByteFormatter U_HEX
For convenience to format hexadecimal radix as unsigned byte.

This returns "ff" for 0xFF.

Constructor Detail

DefaultByteFormatter

public DefaultByteFormatter(int radix,
                            boolean useSign)
Constructor.

Parameters:
radix - to format specified byte value.
useSign - whether sign('-') is used to represent value or not.
Method Detail

forObject

public final ObjectFormatter forObject()
Get object which adapts "this" to ObjectFormatter.

This is useful to get ObjectFormatter which formats value in as same manner as format(Byte) of "this".

This adaptation is done even if you override format(Byte) in derived classes.

See Also:
DefaultUniversalFormatter.addObjectFormatter(jp.ne.dti.lares.foozy.ptlog.format.ObjectFormatter)

format

public java.lang.String format(byte value)
Description copied from interface: ByteFormatter
Format specified value.

Specified by:
format in interface ByteFormatter

format

public java.lang.String format(java.lang.Byte value)
Description copied from interface: ByteFormatter
Format specified value.

Specified by:
format in interface ByteFormatter

PTLog API - 1.0