org.fourthline.cling.model.types

## Interface Datatype<V>

- Type Parameters:
    `V` - The Java type of the value handled by this datatype.
  All Known Implementing Classes:
    AbstractDatatype, Base64Datatype, BinHexDatatype, BooleanDatatype, CharacterDatatype, CustomDatatype, DateTimeDatatype, DoubleDatatype, FloatDatatype, IntegerDatatype, ShortDatatype, StringDatatype, UnsignedIntegerFourBytesDatatype, UnsignedIntegerOneByteDatatype, UnsignedIntegerTwoBytesDatatype, URIDatatype

      public interface Datatype<V>

  The type of a state variable value, able to convert to/from string representation.
  Author:
    Christian Bauer

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `Datatype.Builtin` Mapping from UPnP built-in standardized type to actual subtype of `Datatype`.
    `static class` | `Datatype.Default` Mapping from Java type to UPnP built-in type.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Datatype.Builtin` | `getBuiltin()`
    `String` | `getDisplayString()`
    `String` | `getString(V value)` Transforms a value supported by this datatype into a string representation.
    `boolean` | `isHandlingJavaType(Class type)`
    `boolean` | `isValid(V value)`
    `V` | `valueOf(String s)` Transforms a string representation into a value of the supported type.

- - ### Method Detail

    - #### isHandlingJavaType

          boolean isHandlingJavaType(Class type)

      Returns:
        `true` if this datatype can handle values of the given Java type.

    - #### getBuiltin

          Datatype.Builtin getBuiltin()

      Returns:
        The built-in UPnP standardized type this datatype is mapped to or `null` if this is a custom datatype.

    - #### isValid

          boolean isValid(V value)

      Parameters:
        `value` - The value to validate or `null`.
      Returns:
        Returns `true` if the value was `null`, validation result otherwise.

    - #### getString

          String getString(V value)
                    throws InvalidValueException

      Transforms a value supported by this datatype into a string representation.

      This method calls `isValid(Object)` before converting the value, it throws an exception if validation fails.

      Parameters:
        `value` - The value to transform.
      Returns:
        The transformed value as a string, or an empty string when the value is null, never returns `null`.
      Throws:
        `InvalidValueException`

    - #### valueOf

          V valueOf(String s)
             throws InvalidValueException

      Transforms a string representation into a value of the supported type.
      Parameters:
        `s` - The string representation of a value.
      Returns:
        The converted value or `null` if the string was `null` or empty.
      Throws:
        `InvalidValueException` - If the string couldn't be parsed.

    - #### getDisplayString

          String getDisplayString()

      Returns:
        Metadata about this datatype, a nice string for display that describes this datatype (e.g. concrete class name).

Copyright © 2016 4th Line GmbH, Switzerland. All rights reserved.