Class URIConverter

java.lang.Object
org.apache.commons.beanutils2.converters.AbstractConverter<URI>
org.apache.commons.beanutils2.converters.URIConverter
All Implemented Interfaces:
Converter<URI>

public final class URIConverter extends AbstractConverter<URI>
Converter implementation that handles conversion to and from java.net.URI objects.

Can be configured to either return a default value or throw a ConversionException if a conversion error occurs.

Since:
2.0
  • Constructor Details

    • URIConverter

      public URIConverter()
      Constructs a java.net.URI Converter that throws a ConversionException if an error occurs.
    • URIConverter

      public URIConverter(URI defaultValue)
      Constructs a java.net.URI Converter that returns a default value if an error occurs.
      Parameters:
      defaultValue - The default value to be returned if the value to be converted is missing or an error occurs converting the value.
  • Method Details

    • convertToType

      protected <T> T convertToType(Class<T> type, Object value) throws Throwable

      Converts a java.net.URI or object into a String.

      Specified by:
      convertToType in class AbstractConverter<URI>
      Type Parameters:
      T - Target type of the conversion.
      Parameters:
      type - Data type to which this value should be converted.
      value - The input value to be converted.
      Returns:
      The converted value.
      Throws:
      Throwable - if an error occurs converting to the specified type
      Since:
      2.0
    • getDefaultType

      protected Class<URI> getDefaultType()
      Gets the default type this Converter handles.
      Specified by:
      getDefaultType in class AbstractConverter<URI>
      Returns:
      The default type this Converter handles.
      Since:
      2.0