Package org.jfree.chart.util
Class HexNumberFormat
- java.lang.Object
-
- java.text.Format
-
- java.text.NumberFormat
-
- org.jfree.chart.util.HexNumberFormat
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class HexNumberFormat extends java.text.NumberFormat
A custom number formatter that formats numbers as hexadecimal strings. There are some limitations, so be careful using this class.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
BYTE
Number of hexadecimal digits for a byte.static int
DWORD
Number of hexadecimal digits for a double word.private int
m_numDigits
The number of digits (shorter strings will be left padded).static int
QWORD
Number of hexadecimal digits for a quad word.static int
WORD
Number of hexadecimal digits for a word.
-
Constructor Summary
Constructors Constructor Description HexNumberFormat()
Creates a new instance with 8 digits.HexNumberFormat(int digits)
Creates a new instance with the specified number of digits.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringBuffer
format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Formats the specified number as a hexadecimal string.java.lang.StringBuffer
format(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Formats the specified number as a hexadecimal string.int
getNumberOfDigits()
Returns the number of digits.java.lang.Number
parse(java.lang.String source, java.text.ParsePosition parsePosition)
Parsing is not implemented, so this method always returnsnull
.void
setNumberOfDigits(int digits)
Sets the number of digits.-
Methods inherited from class java.text.NumberFormat
clone, equals, format, format, format, getAvailableLocales, getCurrency, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, getRoundingMode, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly, setRoundingMode
-
-
-
-
Field Detail
-
BYTE
public static final int BYTE
Number of hexadecimal digits for a byte.- See Also:
- Constant Field Values
-
WORD
public static final int WORD
Number of hexadecimal digits for a word.- See Also:
- Constant Field Values
-
DWORD
public static final int DWORD
Number of hexadecimal digits for a double word.- See Also:
- Constant Field Values
-
QWORD
public static final int QWORD
Number of hexadecimal digits for a quad word.- See Also:
- Constant Field Values
-
m_numDigits
private int m_numDigits
The number of digits (shorter strings will be left padded).
-
-
Method Detail
-
getNumberOfDigits
public final int getNumberOfDigits()
Returns the number of digits.- Returns:
- The number of digits.
-
setNumberOfDigits
public void setNumberOfDigits(int digits)
Sets the number of digits.- Parameters:
digits
- the number of digits.
-
format
public java.lang.StringBuffer format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Formats the specified number as a hexadecimal string. The decimal fraction is ignored.- Specified by:
format
in classjava.text.NumberFormat
- Parameters:
number
- the number to format.toAppendTo
- the buffer to append to (ignored here).pos
- the field position (ignored here).- Returns:
- The string buffer.
-
format
public java.lang.StringBuffer format(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Formats the specified number as a hexadecimal string. The decimal fraction is ignored.- Specified by:
format
in classjava.text.NumberFormat
- Parameters:
number
- the number to format.toAppendTo
- the buffer to append to (ignored here).pos
- the field position (ignored here).- Returns:
- The string buffer.
-
parse
public java.lang.Number parse(java.lang.String source, java.text.ParsePosition parsePosition)
Parsing is not implemented, so this method always returnsnull
.- Specified by:
parse
in classjava.text.NumberFormat
- Parameters:
source
- ignored.parsePosition
- ignored.- Returns:
- Always
null
.
-
-