private List < ? > loadDataFromXml ( String xml , Class < ? > cls ) { logger . entering ( new Object [ ] { xml , cls } ) ; Preconditions . checkArgument ( cls != null , "Please provide a valid type." ) ; List < ? > returned ; try { JAXBContext context = JAXBContext . newInstance ( Wrapper . class , cls ) ; Unmarshaller unmarshaller = context . createUnmarshaller ( ) ; StringReader xmlStringReader = new StringReader ( xml ) ; StreamSource streamSource = new StreamSource ( xmlStringReader ) ; Wrapper < ? > wrapper = unmarshaller . unmarshal ( streamSource , Wrapper . class ) . getValue ( ) ; returned = wrapper . getList ( ) ; } catch ( JAXBException excp ) { logger . exiting ( excp . getMessage ( ) ) ; throw new DataProviderException ( "Error unmarshalling XML string." , excp ) ; } logger . exiting ( returned ) ; return returned ; }
Generates a list of the declared type after parsing the XML data string .