Debian Codegraph @

src/com/jidesoft/converter/ByteConverter.java

raw
1 /*
2 * @(#)ByteConverter.java 1/29/2007
3 *
4 * Copyright 2002 - 2007 JIDE Software Inc. All rights reserved.
5 */
6
7 package com.jidesoft.converter;
8
9 import java.text.DecimalFormat;
10 import java.text.NumberFormat;
11
12 /**
13 * Converter which converts Byte to String and converts it back.
14 */
15 public class ByteConverter extends NumberConverter {
16 public ByteConverter() {
17 this(DecimalFormat.getIntegerInstance());
18 }
19
20 public ByteConverter(NumberFormat format) {
21 super(format);
22 }
23
24 public Object fromString(String string, ConverterContext context) {
25 Number number = parseNumber(string);
26 return number != null ? number.byteValue() : null;
27 }
28
29 public boolean supportFromString(String string, ConverterContext context) {
30 return true;
31 }
32 }