- java.lang.Object
-
- com.gluonhq.connect.converter.InputStreamInputConverter<T>
-
- com.gluonhq.connect.converter.XmlInputConverter<T>
-
- Type Parameters:
T
- the type of the object to convert the XML Object into
- All Implemented Interfaces:
InputConverter<T>
public class XmlInputConverter<T> extends InputStreamInputConverter<T>
An InputConverter that converts a XML Object read from an InputStream into an object.
-
-
Constructor Summary
Constructors Constructor Description XmlInputConverter(Class<T> targetClass)
Construct a new instance of a XmlInputConverter that is able to convert the data read from the InputStream into objects of the specifiedtargetClass
.XmlInputConverter(Class<T> targetClass, String tag)
Construct a new instance of a XmlInputConverter that is able to convert the data read from the InputStream into objects of the specifiedtargetClass
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
read()
Reads an object from a certain input source and returns it.-
Methods inherited from class com.gluonhq.connect.converter.InputStreamInputConverter
getInputStream, setInputStream
-
-
-
-
Constructor Detail
-
XmlInputConverter
public XmlInputConverter(Class<T> targetClass)
Construct a new instance of a XmlInputConverter that is able to convert the data read from the InputStream into objects of the specifiedtargetClass
.- Parameters:
targetClass
- The class defining the objects being converted from XML.
-
XmlInputConverter
public XmlInputConverter(Class<T> targetClass, String tag)
Construct a new instance of a XmlInputConverter that is able to convert the data read from the InputStream into objects of the specifiedtargetClass
. Often, the XML returned by web services has the relevant information nested or wrapped in rootnodes. If there is a 1-1 mapping between the data and the Object, we would end up with unused wrapper classes. By specifying the name of the node that contains the relevant information, the wrapping data is ignored.- Parameters:
targetClass
- The class defining the objects being converted from XML.tag
- the nodename of the rootnode containing the relevant information.
-
-
Method Detail
-
read
public T read()
Description copied from interface:InputConverter
Reads an object from a certain input source and returns it.- Returns:
- An object read from a certain input source.
-
-