Class XmlExtensions


  • public final class XmlExtensions
    extends java.lang.Object
    The class XmlExtensions
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.xml.sax.InputSource getInputSource​(java.lang.String xmlString)
      Gets the input source from the given xml string.
      static <T> T loadObject​(java.io.File xmlFile)
      Load from the given file name that should represent an xml file and transform it to the generic type object.
      static <T> T loadObject​(java.io.File xmlFile, java.lang.Class<T> clazz)
      Load from the given file name that should represent an xml file and transform it to the generic type object.
      static <T> T loadObject​(java.lang.String xmlFileName)
      Load from the given file name that should represent an xml file and transform it to the generic type object.
      static <T> T loadObject​(java.lang.String xmlFileName, java.lang.Class<T> clazz)
      Load from the given file name that should represent an xml file and transform it to the generic type object.
      static java.lang.String newTag​(java.lang.String tagname, java.lang.String value, java.util.Map<java.lang.String,​java.lang.String> attributes)
      Creates a tag from the given string values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInputSource

        public static org.xml.sax.InputSource getInputSource​(java.lang.String xmlString)
        Gets the input source from the given xml string.
        Parameters:
        xmlString - the xml as string object
        Returns:
        the input source
      • loadObject

        public static <T> T loadObject​(java.io.File xmlFile)
                                throws java.io.IOException
        Load from the given file name that should represent an xml file and transform it to the generic type object.
        Type Parameters:
        T - the generic type
        Parameters:
        xmlFile - the xml file
        Returns:
        the object from the given xml file.
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • loadObject

        public static <T> T loadObject​(java.io.File xmlFile,
                                       java.lang.Class<T> clazz)
                                throws java.io.IOException
        Load from the given file name that should represent an xml file and transform it to the generic type object.
        Type Parameters:
        T - the generic type
        Parameters:
        xmlFile - the xml file
        clazz - the class of the generic type
        Returns:
        the object from the given xml file.
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • loadObject

        public static <T> T loadObject​(java.lang.String xmlFileName)
                                throws java.io.IOException
        Load from the given file name that should represent an xml file and transform it to the generic type object.
        Type Parameters:
        T - the generic type
        Parameters:
        xmlFileName - the xml file name
        Returns:
        the object from the given xml file.
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • loadObject

        public static <T> T loadObject​(java.lang.String xmlFileName,
                                       java.lang.Class<T> clazz)
                                throws java.io.IOException
        Load from the given file name that should represent an xml file and transform it to the generic type object.
        Type Parameters:
        T - the generic type
        Parameters:
        xmlFileName - the xml file name
        clazz - the class of the generic type
        Returns:
        the object from the given xml file.
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • newTag

        public static java.lang.String newTag​(java.lang.String tagname,
                                              java.lang.String value,
                                              java.util.Map<java.lang.String,​java.lang.String> attributes)
        Creates a tag from the given string values. Can be used for creating html or xml tags.
        Parameters:
        tagname - the tag name
        value - the value from the tag
        attributes - a map with the attributes
        Returns:
        the string