| 1 |
/* |
| 2 |
* @(#) ObjectConverter.java |
| 3 |
* |
| 4 |
* Copyright 2002 - 2003 JIDE Software. All rights reserved. |
| 5 |
*/ |
| 6 |
package com.jidesoft.converter; |
| 7 |
|
| 8 |
|
| 9 |
/** |
| 10 |
* An interface that can convert a object to a String and convert from |
| 11 |
* String to object. |
| 12 |
*/ |
| 13 |
public interface ObjectConverter { |
| 14 |
|
| 15 |
/** |
| 16 |
* Converts from object to String based on current locale. |
| 17 |
* |
| 18 |
* @param object object to be converted |
| 19 |
* @param context converter context to be used |
| 20 |
* @return the String |
| 21 |
*/ |
| 22 |
abstract String toString(Object object, ConverterContext context); |
| 23 |
|
| 24 |
/** |
| 25 |
* If it supports toString method. |
| 26 |
* |
| 27 |
* @param object object to be converted |
| 28 |
* @param context converter context to be used |
| 29 |
* @return true if supports toString |
| 30 |
*/ |
| 31 |
abstract boolean supportToString(Object object, ConverterContext context); |
| 32 |
|
| 33 |
/** |
| 34 |
* Converts from String to an object. |
| 35 |
* |
| 36 |
* @param string the string |
| 37 |
* @param context context to be converted |
| 38 |
* @return the object converted from string |
| 39 |
*/ |
| 40 |
abstract Object fromString(String string, ConverterContext context); |
| 41 |
|
| 42 |
/** |
| 43 |
* If it supports fromString. |
| 44 |
* |
| 45 |
* @param string the string |
| 46 |
* @param context context to be converted |
| 47 |
* @return true if it supports |
| 48 |
*/ |
| 49 |
abstract boolean supportFromString(String string, ConverterContext context); |
| 50 |
} |