All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.powsybl.powerfactory.dgs.DgsStudyCaseLoader Maven / Gradle / Ivy

There is a newer version: 6.6.0
Show newest version
/**
 * Copyright (c) 2021, RTE (http://www.rte-france.com)
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.powsybl.powerfactory.dgs;

import com.google.auto.service.AutoService;
import com.google.common.io.Files;
import com.powsybl.powerfactory.model.StudyCase;
import com.powsybl.powerfactory.model.PowerFactoryDataLoader;

import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author Geoffroy Jamgotchian 
 */
@AutoService(PowerFactoryDataLoader.class)
public class DgsStudyCaseLoader implements PowerFactoryDataLoader {

    @Override
    public Class getDataClass() {
        return StudyCase.class;
    }

    @Override
    public String getExtension() {
        return "dgs";
    }

    @Override
    public boolean test(InputStream is) {
        return true;
    }

    @Override
    public StudyCase doLoad(String fileName, InputStream is) {
        String studyCaseName = Files.getNameWithoutExtension(fileName);
        return new DgsReader().read(studyCaseName, new InputStreamReader(is));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy