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

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

/**
 * Represents a name of section (NOS) information element.
 */
public class IeNameOfSection extends InformationElement {

    private final int value;

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

    static IeNameOfSection decode(DataInputStream is) throws IOException {
        return new IeNameOfSection(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 "Name of section: " + value;
    }
}
