-
-
Save pitometsyurii/a12dd725ddcfcd8e4ea7bd859f133db5 to your computer and use it in GitHub Desktop.
XMLHelper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class XmlHelper { | |
private static Logger logger = LoggerFactory.getLogger(XmlHelper.class); | |
public static <T> T fromXml(String xml, Class<?> clazz) { | |
Unmarshaller um = null; | |
try { | |
um = JAXBContext.newInstance(clazz).createUnmarshaller(); | |
Object obj = um.unmarshal(new StringReader(xml)); | |
return (T) obj; | |
} catch (JAXBException e) { | |
e.printStackTrace(); | |
logger.error("Can't unmarshal from XML: ", e); | |
} | |
return null; | |
} | |
} | |
package com.macquarie.mpl.web.model.dte.genericxml; | |
import javax.xml.bind.annotation.XmlElement; | |
import javax.xml.bind.annotation.XmlRootElement; | |
import java.util.List; | |
@XmlRootElement(name = "report") | |
public class ForwardCashReportResponse { | |
@XmlElement(name = "value") | |
public Value value; | |
@XmlElement(name = "type") | |
public Type type; | |
public static class Type { | |
@XmlElement(name = "error") | |
public Error error; | |
} | |
public static class Error { | |
@XmlElement(name = "vector") | |
public Vector vector; | |
} | |
public static class Vector { | |
@XmlElement(name = "forward_cash") | |
public String fwdCash; | |
} | |
public static class Value { | |
@XmlElement(name = "list") | |
public RowList list; | |
@XmlElement(name = "error") | |
public String errorMessage; | |
} | |
public static class RowList { | |
@XmlElement(name = "litem") | |
public List<Litem> list; | |
} | |
public static class Litem { | |
@XmlElement(name = "forward_cash") | |
public ForwardCash forwardCash; | |
} | |
public static class ForwardCash { | |
@XmlElement(name = "date") | |
public String date; | |
@XmlElement(name = "amount") | |
public double amount; | |
@XmlElement(name = "asset") | |
public String asset; | |
@XmlElement(name = "contingent") | |
public String contingent; | |
@XmlElement(name = "payment_key") | |
public String payment_key; | |
@XmlElement(name = "counterparty") | |
public String counterparty; | |
@XmlElement(name = "description") | |
public String description; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment