java.lang.Object
org.jhotdraw8.base.converter.ConverterFormatAdapter
Allows to use a
java.text.Format with the Converter API.- Author:
- Werner Randelshofer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfromString(String string, IdFactory idFactory, @NonNull ParsePosition pp) fromString(@NonNull CharBuffer buf, @Nullable IdResolver idResolver) Constructs a value from a string.Provides a default value for APIs which always require a value even if conversion from String failed.voidtoString(Appendable out, @Nullable IdSupplier idSupplier, Object value) Converts a value to a string and appends it to the providedAppendable.Converts a value to a String.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.base.converter.Converter
fromString, fromString, fromString, getHelpText, needsIdResolver, toString, toString
-
Constructor Details
-
ConverterFormatAdapter
-
-
Method Details
-
toString
Description copied from interface:ConverterConverts a value to a String.This method does not change the state of the converter.
Note: this is a convenience method. Implementing classes rarely need to overwrite this method.
-
fromString
-
toString
Description copied from interface:ConverterConverts a value to a string and appends it to the providedAppendable.This method does not change the state of the converter.
-
fromString
public Object fromString(@NonNull CharBuffer buf, @Nullable IdResolver idResolver) throws ParseException Description copied from interface:ConverterConstructs a value from a string.The converter should try to create the value greedily, by consuming as many characters as possible for the value.
This method does not change the state of the converter.
- Specified by:
fromStringin interfaceConverter<Object>- Parameters:
buf- A char buffer which holds the string. The char buffer must be treated as read only! The position of the char buffer denotes the beginning of the string when this method is invoked. After completion of this method, the position is set after the last consumed character.idResolver- The factory for looking up object ids. Nullable for non-resolving converters.- Returns:
- The value. Nullable.
- Throws:
ParseException- if conversion failed. The error offset field is set to the position where parsing failed. The position of the buffer is undefined.
-
getDefaultValue
Description copied from interface:ConverterProvides a default value for APIs which always require a value even if conversion from String failed.- Specified by:
getDefaultValuein interfaceConverter<Object>- Returns:
- The default value to use when conversion from String failed.
-