Class XMLTypeConverter

    • Constructor Detail

      • XMLTypeConverter

        public XMLTypeConverter()
    • Method Detail

      • toXML

        public String toXML​(Date dt)
        Returns the String format of a Date, the standard xml format is used: yyyy-MM-dd'T'HH:mm:ss.S'Z'
        Parameters:
        dt - the Date to format
        Returns:
        the String representation of the Date in xml format
      • toXML

        public String toXML​(Number number)
        Returns:
        numbers are converted using the Number.toString method
      • toXML

        public String toXML​(String str)
        Returns:
        the parameter str is returned without changing it
      • toXML

        public String toXML​(Boolean b)
        Returns:
        the result of the b.toString() method is returned
      • toXML

        public String toXML​(Object o)
        Returns an empty string if the object is null. In other cases the call is forwarded to one of the other toXML methods in this class.
        Parameters:
        o - the value to convert to a String XML representation
        Returns:
        the String XML representation
      • fromXML

        public <T> T fromXML​(Class<T> targetClass,
                             String xml)
        Converts an xml String back to a primitive type java Object. If the xml string has lenght zero then null is returned.
        Parameters:
        targetClass - the class of the primitive type (e.g. String.class, Float.class)
        xml - the xml string to convert
        Returns:
        the converted object
      • toXMLSchemaType

        public String toXMLSchemaType​(Class<?> targetClass)
        Returns:
        the XML Schema type which matches the targetClass parameter