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

org.openmuc.jdlms.internal.sessionlayer.hdlc.FrameInvalidException Maven / Gradle / Ivy

Go to download

jDLMS is a library implementing the DLMS/COSEM (IEC 62056) communication standard.

There is a newer version: 1.8.0
Show newest version
/*
 * Copyright 2012-16 Fraunhofer ISE
 *
 * This file is part of jDLMS.
 * For more information visit http://www.openmuc.org
 *
 * jDLMS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * jDLMS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with jDLMS.  If not, see .
 *
 */
package org.openmuc.jdlms.internal.sessionlayer.hdlc;

import java.util.List;

import org.openmuc.jdlms.internal.sessionlayer.hdlc.FrameRejectReason.RejectReason;

public class FrameInvalidException extends Exception {
    private FrameRejectReason reason;

    FrameInvalidException(String message) {
        super(message);
    }

    FrameInvalidException(String message, FrameRejectReason reason) {
        super(String.format("%s. REASON: %s", message, reasonsToString(reason.rejectReasons())));
        this.reason = reason;
    }

    private static String reasonsToString(List reasons) {
        StringBuilder builder = new StringBuilder();
        for (RejectReason rejectReason : reasons) {
            builder.append(rejectReason.name()).append(", ");
        }
        return builder.toString();
    }

    public FrameRejectReason rejectReason() {
        return reason;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy