Package webapp.storage

Source Code of webapp.storage.XmlStorage

package webapp.storage;

import webapp.model.*;
import webapp.util.JaxbParser;

import java.io.*;

/**
* User: gkislin
* Date: 28.04.2014
*/
public class XmlStorage extends FileStorage {
    private JaxbParser xmlParser;

    public XmlStorage(String path) {
        super(path);
        xmlParser = new JaxbParser(Resume.class, Organization.class, Link.class,
                OrganizationSection.class, StringSection.class, Period.class);
    }

    @Override
    protected void doWrite(OutputStream os, Resume resume) throws IOException {
        try (Writer w = new OutputStreamWriter(os)) {
            xmlParser.marshall(resume, w);
        }
    }

    @Override
    protected Resume doRead(InputStream is) throws IOException {
        try (Reader r = new InputStreamReader(is)) {
            return xmlParser.unmarshall(r);
        }
    }
}
TOP

Related Classes of webapp.storage.XmlStorage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.