@@ -0,0 +1,2270 @@
+/*%0A * Copyright 2016 PantherCode%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *        http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.panthercode.arctic.core.xml;%0A%0Aimport org.panthercode.arctic.core.arguments.ArgumentUtils;%0Aimport org.panthercode.arctic.core.io.IOUtils;%0A%0Aimport javax.xml.bind.JAXB;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0A%0A/**%0A * Utils class that contains a set of functions to handle xml files and objects.%0A */%0Apublic class XmlUtils %7B%0A%0A    /**%0A     * private constructor%0A     */%0A    private XmlUtils() %7B%0A    %7D%0A%0A    /**%0A     * Writes an object to a xml file.%0A     *%0A     * @param path path to xml file%0A     * @param obj  object to store in xml file%0A     * @throws IOException Is thrown if an error occurs while writing in file.%0A     */%0A    public static void writeToFile(String path, Object obj)%0A            throws IOException %7B%0A        ArgumentUtils.assertNotNull(obj, %22object%22);%0A%0A        try (FileOutputStream stream = IOUtils.toFileOutputStream(path)) %7B%0A            JAXB.marshal(obj, stream);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Reads in an object from a xml file.%0A     *%0A     * @param path  path to file%0A     * @param clazz class type of returned object%0A     * @param %3CT%3E   type of return type%0A     * @return Returns an object with given type.%0A     * @throws IOException Is thrown if an error occurs while reading the file.%0A     */%0A    public static %3CT%3E T readFromFile(String path, Class%3CT%3E clazz)%0A            throws IOException %7B%0A        ArgumentUtils.assertNotNull(path, %22path%22);%0A        ArgumentUtils.assertNotNull(clazz, %22clazz%22);%0A%0A        T result;%0A%0A        try (FileInputStream stream = IOUtils.toFileIntputStream(path)) %7B%0A            result = JAXB.unmarshal(stream, clazz);%0A        %7D%0A%0A        return result;%0A    %7D%0A%7D%0A

implement xml package