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

org.openlr.binary.writer.StatusWriter Maven / Gradle / Ivy

The newest version!
package org.openlr.binary.writer;

import org.openlr.binary.format.Status;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

class StatusWriter {
    void write(Status status, ByteArrayOutputStream outputStream) throws IOException {
        int versionBits = status.getVersion();
        int attributesFlagBit = (status.isAttributeFlag() ? 1 : 0) << 3;
        int areaFlag0Bit = (status.getAreaFlag() & 0x01) << 4;
        int pointFlagBit = (status.isPointFlag() ? 1 : 0) << 5;
        int areaFlag1Bit = (status.getAreaFlag() & 0x02) << 5;

        byte b = (byte) (areaFlag1Bit | pointFlagBit | areaFlag0Bit | attributesFlagBit | versionBits);
        outputStream.write(new byte[] { b });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy