package com.gyee.edge.protocol.iec60870.infoelement;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * Represents a last section or segment qualifier (LSQ) information element.
 */
public class IeLastSectionOrSegmentQualifier extends InformationElement {

    private final int value;

    public IeLastSectionOrSegmentQualifier(int value) {
        this.value = value;
    }

    static IeLastSectionOrSegmentQualifier decode(DataInputStream is) throws IOException {
        return new IeLastSectionOrSegmentQualifier(is.readUnsignedByte());
    }

    @Override
    int encode(byte[] buffer, int i) {
        buffer[i] = (byte) value;
        return 1;
    }

    public int getValue() {
        return value;
    }

    @Override
    public String toString() {
        return "Last section or segment qualifier: " + value;
    }
}
