Class GpxJaxbContextHelper

java.lang.Object
org.bremersee.gpx.GpxJaxbContextHelper

public abstract class GpxJaxbContextHelper extends Object
GPX XML context helper.
Author:
Christian Bremer
  • Method Details

    • parseExtensions

      public static Map<Class<?>,List<Object>> parseExtensions(ExtensionsType extensions, jakarta.xml.bind.JAXBContext jaxbContext)
      Parses the elements of the given GPX extensions (ExtensionsType.getAnies()) with the given JAXBContext.

      If the JAXBContext can unmarshall the Element to a concrete object, a map entry will be created with the class of the object as key and a list with all unmarshalled objects as value.

      If the JAXBContext cannot unmarshall the Element to a concrete object, a map entry will be created with the class of the element as key and a list with all elements as value.

      Parameters:
      extensions - the GPX extension
      jaxbContext - the JAXBContext to parse the elements
      Returns:
      an unmodifiable map with the unmarshalled objects (key is the class of the objects, value is a list with all unmarshalled objects of this class)
    • parseExtensions

      public static Map<Class<?>,List<Object>> parseExtensions(ExtensionsType extensions, jakarta.xml.bind.Unmarshaller unmarshaller)
      Parses the elements of the given GPX extensions (ExtensionsType.getAnies()) with the given Unmarshaller.

      If the Unmarshaller can unmarshall the Element to a concrete object, a map entry will be created with the class of the object as key and a list with all unmarshalled objects as value.

      If the Unmarshaller cannot unmarshall the Element to a concrete object, a map entry will be created with the class of the element as key and a list with all elements as value.

      Parameters:
      extensions - the GPX extension
      unmarshaller - the Unmarshaller to parse the elements
      Returns:
      an unmodifiable map with the unmarshalled objects (key is the class of the objects, value is a list with all unmarshalled objects of this class)
    • findExtensions

      public static <T> List<T> findExtensions(Class<T> cls, boolean instancesOf, Map<Class<?>,List<Object>> parsedExtensions)
      Find all extensions of the given type.
      Type Parameters:
      T - the type
      Parameters:
      cls - the type
      instancesOf - if true instanceof will be used, otherwise Object.equals(Object) will be used
      parsedExtensions - the parsed extensions (see parseExtensions(ExtensionsType, JAXBContext))
      Returns:
      an unmodifiable list of all extensions of the given type
    • findExtensions

      public static <T> List<T> findExtensions(Class<T> cls, boolean instancesOf, ExtensionsType extensions, jakarta.xml.bind.JAXBContext jaxbContext)
      Find all extensions of the given type.
      Type Parameters:
      T - the type
      Parameters:
      cls - the type
      instancesOf - if true instanceof will be used, otherwise Object.equals(Object) will be used
      extensions - the GPX extensions
      jaxbContext - the JAXBContext to parse the elements
      Returns:
      an unmodifiable list of all extensions of the given type
    • findExtensions

      public static <T> List<T> findExtensions(Class<T> cls, boolean instancesOf, ExtensionsType extensions, jakarta.xml.bind.Unmarshaller unmarshaller)
      Find all extensions of the given type.
      Type Parameters:
      T - the type
      Parameters:
      cls - the type
      instancesOf - if true instanceof will be used, otherwise Object.equals(Object) will be used
      extensions - the GPX extensions
      unmarshaller - the Unmarshaller to parse the elements
      Returns:
      an unmodifiable list of all extensions of the given type
    • findFirstExtension

      public static <T> Optional<T> findFirstExtension(Class<T> cls, boolean instancesOf, Map<Class<?>,List<Object>> parsedExtensions)
      Find the first extension of the given type.
      Type Parameters:
      T - the type
      Parameters:
      cls - the type
      instancesOf - if true instanceof will be used, otherwise Object.equals(Object) will be used
      parsedExtensions - the parsed extensions (see parseExtensions(ExtensionsType, JAXBContext))
      Returns:
      Optional.empty() if there is no such element, otherwise an optional with the parsed element
    • findFirstExtension

      public static <T> Optional<T> findFirstExtension(Class<T> cls, boolean instancesOf, ExtensionsType extensions, jakarta.xml.bind.JAXBContext jaxbContext)
      Find the first extension of the given type.
      Type Parameters:
      T - the type
      Parameters:
      cls - the type
      instancesOf - if true instanceof will be used, otherwise Object.equals(Object) will be used
      extensions - the GPX extensions
      jaxbContext - the JAXBContext to parse the elements
      Returns:
      Optional.empty() if there is no such element, otherwise an optional with the parsed element
    • findFirstExtension

      public static <T> Optional<T> findFirstExtension(Class<T> cls, boolean instancesOf, ExtensionsType extensions, jakarta.xml.bind.Unmarshaller unmarshaller)
      Find the first extension of the given type.
      Type Parameters:
      T - the type
      Parameters:
      cls - the type
      instancesOf - if true instanceof will be used, otherwise Object.equals(Object) will be used
      extensions - the GPX extensions
      unmarshaller - the Unmarshaller to parse the elements
      Returns:
      Optional.empty() if there is no such element, otherwise an optional with the parsed element