Package io.github.astrapi69.xml
Class XmlExtensions
- java.lang.Object
-
- io.github.astrapi69.xml.XmlExtensions
-
public final class XmlExtensions extends java.lang.Object
The classXmlExtensions
-
-
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.
-
-
-
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 fileclazz
- 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 nameclazz
- 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 namevalue
- the value from the tagattributes
- a map with the attributes- Returns:
- the string
-
-