Debian Codegraph @

src/com/jidesoft/converter/ShortConverter.java

raw
1 /*
2 * @(#)ShortConverter.java 3/9/2005
3 *
4 * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
5 */
6 package com.jidesoft.converter;
7
8 import java.text.DecimalFormat;
9 import java.text.NumberFormat;
10
11
12 /**
13 * Converter which converts Short to String and converts it back.
14 */
15 public class ShortConverter extends NumberConverter {
16 public ShortConverter() {
17 this(DecimalFormat.getIntegerInstance());
18 }
19
20 public ShortConverter(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.shortValue() : null;
27 }
28
29 public boolean supportFromString(String string, ConverterContext context) {
30 return true;
31 }
32 }