// Path: src/main/java/cz/tomasdvorak/eet/client/exceptions/RequestSerializationException.java
// public class RequestSerializationException extends RuntimeException {
//     public RequestSerializationException(final String message, final JAXBException cause) {
//         super(message, cause);
// 
//     }
// }


import cz.etrzby.xml.ObjectFactory;
import cz.etrzby.xml.TrzbaType;
import cz.tomasdvorak.eet.client.exceptions.RequestSerializationException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
import java.io.*;
package cz.tomasdvorak.eet.client.persistence;



/**
 * EET request serializer / deserializer. May serve for persistence or logging.
 */
public class RequestSerializer {

    /**
     * Convert request to a String representation.
     */
    public static String toString(TrzbaType request) {
        try {
            final JAXBElement<TrzbaType> trzba = new ObjectFactory().createTrzba(request);
            JAXBContext context = JAXBContext.newInstance(TrzbaType.class);
            StringWriter sw = new StringWriter();
            context.createMarshaller().marshal(trzba, sw);
            return sw.toString();
        } catch (JAXBException e) {
// Path: src/main/java/cz/tomasdvorak/eet/client/exceptions/RequestSerializationException.java
// public class RequestSerializationException extends RuntimeException {
//     public RequestSerializationException(final String message, final JAXBException cause) {
//         super(message, cause);
// 
//     }
// }


// Path: src/main/java/cz/tomasdvorak/eet/client/persistence/RequestSerializer.java
import cz.etrzby.xml.ObjectFactory;
import cz.etrzby.xml.TrzbaType;
import cz.tomasdvorak.eet.client.exceptions.RequestSerializationException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
import java.io.*;

package cz.tomasdvorak.eet.client.persistence;



/**
 * EET request serializer / deserializer. May serve for persistence or logging.
 */
public class RequestSerializer {

    /**
     * Convert request to a String representation.
     */
    public static String toString(TrzbaType request) {
        try {
            final JAXBElement<TrzbaType> trzba = new ObjectFactory().createTrzba(request);
            JAXBContext context = JAXBContext.newInstance(TrzbaType.class);
            StringWriter sw = new StringWriter();
            context.createMarshaller().marshal(trzba, sw);
            return sw.toString();
        } catch (JAXBException e) {
            throw new RequestSerializationException("Failed to serialize EET request to String", e);